Class ServerHttpObservationFilter
java.lang.Object
org.springframework.web.filter.reactive.ServerHttpObservationFilter
- All Implemented Interfaces:
WebFilter
WebFilter
that creates observations
for HTTP exchanges. This collects information about the execution time and
information gathered from the ServerRequestObservationContext
.
Web Frameworks can fetch the current context
as a request attribute
and contribute
additional information to it.
The configured ServerRequestObservationConvention
will use this context to collect
metadata
and attach it to the observation.
- Since:
- 6.0
- Author:
- Brian Clozel
-
Field Summary
-
Constructor Summary
ConstructorDescriptionServerHttpObservationFilter
(io.micrometer.observation.ObservationRegistry observationRegistry) Create anHttpRequestsObservationWebFilter
that records observations against the givenObservationRegistry
.ServerHttpObservationFilter
(io.micrometer.observation.ObservationRegistry observationRegistry, ServerRequestObservationConvention observationConvention) Create anHttpRequestsObservationWebFilter
that records observations against the givenObservationRegistry
with a custom convention. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>
filter
(ServerWebExchange exchange, WebFilterChain chain) Process the Web request and (optionally) delegate to the nextWebFilter
through the givenWebFilterChain
.findObservationContext
(ServerWebExchange exchange) Get the currentobservation context
from the given request, if available.
-
Field Details
-
CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE
Name of the request attribute holding thecontext
for the current observation.
-
-
Constructor Details
-
ServerHttpObservationFilter
public ServerHttpObservationFilter(io.micrometer.observation.ObservationRegistry observationRegistry) Create anHttpRequestsObservationWebFilter
that records observations against the givenObservationRegistry
. The defaultconvention
will be used.- Parameters:
observationRegistry
- the registry to use for recording observations
-
ServerHttpObservationFilter
public ServerHttpObservationFilter(io.micrometer.observation.ObservationRegistry observationRegistry, ServerRequestObservationConvention observationConvention) Create anHttpRequestsObservationWebFilter
that records observations against the givenObservationRegistry
with a custom convention.- Parameters:
observationRegistry
- the registry to use for recording observationsobservationConvention
- the convention to use for all recorded observations
-
-
Method Details
-
findObservationContext
public static Optional<ServerRequestObservationContext> findObservationContext(ServerWebExchange exchange) Get the currentobservation context
from the given request, if available.- Parameters:
exchange
- the current exchange- Returns:
- the current observation context
-
filter
Description copied from interface:WebFilter
Process the Web request and (optionally) delegate to the nextWebFilter
through the givenWebFilterChain
.
-