Commit Graph

611 Commits

Author SHA1 Message Date
Stephane Nicoll
bb736e255b Fix SNAPSHOT version 2015-12-17 14:15:14 +01:00
Phillip Webb
2694605a4d Polish 2015-12-10 14:43:00 +00:00
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
2015-12-10 15:37:10 +01:00
Dave Syer
7d04ca1e1b Add tests to assert behaviour of actuator endpoints with context path
See gh-4401
2015-11-27 10:56:04 +00:00
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
2015-11-03 10:14:39 +01:00
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
2015-10-21 13:58:48 +02:00
Phillip Webb
a79131f8d2 Organize imports with new settings
See gh-4234
2015-10-19 12:55:44 -07:00
Spring Buildmaster
2b38a861e3 Next Development Version 2015-10-16 05:57:24 -07:00
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
2015-10-14 12:06:10 +01:00
Phillip Webb
94736719f1 Reformat package-info.java files with Eclipse Mars 2015-10-09 13:32:57 -07:00
Phillip Webb
6ab376e2e8 Reformat code use Eclipse Mars 2015-10-07 23:32:31 -07:00
Andy Wilkinson
9a703ab4d1 Correct quotation marks in spring-boot-actuator’s README
Closes gh-4095
2015-10-07 11:33:43 +01:00
Andy Wilkinson
d793d5abcb Work around intermittent failure caused by SPR-13079
See gh-4098
2015-10-06 11:43:53 +01:00
Andy Wilkinson
6387f36efa Work around MockMvc bug (SPR-13079) that has only been fixed in 4.2
See gh-4098
2015-10-06 11:25:18 +01:00
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
2015-10-06 11:00:59 +01:00
Spring Buildmaster
9409c49c10 Next development version 2015-09-16 09:00:17 -07:00
Phillip Webb
15686ed4fd Reformat code 2015-09-08 14:07:06 -07:00
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
2015-08-17 10:08:07 +02:00
Phillip Webb
d2d71934b6 Polish 2015-07-20 10:04:28 -07:00
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
2015-07-20 10:56:52 +02:00
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
2015-07-13 13:33:30 +01:00
Johannes Stelzer
fdb83ec338 Correct assertion for indicators parameter in CompositeHealthIndicator
Closes gh-3417
2015-07-13 09:58:33 +01:00
Spring Buildmaster
7ce391db4f Next development version 2015-07-01 22:48:01 -07:00
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
2015-07-01 18:11:53 -07:00
olivier bourgain
5ed2a9632b Make InMemoryTraceRepository thread-safe
Closes gh-3027
2015-06-22 15:30:00 +01:00
Stephane Nicoll
5a57913732 Tune spring-boot-actuator logging config
Closes gh-3060
2015-06-08 15:43:30 +02:00
Spring Buildmaster
5d81c87b43 Next Development Version 2015-06-04 00:49:11 -07:00
Phillip Webb
df0ba5c03a Guard against metric failures in MetricsFilter
Update MetricsFilter so that failures to record metrics are logged and
ignored.

Fixes gh-2777
2015-06-02 14:30:59 -07:00
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
2015-06-02 12:01:47 -07:00
Phillip Webb
aaa2ff54dd Extract @ConditionalOnEnabledEndpoint
Extract @ConditionalOnEnabledEndpoint to a top level class.

See gh-2798
2015-06-02 11:17:23 -07:00
Phillip Webb
968b68c322 Polish 2015-06-02 11:17:16 -07:00
Andy Wilkinson
ffcc854d42 Include exception in warning message when pid file cannot be created
Closes gh-2905
2015-05-05 16:40:48 +01:00
Josh Thornhill
b16a973d6a Honor the endpoint.enabled property when registering MBeans
Fixes gh-2873
Closes gh-2890
2015-04-30 15:28:45 +01:00
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
2015-04-27 17:32:47 -05:00
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
2015-04-15 13:47:30 +01:00
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
2015-04-14 12:24:32 +01:00
Stephane Nicoll
08959286e2 Fix "keys-to-sanitize" property doc 2015-04-13 12:28:34 +02:00
Phillip Webb
e94de70358 Polish 2015-04-09 10:42:53 -07:00
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.
2015-04-09 13:11:59 +01:00
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
2015-04-09 12:04:19 +01:00
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
2015-04-08 11:29:41 +01:00
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
2015-04-07 17:43:02 +01:00
Spring Buildmaster
e03c11dda8 Next development version 2015-03-30 22:56:20 -07:00
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
2015-03-24 13:56:12 -07:00
Andy Wilkinson
c1eea4cf40 Ensure that a TTL of zero is honoured by HealthMvcEndpoint
See gh-2630
2015-03-19 17:16:08 +00:00
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
2015-03-19 16:23:04 +00:00
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
2015-03-18 11:16:58 +00:00
Phillip Webb
16495d223a Polish 2015-03-16 14:11:43 -07:00
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
2015-03-05 11:07:58 +00:00
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
2015-03-04 15:03:03 +00:00