Add an `DispatcherServletPath` interface which provides a much more
consistent way to discover the path of the main dispatcher servet.
Prior to this commit, auto-configurations would often make use of the
`ServerProperties` class to discover the dispatcher servlet path. This
mechanism isn't very explicit and also makes it hard for us to relocate
that property in Spring Boot 2.1.
This commit also reverts most of fddc9e9c7e since it is now clear that
the supporting multiple dispatcher servlet paths will be much more
involved that we originally anticipated.
Closes gh-13834
Previously, when a DispatcherServlet was registered via a
ServletRegistrationBean, the mappings endpoint did not expose any
information about it as it wasn't detected.
This commit fixes the detection of available DispatcherServlets in the
context so that the mappings endpoint include them all.
Closes gh-13186
This commit improves the for Actuator Metrics in WebClient.
Unlike the server couterpart of WebFlux, using a `retry` operator on a
`WebClient` pipeline does resubscribes to the whole chain.
The previous implementation recorded start time at the time of pipeline
build phase, but outside of it. This doesn't work since retrying the
same pipeline doesn't update the recorded start time and the duration of
sequential calls are cumulative.
This is now fixed using the Reactor `Context`, since we're now recording
the start time at subscription time and record metrics on `onNext` and
`onError` signals.
Closes gh-12228
Previously, a NullPointerException would occur when WebFluxTags
attempted to create a method Tag for a request with a non-standard
method.
This commit updates WebFluxTags to use getMethodValue(), which will
never return null, rather than getMethod(), which may return null,
when determining the tag's value for the given request.
Closes gh-13596
As of Spring Framework 5.1, we're depending on the Reactor Californium
release train.
Reactor Netty is now at version 0.8 and changed its artifact
coordinates, package names and broke several APIs. Spring Framework is
now up-to-date with those changes and this commit does the same for
Spring Boot.
Note that in that process, the `NettyServerCustomizer` has been changed
since the former `HttpServerOptions.Builder` API is now gone from
Reactor Netty, and we're now relying on immutable server instances
instead of a stateful builder pattern.
See gh-13321
Previously, WebMvcTags would fall back to using the request’s path
info if Spring MVC’s best matching path pattern attribute was not
available. For non-Spring MVC web frameworks that support path
variables, such as Jersey, this led to an explosion of URI tags that
could exhaust the heap.
Closes gh-12447
This commit fixes endpoint extension discovery when the related endpoint
is sub-classed. Previously, a strict by type check was applied against
the `endpoint` attribute of `EndpointExtension`.
Rather than using a `Class` check, this commit extracts the id of an
endpoint and uses it to match its extension, if any.
Closes gh-13082
This commit improves the `health` endpoint to run health check for a
particular component or, if that component is itself a composite, an
instance of that component.
Concretely, it is now possible to issue a `GET` on
`/actuator/health/{component}` and
`/actuator/health/{component}/instance` to retrieve the health of a
component or an instance of a composite component, respectively.
If details cannot be showed for the current user, any request leads to a
404 and does not invoke the health check at all.
Closes gh-8865
This commit updates the initial proposal to add support for reactive
use cases as well. A reactive application can use
ReactiveHealthIndicatorRegistry as an alternative to
HealthIndicatorRegistry.
Closes gh-4965
This commit introduces HealthIndicatorRegistry which handles
registration of HealthIndicator instances. Registering new
HealthIndicator instances is now possible in runtime.
See gh-4965
This commit improves the initial proposal by providing a by name read
operation that returns the detail of a particular cache. It also adds
more tests and complete API documentation for the feature.
Closes gh-12216
This commits adds an actuator endpoint which lists the caches per
context and cacheManager and provides a delete operation to clear the
caches. As the statistics are exposed via the metrics endpoint they are
not included
See gh-12216
This commit adds support for Actuator Metrics for WebClient.
This support mirrors the current behavior for `RestTemplate`, reusing
the same metric name `"http.client.requests"` and tags.
`WebClient` is instrumented by a `MetricsWebClientFilterFunction` which
is applied by a `WebClientCustomizer`. This instrumentation happens
automatically only if you create an instance of `WebClient` using an
auto-configured `WebClient.Builder` bean.
This infrastructure is reusing de facto the `MeterFilter` that has been
added for `RestTemplate` in order to limit the "uri" tag cardinality.
Closes gh-12228
This commit makes sure to respect the MBeanServer#invoke contract by
wrapping any user-defined exception in an MBeanException. Also, any
exception not from the JDK is translated, as it may lead to unexpected
issue on the client if that class isn't present. This is consistent
with our operation result mapping strategy.
Closes gh-10448
As pointed out by Rossen in gh-11514 comments, a handler might commit
the response and then send an error signal in the pipeline. In this
case, adding a callback to `beforeCommit` is useless because it won't be
triggered. In those cases, we need to collect metrics right away.
Spring Boot now deploys both annotation-based and functional endpoints
under the same `HttpHandler`; this means the currently auto-configured
`MetricsWebFilter` is instrumenting all endpoints to produce metrics.
There is no need for a WebFlux functional specific support.
This commit removes mentions of `RouterFunctionMetrics` in the docs and
deprecates that class.
Closes gh-12833
Prior to this commit, the metrics `WebFilter` would handle exceptions
flowing through the pipeline and extract tag information right away.
Since error handling turns the exception information into error HTTP
responses later in the chain, the information extracted from the
response earlier is invalid.
In this case, the "status" information could be "200" whereas error
handlers would later set that status to "500".
This commit delays the tags extraction later in the process, right
before the response is comitted. The happy path is not changed, as
handlers signal that the response is fully taken care of at that point.
Fixes gh-11514
Previously to this commit, if a `@ControllerEndpoint`,
`@RestControllerEndpoint` or `@ServletEndpoint` annotated bean was
proxied, the endpoint wasn't properly detected.
This commit makes sure that annotation retrieval works on the user class
while preserving the get (vs. find) retrieval semantic
Closes gh-12441
This commit ensures that `WebFluxTags` not only relies on
`BEST_MATCHING_PATTERN_ATTRIBUTE` or request URI to provide the "uri"
tag information.
To avoid cardinality explosion, HTTP not found and redirects are
assigned fixed uri tags.
Closes gh-12685
Prior to this commit, `WebMvcTags' would always mark as "NOT_FOUND" or
"REDIRECTION" *any* exchange with responses of 404 and 3xx status, even
if those responses are actually returned by Controller handlers.
This commit checks inverts those checks and first considers if the
"BEST_MATCHING_PATTERN_ATTRIBUTE" request attribute is present and uses
it - then falls back to "NOT_FOUND" and "REDIRECTION" to avoid
cardinality explosion.
Fixes gh-12577
Create a new `ApplicationConversionService` similar in design to the
DefaultFormattingConversionService from Spring Framework. The new
conversion service provides a central place for custom conversion logic
supported by Spring Boot.
Also replace the `BindingConversionService` with an internal
`BindConverter` class that now invokes the `SimpleTypeConverter`
directly. Binding for `@ConfigurationProperties` has been updated so
that any custom property editors registered with the BeanFactory can
be used.
Fixes gh-12095
Move leading slash logic from `MetricsClientHttpRequestInterceptor` to
`RestTemplateExchangeTags` so that URI based calls are also managed.
Closes gh-12126
Previously, if a controll endpoint included a mapping with no path,
it would be mapped to the root of the application rather than the
root of the endpoint's path.
This commit updates the handler mappings for both reactive and Servlet
web applications to treat a mapping with no paths as being a mapping
with a single empty path. This ensures that a path with the endpoint's
path prepended is used for the mapping.
Closes gh-12104
Remove custom `SpringIntegrationMetrics` and instead provide
auto-configuration to the direct Micrometer support added in Spring
Integration 5.0.2.
Closes gh-11985
Previously, links were only provide to web endpoints. This commit
expands link resolution to also provide links for servlet endpoints,
controller endpoints, and rest controller endpoints.
Closes gh-11902
Update `GitProperties` so that the `commit.id` entry is also copied to
`commit.id.full`.
Prior to this commit, when returning full details, the value of
`commit.id` would be replaced with a `Map` containing only `abbriv` as
a key. By copying the value to a sub-key we ensure that it remains
available both in the FULL and SIMPLE modes.
Fixes gh-11892
Update `AbstractHealthIndicator` so that the warning message can be
customized. Also updated our existing indicators with better messages.
Fixes gh-11880
Move the "testdb" naming logic to `DataSourceProperties` and expose
the `deduceDatabaseName` method so they can be used in
auto-configuration.
See gh-11719
Previously, Hikari's pool name was auto-configured with the value of
`spring.datasource.name` that defaults to `testdb`, which brings some
confusion.
This commit removes the default `testdb` value on
`spring.datasource.name` as it is a sane default only for an embedded
datasource. It is applied whenever applicable instead.
Closes gh-11719
This commit adds InvalidEndpointRequestException as a technology
agnostic way to signal that an endpoint request is invalid. When such
exception is thrown, the web layer translates that to a 400.
Rather than overriding the reason, this commit makes sure to reuse the
error infrastructure.
Closes gh-10618
This commit makes sure that `CharacterEncodingFilter` is ordered with
the `Ordered.HIGHEST_PRECEDENCE` and that other filters, potentially
reading the request body, are ordered after.
In this particular case, both `WebMvcMetricsFilter` and
`ErrorPageFilter` are now ordered at `Ordered.HIGHEST_PRECEDENCE + 1` to
avoid cases where the request body is read before the encoding
configuration is taken into account.
Closes gh-11607
Add `@ControllerEndpoint` and `@RestControllerEndpoint` annotations that
can be used to develop a Spring-only request mapped endpoint. Both
Spring MVC and Spring WebFlux are supported.
This feature is primarily for use when deeper Spring integration is
required or when existing Spring Boot 1.5 projects want to migrate to
Spring Boot 2.0 without re-writing existing endpoints. It comes at the
expense of portability, since such endpoints will be missing from
Jersey.
Fixes gh-10257