Package io.grpc
Class ClientStreamTracer
- java.lang.Object
-
- io.grpc.StreamTracer
-
- io.grpc.ClientStreamTracer
-
- Direct Known Subclasses:
ForwardingClientStreamTracer
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/2861") public abstract class ClientStreamTracer extends StreamTracer
StreamTracerfor the client-side.This class is thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classClientStreamTracer.FactoryFactory class forClientStreamTracer.static classClientStreamTracer.StreamInfoInformation about a stream.
-
Field Summary
Fields Modifier and Type Field Description static CallOptions.Key<Long>NAME_RESOLUTION_DELAYEDIndicates how long the call was delayed, in nanoseconds, due to waiting for name resolution result.
-
Constructor Summary
Constructors Constructor Description ClientStreamTracer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOptionalLabel(String key, String value)Information providing context to the call became available.voidcreatePendingStream()Name resolution is completed and the connection starts getting established.voidinboundHeaders()Headers has been received from the server.voidinboundHeaders(Metadata headers)Headers has been received from the server.voidinboundTrailers(Metadata trailers)Trailing metadata has been received from the server.voidoutboundHeaders()Headers has been sent to the socket.voidrecordDelayEnd(String delayType)Called when an attempt-level delay ends upon successful pick or stream creation, or when the attempt is cancelled or reaches its deadline while still waiting.voidrecordDelayReasonChanged(String delayType, String delayReason)Called when an attempt-level delay reason changes while the delay type remains constant (for example, when a load balancing policy updates its connection status detail).voidrecordDelayStart(String delayType, String delayReason)Called when an attempt-level delay (such as waiting for a load balancing pick or connection establishment) starts, or when thedelayTypeof the ongoing delay changes, in which caserecordDelayEnd(java.lang.String)is called for the previous delay first.voidstreamCreated(Attributes transportAttrs, Metadata headers)The stream is being created on a ready transport.-
Methods inherited from class io.grpc.StreamTracer
inboundMessage, inboundMessageRead, inboundUncompressedSize, inboundWireSize, outboundMessage, outboundMessageSent, outboundUncompressedSize, outboundWireSize, streamClosed
-
-
-
-
Field Detail
-
NAME_RESOLUTION_DELAYED
public static final CallOptions.Key<Long> NAME_RESOLUTION_DELAYED
Indicates how long the call was delayed, in nanoseconds, due to waiting for name resolution result. If the call option is not set, the call did not experience name resolution delay.
-
-
Method Detail
-
streamCreated
public void streamCreated(@TransportAttr Attributes transportAttrs, Metadata headers)
The stream is being created on a ready transport.- Parameters:
headers- the mutable initial metadata. Modifications to it will be sent to the socket but not be seen by client interceptors and the application.- Since:
- 1.40.0
-
createPendingStream
public void createPendingStream()
Name resolution is completed and the connection starts getting established. This method is only invoked on the streams that encounter such delay. gRPC buffers the client call if the remote address and configurations, e.g. timeouts and retry policy, are not ready. Asynchronously gRPC internally does the name resolution to get this information. The streams that are processed immediately on ready transports by the time the RPC comes do not go through the pending process, thus this callback will not be invoked.
-
recordDelayStart
public void recordDelayStart(String delayType, String delayReason)
Called when an attempt-level delay (such as waiting for a load balancing pick or connection establishment) starts, or when thedelayTypeof the ongoing delay changes, in which caserecordDelayEnd(java.lang.String)is called for the previous delay first.Implementations should start a timer and open a child tracing span (named strictly
"Delay") carrying the canonicalgrpc.delay_typeattribute.- Parameters:
delayType- canonical low-cardinality label categorizing the delay (e.g., "connecting")delayReason- high-cardinality diagnostic string describing granular runtime conditions- Since:
- 1.86.0
-
recordDelayReasonChanged
public void recordDelayReasonChanged(String delayType, String delayReason)
Called when an attempt-level delay reason changes while the delay type remains constant (for example, when a load balancing policy updates its connection status detail).Implementations should record a structured event (such as
"Delay triggered") on the active delay span without recreating the span or resetting cumulative timers.- Parameters:
delayType- canonical low-cardinality label of the ongoing delaydelayReason- updated high-cardinality diagnostic string describing new conditions- Since:
- 1.86.0
-
recordDelayEnd
public void recordDelayEnd(String delayType)
Called when an attempt-level delay ends upon successful pick or stream creation, or when the attempt is cancelled or reaches its deadline while still waiting.Implementations should close the active child tracing span and record the elapsed duration to the
grpc.client.attempt.delay.durationhistogram labeled withdelayType.- Parameters:
delayType- canonical low-cardinality label of the delay being ended- Since:
- 1.86.0
-
outboundHeaders
public void outboundHeaders()
Headers has been sent to the socket.
-
inboundHeaders
public void inboundHeaders()
Headers has been received from the server.
-
inboundHeaders
public void inboundHeaders(Metadata headers)
Headers has been received from the server. This method does not pass ownership toheaders, so implementations must not access the metadata after returning. Modifications to the metadata within this method will be seen by interceptors and the application.- Parameters:
headers- the received header metadata
-
inboundTrailers
public void inboundTrailers(Metadata trailers)
Trailing metadata has been received from the server. This method does not pass ownership totrailers, so implementations must not access the metadata after returning. Modifications to the metadata within this method will be seen by interceptors and the application.- Parameters:
trailers- the received trailing metadata- Since:
- 1.17.0
-
-