- 2.59.0 (latest)
- 2.58.0
- 2.57.0
- 2.55.0
- 2.54.1
- 2.53.0
- 2.52.0
- 2.51.0
- 2.50.0
- 2.49.0
- 2.48.1
- 2.47.0
- 2.46.1
- 2.45.0
- 2.43.0
- 2.42.0
- 2.41.0
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.0
- 2.35.0
- 2.34.1
- 2.33.0
- 2.32.1
- 2.31.1
- 2.30.1
- 2.24.0
- 2.23.3
- 2.22.0
- 2.21.0
- 2.20.1
- 2.19.6
- 2.18.7
- 2.17.0
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.2
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.7.1
public class OpencensusTracer extends BaseApiTracer
Implementation of 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
- 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 cancelled
with 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 attempt
with 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 exhausted
with 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 retryable
with 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 succeeded
with 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 started
Operation failed to start
with the following attributes:status
- The status code of why the operation failed to start
Polling was cancelled
with the following attributes:attempt
- Zero based sequential poll number.
attempt request count
Scheduling next poll
with 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 exhausted
with the following attributes:attempt
- Zero based sequential poll number
status
- OK if the poll succeeded, but the operation is still running.
Polling failed
with the following attributes:attempt
- Zero based sequential poll number
status
- OK if the poll succeeded, but the operation is still running.
Polling completed
with 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 com.google.api.gax.rpc.ApiStreamObserver for more information.
Methods
attemptCancelled()
public void attemptCancelled()
Add an annotation that the attempt was cancelled by the user.
attemptFailed(Throwable error, Duration delay)
public void attemptFailed(Throwable error, Duration delay)
Adds an annotation that the attempt failed, but another attempt will be made after the delay.
Parameters | |
---|---|
Name | Description |
error | Throwable |
delay | org.threeten.bp.Duration |
attemptFailedRetriesExhausted(Throwable error)
public 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.
Parameter | |
---|---|
Name | Description |
error | Throwable |
attemptPermanentFailure(Throwable error)
public 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.
Parameter | |
---|---|
Name | Description |
error | Throwable |
attemptStarted(int attemptNumber)
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.
Parameter | |
---|---|
Name | Description |
attemptNumber | int |
attemptStarted(Object request, int attemptNumber)
public void attemptStarted(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.
Parameters | |
---|---|
Name | Description |
request | Object |
attemptNumber | int |
attemptSucceeded()
public void attemptSucceeded()
Adds an annotation that the attempt succeeded.
batchRequestSent(long elementCount, long requestSize)
public void batchRequestSent(long elementCount, long requestSize)
Adds an annotation that a batch of writes has been flushed.
Parameters | |
---|---|
Name | Description |
elementCount | long |
requestSize | long |
connectionSelected(String id)
public void connectionSelected(String id)
Annotates the operation with selected connection id from the ChannelPool
.
Parameter | |
---|---|
Name | Description |
id | String |
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.
Returns | |
---|---|
Type | Description |
ApiTracer.Scope |
lroStartFailed(Throwable error)
public void lroStartFailed(Throwable error)
Signals that the initial RPC for the long running operation failed.
Parameter | |
---|---|
Name | Description |
error | Throwable |
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.
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.
operationFailed(Throwable error)
public void operationFailed(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.
Parameter | |
---|---|
Name | Description |
error | Throwable |
operationSucceeded()
public void operationSucceeded()
Signals that the overall operation has finished successfully. The tracer is now considered closed and should no longer be used.
requestSent()
public void requestSent()
Adds an annotation that a streaming request has been sent.
responseReceived()
public void responseReceived()
Adds an annotation that a streaming response has been received.