Commit Graph

611 Commits (1.2.x)

Author SHA1 Message Date
Stephane Nicoll bb736e255b Fix SNAPSHOT version 9 years ago
Phillip Webb 2694605a4d Polish 9 years ago
Stephane Nicoll ce2346b087 Reintroduce endpoints.metrics.filter.enabled
Commit 8c14009 removed the endpoints.metrics.filter.enabled property so
that endpoints.metrics.enabled is used for both disabling the endpoint
and the servlet filter that records interactions.

This was an unfortunate decision as it was no longer possible to only
disable the servlet filter. The endpoints.metrics.filter.enabled property
has therefore been restored.

Closes gh-4365
9 years ago
Dave Syer 7d04ca1e1b Add tests to assert behaviour of actuator endpoints with context path
See gh-4401
9 years ago
Stephane Nicoll 8c140092b6 Fix key to disable the metrics filter
Commit d0cf6b5 introduced a `endpoints.metrics.filter.enabled` property
key meant to disable the filter. Unfortunately, the `endpoints.metrics`
namespace is already managed so setting this property will fail.

We now use the same key than the one used to disable the metrics
endpoint.

Closes gh-4365
9 years ago
Stephane Nicoll 2e2ebeb9fa Allow PORTFILE to always override the file to use
Previously, the `PORTFILE` system property was not checked if the
`EmbeddedServerPortFileWriter` was created using the default constructor.

This had the effect to prevent overriding of the port file when this
listener is created without any file or via `META-INF/spring.factories`.

Closes gh-4254
9 years ago
Phillip Webb a79131f8d2 Organize imports with new settings
See gh-4234
9 years ago
Spring Buildmaster 2b38a861e3 Next Development Version 9 years ago
Andy Wilkinson e4895f8fde Disable child context's /error endpoint if disabled in parent
Previously, EndpointWebMvcChildContextConfiguration would attempt to
create a /error endpoint, irrespective of whether or not the parent
had such an endpoint. If the endpoint was disabled in the parent this
would cause a failure due to the absence of an ErrorAttributes bean.

This commit updates EndpointWebMvcChildContextConfiguration to make
the creation of its /error endpoint conditional on the existence of
an ErrorAttributes bean.

Closes gh-4164
9 years ago
Phillip Webb 94736719f1 Reformat package-info.java files with Eclipse Mars 9 years ago
Phillip Webb 6ab376e2e8 Reformat code use Eclipse Mars 9 years ago
Andy Wilkinson 9a703ab4d1 Correct quotation marks in spring-boot-actuator’s README
Closes gh-4095
9 years ago
Andy Wilkinson d793d5abcb Work around intermittent failure caused by SPR-13079
See gh-4098
9 years ago
Andy Wilkinson 6387f36efa Work around MockMvc bug (SPR-13079) that has only been fixed in 4.2
See gh-4098
9 years ago
Andy Wilkinson b8b4ea489e Improve MetricsFilter’s handling of async requests
Previously, MetricsFilter would treat async requests the same as
sync requests and would record their response status as soon as the
request had been processed by the filter chain. This would result in a
200 response being recorded and the actual response status produced by
the async processing being ignored. Furthermore, the time that was
recorded for the request would not include the time take for any async processing.

This commit updates MetricsFilter to check whether or not an async
request has been started before it records the metrics for the request.
In the event of an async request having been started no metrics are
recorded. Instead, the StopWatch is stored in a request attribute that
is then retrieved during the filtering of the request’s async
dispatch(es). Once the async processing has completed (isAsyncStarted()
returns false), the StopWatch is stopped, removed from the request’s
attributes and the metrics for the request are recorded.

Closes gh-4098
9 years ago
Spring Buildmaster 9409c49c10 Next development version 9 years ago
Phillip Webb 15686ed4fd Reformat code 9 years ago
Stephane Nicoll 11b82cc6fe Properly guard DB health indicator
The DataSource health indicator uses `JdbcTemplate` behind the scenes
but nothing was checking that it is actually available.

`DataSourcesHealthIndicatorConfiguration` is now disabled if
`spring-jdbc` is not on the classpath.

Fixes gh-3765
9 years ago
Phillip Webb d2d71934b6 Polish 9 years ago
Stephane Nicoll 539b009d12 Clean management context path if necessary
Various areas of the code expect the management's context path to not
contain any trailing slash but nothing is enforcing it. We now make sure
to remove any trailing slash, including the one for '/' and make that
explicit via the Javadoc of the getter.

Fixes gh-3553
9 years ago
Dave Syer d0cf6b534b Add 3xx redirects to the "unmapped" class of requests for metrics
When Spring Security sends 302 responses to a login page we don't get
any information about the request matching in Spring MVC. Consequently
apps can end up with a lot of counter.status.302.* metrics (where
"*" can be whatever the user sent).

This change treats 3xx the same as 4xx (if it is unmapped it just gets
added to a metric called "unmapped" instead of using the actual request
path).

Fixes gh-2563
9 years ago
Johannes Stelzer fdb83ec338 Correct assertion for indicators parameter in CompositeHealthIndicator
Closes gh-3417
9 years ago
Spring Buildmaster 7ce391db4f Next development version 10 years ago
Phillip Webb 3ef667f0d8 Fix MetricWriterMessageHandler to deal with reset
Update MetricWriterMessageHandler to deal with 'reset' messages and to
log unsupported payload types.

Fixes gh-3378
10 years ago
olivier bourgain 5ed2a9632b Make InMemoryTraceRepository thread-safe
Closes gh-3027
10 years ago
Stephane Nicoll 5a57913732 Tune spring-boot-actuator logging config
Closes gh-3060
10 years ago
Spring Buildmaster 5d81c87b43 Next Development Version 10 years ago
Phillip Webb df0ba5c03a Guard against metric failures in MetricsFilter
Update MetricsFilter so that failures to record metrics are logged and
ignored.

Fixes gh-2777
10 years ago
Phillip Webb 1d5a62b3df Show `endpoint.isEnabled` in `/configprops`
Update `ConfigurationPropertiesReportEndpoint` so that properties that
are set with a Boolean class but read with a boolean primitive still
appear in the report. The allows the Endpoint.isEnabled() property to
be displayed.

Fixes gh-2929
10 years ago
Phillip Webb aaa2ff54dd Extract @ConditionalOnEnabledEndpoint
Extract @ConditionalOnEnabledEndpoint to a top level class.

See gh-2798
10 years ago
Phillip Webb 968b68c322 Polish 10 years ago
Andy Wilkinson ffcc854d42 Include exception in warning message when pid file cannot be created
Closes gh-2905
10 years ago
Josh Thornhill b16a973d6a Honor the endpoint.enabled property when registering MBeans
Fixes gh-2873
Closes gh-2890
10 years ago
Rob Winch b54960f072 Management Security uses Spring Realm
Previously ManagementSecurityAutoConfiguration used Spring Security's
default realm of "Realm" when authentication failed. This was confusing
because when prompted for authentication (i.e. no credentials provided)
the realm "Spring" was requested.

This commit ensures the Realm that is used is consistent for all of of the
security auto configuration.

Fixes #2466
10 years ago
Andy Wilkinson 764e34b9db Don’t start child context for actuator endpoints when not embedded
Prior to this commit, EndpointWebMvcAutoConfiguration would start a
child context if the management port was different to the server port
and the application context was a web application context. This caused
two problems:

If a user built an executable war and configured the management port so
that it was different to the server port, their application would run
successfully when launched with java -jar, but it would fail when
deployed to Tomcat as an attempt would be made to start embedded Tomcat.

Secondly, if a user ran a test annotated with @WebAppConfiguration the
main embedded Tomcat instance would not be started, but the child
context would trigger the creation of a Tomcat instance listening on the
configured management port. This is unexpected as @WebIntegrationTest
or @IntegrationTest and @WebAppConfiguration should be required to have
the test trigger full startup of the application and listen on the
configured ports.

This commit updates EndpointWebMvcAutoConfiguration so that it will only
start a child context when the management port is different to the
server port and the EmbeddedWebApplicationContext has an embedded
servlet container. This resolves the two problems described above as
there will be no embedded servlet container when deployed to a
standalone container or when a test is run without @IntegrationTest.

Fixes gh-2798
10 years ago
Andy Wilkinson 0c7708bf9f Update MetricFilter to treat an unsuccessful call to doFilter as a 500
Previously, if a call to doFilter in MetricFilter failed (i.e. it threw
an exception), it would be handled as if it had a response status of
200. This is because the servlet container was yet to handle the
exception and set the response status to 500.

This commit updates MetricFilter to assume that an exception thrown from
doFilter will result in a response with a status of 500. Strictly
speaking, even though the filter has highest precedence and will
therefore run last on the way back out, this may not always be the case.
For example, a custom Tomcat Valve could handle the exception and result
in a 200 response but that’s an edge case that’s into shooting yourself
in the foot territory.

Closes gh-2818
10 years ago
Stephane Nicoll 08959286e2 Fix "keys-to-sanitize" property doc 10 years ago
Phillip Webb e94de70358 Polish 10 years ago
Dave Syer 8cdff1cf70 Fix bug in trace repository
When reverse==false we have to be careful to remove the right element
when capacity is reached.
10 years ago
Dave Syer 8ef21b31ad Add flag to TraceRepository to reverse order of listing
Default to true (so existing apps change their behaviour, but that
seems to be the majority vote).

Fixes gh-2794
10 years ago
Andy Wilkinson 83f842a226 Reinstate support for relaxed binding for endpoint enablement
This commit improves upon the changes made in a8bf9d3 by adding
support for relaxed binding of the endpoints.enabled and
endpoints.<name>.enabled properties. This is achieved by replacing
use of @ConditionalOnExpression (which does not support relaxed
binding) with a custom condition implementation that uses
RelaxedPropertyResolver.

Closes gh-2767
10 years ago
Andy Wilkinson a8bf9d34d5 Honour endpoint.enabled:false for nested paths
Previously, only invocations of /metricName/ would honour the enabled
property and return a not found (404) response. For endpoints which
support nested paths, access to /metricName/foo would ignore the enabled
flag and return an OK (200) response. Furthermore, there was a comment
in EndpointMvcAdapter that suggested that an endpoint shouldn’t be
called when it is disabled, however this was not the case.

This commit updates EndpointWebMvcAutoConfiguration and
JolokiaAutoConfiguration to only register their MvcEndpoint beans if
the underlying endpoint is enabled. This means that an
EndpointMvcAdapter should not be called if its delegate is disabled,
making the comment described above accurate.

The check for the delegate being enabled has been retained so as not to
rely upon the auto-configurations’ behaviour. The methods which handle
nested paths (MetricsMvcEndpoint.value() and
EnvironmentMvcEndpoint.value()) have been updated to add the same check
for the enablement of their delegate.

Fixes gh-2767
10 years ago
Spring Buildmaster e03c11dda8 Next development version 10 years ago
Phillip Webb 4c50c9eaa8 Allow basic SystemPublicMetrics on GAE
Update SystemPublicMetrics to silently ignore ManagementFactory
NoClassDefFoundErrors which can occur when deploying to Google App
Engine.

Fixes gh-2701
10 years ago
Andy Wilkinson c1eea4cf40 Ensure that a TTL of zero is honoured by HealthMvcEndpoint
See gh-2630
10 years ago
Andy Wilkinson c849a0aba1 Cache /health response irrespective of sensitivity and security
Previously, the response from /health was not cached if the request
was secure, i.e. the user has authenticated, or the endpoint was
configured as not being sensitive. 

The commit updates HealthMvcEndpoint to apply the caching logic
all the time. Users that do not want caching can disable it by 
configuring the TTL with a value of zero.

Closes gh-2630
10 years ago
Andy Wilkinson 8b20403c41 Use a String when referencing a class with @ConditionalOnMissingClass
Using a Class reference can cause reflection problems at runtime (see
gh-1065).

Closes gh-2674
10 years ago
Phillip Webb 16495d223a Polish 10 years ago
Andy Wilkinson 743482ab69 Tolerate Gauges with non-Number values
Spring Boot's metrics infrastructure requires a Metric to have a
Number value. Coda Hale's ThreadStatesGaugeSet includes a Gauge
named deadlocks with a Set<String> value (each entry in the set is a
description, including stacktrace, of a deadlocked thread). There's
no obvious way to coerce this to a Number, and there's already a
deadlocks.count metric in the set.

This commit updates MetricRegistryMetricReader to ignore the addition
of any Gauge with a non-Number value.

Fixes gh-2593
10 years ago
Andy Wilkinson 4487823ff9 Improve thread-safety of MetricRegistryMetricReader
ee567fa boldy claimed that it had made MetricRegistryMetricReader
thread-safe. It had not. This commit should actually make it thread
safe. I hope.

One notable improvement is that MetricRegistryMetricReader.findAll()
will no longer contain null values if a metric is removed on another
thread during iteration.

names is now a ConcurrentHashMap to allow it to be safely read and
written without holding a lock.

reverse is a LinkedMultiValueMap  which is not thread-safe. This could
lead to values being lost when concurrent add calls were made. Access
to reverse is now protected by synchronizing on an internal monitor
object.

Calls to containsKey(key) followed by get(key) have been reworked to
only call get(key), this avoids the possibility of the key being
removed after the contains check but before the get.

Closes gh-2590
10 years ago