Top Description Fields Constructors Methods
org.springframework.http.server.reactive.observation

public Class ServerRequestObservationContext

extends RequestReplyReceiverContext<ServerHttpRequest, ServerHttpResponse>
Class Inheritance
Imports
java.util.Collections, .Map, .Optional, io.micrometer.observation.transport.RequestReplyReceiverContext, org.springframework.http.server.reactive.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable

Context that holds information for metadata collection regarding reactive HTTP requests observations.

This context also extends RequestReplyReceiverContext for propagating tracing information during HTTP request processing.

Author
Brian Clozel
Since
6.0

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private boolean
public static final String
CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE

Name of the request attribute holding the context for the current observation.

private String

Constructor Summary

AccessConstructor and Description
public
ServerRequestObservationContext(ServerHttpRequest
the current request
request
,
ServerHttpResponse
the current response
response
,
Map<String, Object>
the current attributes
attributes
)

Create a new ServerRequestObservationContext instance.

Method Summary

Modifier and TypeMethod and Description
public static Optional<ServerRequestObservationContext>

Returns:

the current observation context
findCurrent
(Map<String, Object>
the current exchange attributes
attributes
)

Get the current observation context from the given attributes, if available.

public Map<String, Object>
getAttributes()

Return an immutable map of the current request attributes.

public String

Returns:

the path pattern, or null if none found
getPathPattern
()

Return the path pattern for the handler that matches the current request.

public boolean

Returns:

if the connection has been aborted
isConnectionAborted
()

Whether the current connection was aborted by the client, resulting in a cancel signal on the reactive chain, or an AbortedException when reading the request.

public void
setConnectionAborted(boolean
if the connection has been aborted
connectionAborted
)

Set whether the current connection was aborted by the client, resulting in a cancel signal on the reactive chain, or an AbortedException when reading the request.

public void
setPathPattern(String
the path pattern, for example "/projects/{name}".
pathPattern
)

Set the path pattern for the handler that matches the current request.

Inherited from io.micrometer.observation.transport.RequestReplyReceiverContext:
getResponsesetResponse

Field Detail

attributesback to summary
private final Map<String, Object> attributes
connectionAbortedback to summary
private boolean connectionAborted
CURRENT_OBSERVATION_CONTEXT_ATTRIBUTEback to summary
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE

Name of the request attribute holding the context for the current observation.

Since
6.1
pathPatternback to summary
private String pathPattern
Annotations
@Nullable

Constructor Detail

ServerRequestObservationContextback to summary
public ServerRequestObservationContext(ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> attributes)

Create a new ServerRequestObservationContext instance.

Parameters
request:ServerHttpRequest

the current request

response:ServerHttpResponse

the current response

attributes:Map<String, Object>

the current attributes

Method Detail

findCurrentback to summary
public static Optional<ServerRequestObservationContext> findCurrent(Map<String, Object> attributes)

Get the current observation context from the given attributes, if available.

Parameters
attributes:Map<String, Object>

the current exchange attributes

Returns:Optional<ServerRequestObservationContext>

the current observation context

Since
6.1
getAttributesback to summary
public Map<String, Object> getAttributes()

Return an immutable map of the current request attributes.

getPathPatternback to summary
public String getPathPattern()

Return the path pattern for the handler that matches the current request. For example, "/projects/{name}".

Path patterns must have a low cardinality for the entire application.

Returns:String

the path pattern, or null if none found

Annotations
@Nullable
isConnectionAbortedback to summary
public boolean isConnectionAborted()

Whether the current connection was aborted by the client, resulting in a cancel signal on the reactive chain, or an AbortedException when reading the request.

Returns:boolean

if the connection has been aborted

setConnectionAbortedback to summary
public void setConnectionAborted(boolean connectionAborted)

Set whether the current connection was aborted by the client, resulting in a cancel signal on the reactive chain, or an AbortedException when reading the request.

Parameters
connectionAborted:boolean

if the connection has been aborted

setPathPatternback to summary
public void setPathPattern(String pathPattern)

Set the path pattern for the handler that matches the current request.

Path patterns must have a low cardinality for the entire application.

Parameters
pathPattern:String

the path pattern, for example "/projects/{name}".