Class OpencensusTracer
- java.lang.Object
-
- com.google.api.gax.tracing.BaseApiTracer
-
- com.google.api.gax.tracing.OpencensusTracer
-
- All Implemented Interfaces:
ApiTracer
@BetaApi("Surface for tracing is not yet stable") public class OpencensusTracer extends BaseApiTracerImplementation ofApiTracerthat uses OpenCensus.This implementation wraps an OpenCensus
Spanfor every tracer and annotates thatSpanwith various events throughout the lifecycle of the logical operation.Each span will be named
ClientName.MethodNameand will have the following attributes:attempt count- The Number of attempts sent before the logical operation completed
status- The status code of the last attempt
total response count- The number of messages received across all of the attempts. This will only be set for server streaming and bidi RPCs.
total request count- The number of messages sent across all of the attempts. This will only be set for client streaming and bidi RPCs.
batch count- For batch requests, the number of elements in the request.
batch size- For batch requests, the byte size of the request.
The spans will contain the following annotations:
Attempt cancelledwith the following attributes:attempt- Zero based sequential attempt number
attempt request count- The number of requests sent in this attempt. This will only be set for client streaming and bidi RPCs.
attempt response count- The number of responses received in this attempt. This will only be set for server streaming and bidi RPCs.
connection- The UUID of the connection which the attempt was sent.
Attempt failed, scheduling next attemptwith the following attributes:attempt- Zero based sequential attempt number
status- The status code of the failed attempt
delay- The number of milliseconds to wait before trying again
attempt request count- The number of requests sent in this attempt. This will only be set for client streaming and bidi RPCs.
attempt response count- The number of responses received in this attempt. This will only be set for server streaming and bidi RPCs.
connection- The UUID of the connection which the attempt was sent.
Attempts exhaustedwith the following attributes:attempt- Zero based sequential attempt number
status- The status code of the failed attempt
attempt request count- The number of requests sent in this attempt. This will only be set for client streaming and bidi RPCs.
attempt response count- The number of responses received in this attempt. This will only be set for server streaming and bidi RPCs.
connection- The UUID of the connection which the attempt was sent.
Attempt failed, error not retryablewith the following attributes:attempt- Zero based sequential attempt number
status- The status code of the failed attempt
attempt request count- The number of requests sent in this attempt. This will only be set for client streaming and bidi RPCs.
attempt response count- The number of responses received in this attempt. This will only be set for server streaming and bidi RPCs.
connection- The UUID of the connection which the attempt was sent.
Attempt succeededwith the following attributes:attempt- Zero based sequential attempt number
attempt request count- The number of requests sent in this attempt. This will only be set for client streaming and bidi RPCs.
attempt response count- The number of responses received in this attempt. This will only be set for server streaming and bidi RPCs.
connection- The UUID of the connection which the attempt was sent.
Long running operations, which are composed of an initial RPC to start the operation and a number of polling RPCs will be represented as a tree of spans. The top level span will be named after the initial RPC name suffixed with "Operation" and will have the following annotations:
Operation startedOperation failed to startwith the following attributes:status- The status code of why the operation failed to start
Polling was cancelledwith the following attributes:attempt- Zero based sequential poll number.
attempt request count
Scheduling next pollwith the following attributes:attempt- Zero based sequential poll number
status- OK if the poll succeeded, but the operation is still running.
delay- The number of milliseconds to wait before polling again
Polling attempts exhaustedwith the following attributes:attempt- Zero based sequential poll number
status- OK if the poll succeeded, but the operation is still running.
Polling failedwith the following attributes:attempt- Zero based sequential poll number
status- OK if the poll succeeded, but the operation is still running.
Polling completedwith the following attributes:attempt- Zero based sequential poll number
The toplevel long running operation span will also contain child spans to describe the retry attempts for the initial RPC and each poll as described in the general span section above.
This class is thread compatible. It expects callers to follow grpc's threading model: there is only one thread that invokes the operation* and attempt* methods. Please see
ApiStreamObserverfor more information.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.api.gax.tracing.ApiTracer
ApiTracer.Scope
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattemptCancelled()Add an annotation that the attempt was cancelled by the user.voidattemptFailed(java.lang.Throwable error, org.threeten.bp.Duration delay)Adds an annotation that the attempt failed, but another attempt will be made after the delay.voidattemptFailedRetriesExhausted(java.lang.Throwable error)Adds an annotation that the attempt failed and that no further attempts will be made because retry limits have been reached.voidattemptPermanentFailure(java.lang.Throwable error)Adds an annotation that the attempt failed and that no further attempts will be made because the last error was not retryable.voidattemptStarted(int attemptNumber)Adds an annotation that an attempt is about to start.voidattemptStarted(java.lang.Object request, int attemptNumber)Adds an annotation that an attempt is about to start with additional information from the request.voidattemptSucceeded()Adds an annotation that the attempt succeeded.voidbatchRequestSent(long elementCount, long requestSize)Adds an annotation that a batch of writes has been flushed.voidconnectionSelected(java.lang.String id)Annotates the operation with selected connection id from theChannelPool.ApiTracer.ScopeinScope()Asks the underlying implementation to install itself as a thread local.voidlroStartFailed(java.lang.Throwable error)Signals that the initial RPC for the long running operation failed.voidlroStartSucceeded()Signals that the initial RPC successfully started the long running operation.voidoperationCancelled()Signals that the operation was cancelled by the user.voidoperationFailed(java.lang.Throwable error)Signals that the overall operation has failed and no further attempts will be made.voidoperationSucceeded()Signals that the overall operation has finished successfully.voidrequestSent()Adds an annotation that a streaming request has been sent.voidresponseReceived()Adds an annotation that a streaming response has been received.-
Methods inherited from class com.google.api.gax.tracing.BaseApiTracer
getInstance
-
-
-
-
Method Detail
-
inScope
public ApiTracer.Scope inScope()
Asks the underlying implementation to install itself as a thread local. This allows for interop between clients using gax and external resources to share the same implementation of the tracing. For example OpenCensus will install a thread local that can read by the GRPC.- Specified by:
inScopein interfaceApiTracer- Overrides:
inScopein classBaseApiTracer
-
operationSucceeded
public void operationSucceeded()
Signals that the overall operation has finished successfully. The tracer is now considered closed and should no longer be used.- Specified by:
operationSucceededin interfaceApiTracer- Overrides:
operationSucceededin classBaseApiTracer
-
operationCancelled
public void operationCancelled()
Signals that the operation was cancelled by the user. The tracer is now considered closed and should no longer be used.- Specified by:
operationCancelledin interfaceApiTracer- Overrides:
operationCancelledin classBaseApiTracer
-
operationFailed
public void operationFailed(java.lang.Throwable error)
Signals that the overall operation has failed and no further attempts will be made. The tracer is now considered closed and should no longer be used.- Specified by:
operationFailedin interfaceApiTracer- Overrides:
operationFailedin classBaseApiTracer- Parameters:
error- the final error that caused the operation to fail.
-
lroStartFailed
public void lroStartFailed(java.lang.Throwable error)
Signals that the initial RPC for the long running operation failed.- Specified by:
lroStartFailedin interfaceApiTracer- Overrides:
lroStartFailedin classBaseApiTracer- Parameters:
error- the error that caused the long running operation fail.
-
lroStartSucceeded
public void lroStartSucceeded()
Signals that the initial RPC successfully started the long running operation. The long running operation will now be polled for completion.- Specified by:
lroStartSucceededin interfaceApiTracer- Overrides:
lroStartSucceededin classBaseApiTracer
-
connectionSelected
public void connectionSelected(java.lang.String id)
Annotates the operation with selected connection id from theChannelPool.- Specified by:
connectionSelectedin interfaceApiTracer- Overrides:
connectionSelectedin classBaseApiTracer- Parameters:
id- the local connection identifier of the selected connection.
-
attemptStarted
public void attemptStarted(int attemptNumber)
Adds an annotation that an attempt is about to start. In general this should occur at the very start of the operation. The attemptNumber is zero based. So the initial attempt will be 0.- Specified by:
attemptStartedin interfaceApiTracer- Overrides:
attemptStartedin classBaseApiTracer- Parameters:
attemptNumber- the zero based sequential attempt number.
-
attemptStarted
public void attemptStarted(java.lang.Object request, int attemptNumber)Adds an annotation that an attempt is about to start with additional information from the request. In general this should occur at the very start of the operation. The attemptNumber is zero based. So the initial attempt will be 0.- Specified by:
attemptStartedin interfaceApiTracer- Overrides:
attemptStartedin classBaseApiTracer- Parameters:
request- request of this attempt.attemptNumber- the zero based sequential attempt number.
-
attemptSucceeded
public void attemptSucceeded()
Adds an annotation that the attempt succeeded.- Specified by:
attemptSucceededin interfaceApiTracer- Overrides:
attemptSucceededin classBaseApiTracer
-
attemptCancelled
public void attemptCancelled()
Add an annotation that the attempt was cancelled by the user.- Specified by:
attemptCancelledin interfaceApiTracer- Overrides:
attemptCancelledin classBaseApiTracer
-
attemptFailed
public void attemptFailed(java.lang.Throwable error, org.threeten.bp.Duration delay)Adds an annotation that the attempt failed, but another attempt will be made after the delay.- Specified by:
attemptFailedin interfaceApiTracer- Overrides:
attemptFailedin classBaseApiTracer- Parameters:
error- the transient error that caused the attempt to fail.delay- the amount of time to wait before the next attempt will start.
-
attemptFailedRetriesExhausted
public void attemptFailedRetriesExhausted(java.lang.Throwable error)
Adds an annotation that the attempt failed and that no further attempts will be made because retry limits have been reached.- Specified by:
attemptFailedRetriesExhaustedin interfaceApiTracer- Overrides:
attemptFailedRetriesExhaustedin classBaseApiTracer- Parameters:
error- the last error received before retries were exhausted.
-
attemptPermanentFailure
public void attemptPermanentFailure(java.lang.Throwable error)
Adds an annotation that the attempt failed and that no further attempts will be made because the last error was not retryable.- Specified by:
attemptPermanentFailurein interfaceApiTracer- Overrides:
attemptPermanentFailurein classBaseApiTracer- Parameters:
error- the error that caused the final attempt to fail.
-
responseReceived
public void responseReceived()
Adds an annotation that a streaming response has been received.- Specified by:
responseReceivedin interfaceApiTracer- Overrides:
responseReceivedin classBaseApiTracer
-
requestSent
public void requestSent()
Adds an annotation that a streaming request has been sent.- Specified by:
requestSentin interfaceApiTracer- Overrides:
requestSentin classBaseApiTracer
-
batchRequestSent
public void batchRequestSent(long elementCount, long requestSize)Adds an annotation that a batch of writes has been flushed.- Specified by:
batchRequestSentin interfaceApiTracer- Overrides:
batchRequestSentin classBaseApiTracer- Parameters:
elementCount- the number of elements in the batch.requestSize- the size of the batch in bytes.
-
-