Class ClientRequestObservationContext

java.lang.Object
io.micrometer.observation.Observation.Context
io.micrometer.observation.transport.SenderContext<C>
io.micrometer.observation.transport.RequestReplySenderContext<ClientRequest.Builder,ClientResponse>
org.springframework.web.reactive.function.client.ClientRequestObservationContext
All Implemented Interfaces:
io.micrometer.observation.Observation.ContextView, io.micrometer.observation.transport.ResponseContext<ClientResponse>

public class ClientRequestObservationContext extends io.micrometer.observation.transport.RequestReplySenderContext<ClientRequest.Builder,ClientResponse>
Context that holds information for metadata collection during the HTTP client exchange observations.

The tracing context carrier is a request builder, since the actual request is immutable. For KeyValue extraction, the actual request should be used instead.

Since:
6.0
Author:
Brian Clozel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name of the request attribute holding the context for the current observation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new Observation context for HTTP client observations.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the current observation context from the given request, if available.
    Return the immutable client request.
    Return the URI template used for the current client exchange, null if none was used.
    boolean
    Whether the client aborted the current HTTP exchange before receiving any response.
    void
    Set the client request.
    void
    setUriTemplate(String uriTemplate)
    Set the URI template used for the current client exchange.

    Methods inherited from class io.micrometer.observation.transport.RequestReplySenderContext

    getResponse, setResponse

    Methods inherited from class io.micrometer.observation.transport.SenderContext

    getCarrier, getKind, getRemoteServiceAddress, getRemoteServiceName, getSetter, setCarrier, setRemoteServiceAddress, setRemoteServiceName

    Methods inherited from class io.micrometer.observation.Observation.Context

    addHighCardinalityKeyValue, addHighCardinalityKeyValues, addLowCardinalityKeyValue, addLowCardinalityKeyValues, clear, computeIfAbsent, containsKey, get, getAllKeyValues, getContextualName, getError, getHighCardinalityKeyValue, getHighCardinalityKeyValues, getLowCardinalityKeyValue, getLowCardinalityKeyValues, getName, getOrDefault, getParentObservation, getRequired, put, remove, removeHighCardinalityKeyValue, removeHighCardinalityKeyValues, removeLowCardinalityKeyValue, removeLowCardinalityKeyValues, setContextualName, setError, setName, setParentObservation, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.micrometer.observation.Observation.ContextView

    getOrDefault
  • Field Details

    • CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE

      public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE
      Name of the request attribute holding the context for the current observation.
      Since:
      6.1.2
  • Constructor Details

    • ClientRequestObservationContext

      @Deprecated(since="6.1.2", forRemoval=true) public ClientRequestObservationContext()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Create a new Observation context for HTTP client observations.
    • ClientRequestObservationContext

      public ClientRequestObservationContext(ClientRequest.Builder request)
      Create a new Observation context for HTTP client observations.
      Parameters:
      request - client request builder
      Since:
      6.1.2
  • Method Details

    • getUriTemplate

      @Nullable public String getUriTemplate()
      Return the URI template used for the current client exchange, null if none was used.
    • setUriTemplate

      public void setUriTemplate(@Nullable String uriTemplate)
      Set the URI template used for the current client exchange.
    • isAborted

      public boolean isAborted()
      Whether the client aborted the current HTTP exchange before receiving any response.
      Returns:
      whether the exchange has been aborted
    • getRequest

      @Nullable public ClientRequest getRequest()
      Return the immutable client request.
    • setRequest

      public void setRequest(ClientRequest request)
      Set the client request.
    • findCurrent

      public static Optional<ClientRequestObservationContext> findCurrent(ClientRequest request)
      Get the current observation context from the given request, if available.
      Parameters:
      request - the current client request
      Returns:
      the current observation context
      Since:
      6.1.2