@BetaApi(value="Surface for tracing is not yet stable") public class OpencensusTracer extends Object implements ApiTracer
ApiTracer that uses OpenCensus.
This implementation wraps an OpenCensus Span for every tracer and annotates that
Span with various events throughout the lifecycle of the logical operation.
Each span will be named ClientName.MethodName and will have the following attributes:
attempt count
status
total response count
total request count
batch count
batch size
The spans will contain the following annotations:
Attempt cancelled with the following attributes:
attempt
attempt request count
attempt response count
connection
Attempt failed, scheduling next attempt with the following attributes:
attempt
status
delay
attempt request count
attempt response count
connection
Attempts exhausted with the following attributes:
attempt
status
attempt request count
attempt response count
connection
Attempt failed, error not retryable with the following attributes:
attempt
status
attempt request count
attempt response count
connection
Attempt succeeded with the following attributes:
attempt
attempt request count
attempt response count
connection
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 started
Operation failed to start with the following attributes:
status
Polling was cancelled with the following attributes:
attempt
attempt request count
Scheduling next poll with the following attributes:
attempt
status
delay
Polling attempts exhausted with the following attributes:
attempt
status
Polling failed with the following attributes:
attempt
status
Polling completed with the following attributes:
attempt
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 ApiStreamObserver for more information.
ApiTracer.Scope| Modifier and Type | Method and Description |
|---|---|
void |
attemptCancelled()
Add an annotation that the attempt was cancelled by the user.
|
void |
attemptFailed(Throwable error,
org.threeten.bp.Duration delay)
Adds an annotation that the attempt failed, but another attempt will be made after the delay.
|
void |
attemptFailedRetriesExhausted(Throwable error)
Adds an annotation that the attempt failed and that no further attempts will be made because
retry limits have been reached.
|
void |
attemptPermanentFailure(Throwable error)
Adds an annotation that the attempt failed and that no further attempts will be made because
the last error was not retryable.
|
void |
attemptStarted(int attemptNumber)
Adds an annotation that an attempt is about to start.
|
void |
attemptSucceeded()
Adds an annotation that the attempt succeeded.
|
void |
batchRequestSent(long elementCount,
long requestSize)
Adds an annotation that a batch of writes has been flushed.
|
void |
connectionSelected(String id)
Annotates the operation with selected connection id from the
ChannelPool. |
ApiTracer.Scope |
inScope()
Asks the underlying implementation to install itself as a thread local.
|
void |
lroStartFailed(Throwable error)
Signals that the initial RPC for the long running operation failed.
|
void |
lroStartSucceeded()
Signals that the initial RPC successfully started the long running operation.
|
void |
operationCancelled()
Signals that the operation was cancelled by the user.
|
void |
operationFailed(Throwable error)
Signals that the overall operation has failed and no further attempts will be made.
|
void |
operationSucceeded()
Signals that the overall operation has finished successfully.
|
void |
requestSent()
Adds an annotation that a streaming request has been sent.
|
void |
responseReceived()
Adds an annotation that a streaming response has been received.
|
public ApiTracer.Scope inScope()
public void operationSucceeded()
operationSucceeded in interface ApiTracerpublic void operationCancelled()
operationCancelled in interface ApiTracerpublic void operationFailed(Throwable error)
operationFailed in interface ApiTracererror - the final error that caused the operation to fail.public void lroStartFailed(Throwable error)
lroStartFailed in interface ApiTracererror - the error that caused the long running operation fail.public void lroStartSucceeded()
lroStartSucceeded in interface ApiTracerpublic void connectionSelected(String id)
ChannelPool.connectionSelected in interface ApiTracerid - the local connection identifier of the selected connection.public void attemptStarted(int attemptNumber)
attemptStarted in interface ApiTracerattemptNumber - the zero based sequential attempt number.public void attemptSucceeded()
attemptSucceeded in interface ApiTracerpublic void attemptCancelled()
attemptCancelled in interface ApiTracerpublic void attemptFailed(Throwable error, org.threeten.bp.Duration delay)
attemptFailed in interface ApiTracererror - the transient error that caused the attempt to fail.delay - the amount of time to wait before the next attempt will start.public void attemptFailedRetriesExhausted(Throwable error)
attemptFailedRetriesExhausted in interface ApiTracererror - the last error received before retries were exhausted.public void attemptPermanentFailure(Throwable error)
attemptPermanentFailure in interface ApiTracererror - the error that caused the final attempt to fail.public void responseReceived()
responseReceived in interface ApiTracerpublic void requestSent()
requestSent in interface ApiTracerpublic void batchRequestSent(long elementCount,
long requestSize)
batchRequestSent in interface ApiTracerelementCount - the number of elements in the batch.requestSize - the size of the batch in bytes.