|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2022 the original author or authors. |
|
|
|
* Copyright 2002-2024 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -23,11 +23,12 @@ import io.micrometer.observation.transport.RequestReplySenderContext; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Context that holds information for metadata collection |
|
|
|
* Context that holds information for metadata collection during the |
|
|
|
* during the {@link ClientHttpObservationDocumentation#HTTP_REACTIVE_CLIENT_EXCHANGES HTTP client exchange observations}. |
|
|
|
* {@link ClientHttpObservationDocumentation#HTTP_REACTIVE_CLIENT_EXCHANGES HTTP client exchange observations}. |
|
|
|
|
|
|
|
* |
|
|
|
* <p>The {@link #getCarrier() tracing context carrier} is a {@link ClientRequest.Builder request builder}, |
|
|
|
* <p>The {@link #getCarrier() tracing context carrier} is a {@link ClientRequest.Builder request builder}, |
|
|
|
* since the actual request is immutable. For {@code KeyValue} extraction, the {@link #getRequest() actual request} |
|
|
|
* since the actual request is immutable. For {@code KeyValue} extraction, |
|
|
|
* should be used instead. |
|
|
|
* the {@link #getRequest() actual request} should be used instead. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Brian Clozel |
|
|
|
* @author Brian Clozel |
|
|
|
* @since 6.0 |
|
|
|
* @since 6.0 |
|
|
|
@ -37,10 +38,11 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Name of the request attribute holding the {@link ClientRequestObservationContext context} |
|
|
|
* Name of the request attribute holding the {@link ClientRequestObservationContext context} |
|
|
|
* for the current observation. |
|
|
|
* for the current observation. |
|
|
|
* @since 6.1.1 |
|
|
|
* @since 6.0.15 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE = ClientRequestObservationContext.class.getName(); |
|
|
|
public static final String CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE = ClientRequestObservationContext.class.getName(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
private String uriTemplate; |
|
|
|
private String uriTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@ -60,6 +62,14 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the URI template used for the current client exchange. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setUriTemplate(@Nullable String uriTemplate) { |
|
|
|
|
|
|
|
this.uriTemplate = uriTemplate; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the URI template used for the current client exchange, {@code null} if none was used. |
|
|
|
* Return the URI template used for the current client exchange, {@code null} if none was used. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -69,10 +79,11 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the URI template used for the current client exchange. |
|
|
|
* Set whether the client aborted the current HTTP exchange. |
|
|
|
|
|
|
|
* @param aborted whether the exchange has been aborted |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setUriTemplate(@Nullable String uriTemplate) { |
|
|
|
void setAborted(boolean aborted) { |
|
|
|
this.uriTemplate = uriTemplate; |
|
|
|
this.aborted = aborted; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -84,11 +95,10 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set whether the client aborted the current HTTP exchange. |
|
|
|
* Set the client request. |
|
|
|
* @param aborted whether the exchange has been aborted |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void setAborted(boolean aborted) { |
|
|
|
public void setRequest(ClientRequest request) { |
|
|
|
this.aborted = aborted; |
|
|
|
this.request = request; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -99,21 +109,16 @@ public class ClientRequestObservationContext extends RequestReplySenderContext<C |
|
|
|
return this.request; |
|
|
|
return this.request; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the client request. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setRequest(ClientRequest request) { |
|
|
|
|
|
|
|
this.request = request; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the current {@link ClientRequestObservationContext observation context} |
|
|
|
* Get the current {@link ClientRequestObservationContext observation context} |
|
|
|
* from the given request, if available. |
|
|
|
* from the given request, if available. |
|
|
|
* @param request the current client request |
|
|
|
* @param request the current client request |
|
|
|
* @return the current observation context |
|
|
|
* @return the current observation context |
|
|
|
* @since 6.1.2 |
|
|
|
* @since 6.0.15 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static Optional<ClientRequestObservationContext> findCurrent(ClientRequest request) { |
|
|
|
public static Optional<ClientRequestObservationContext> findCurrent(ClientRequest request) { |
|
|
|
return Optional.ofNullable((ClientRequestObservationContext) request.attributes().get(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE)); |
|
|
|
return Optional.ofNullable((ClientRequestObservationContext) request.attributes().get(CURRENT_OBSERVATION_CONTEXT_ATTRIBUTE)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|