@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:
Connection selected with the following attributes:
id
Attempt started with the following attributes:
attempt
Attempt cancelled with the following attributes:
attempt
attempt request count
attempt response count
Attempt failed, scheduling next attempt with the following attributes:
attempt
status
delay
attempt request count
attempt response count
Attempts exhausted with the following attributes:
attempt
status
attempt request count
attempt response count
Attempt failed, error not retryable with the following attributes:
attempt
status
attempt request count
attempt response count
Attempt succeeded with the following attributes:
attempt
attempt request count
attempt response count
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(int 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 |
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 connectionSelected(int 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()
ApiTracerattemptCancelled 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.