Package com.google.api.gax.tracing (2.30.1)

Classes

BaseApiTracer

A base implementation ofApiTracer that does nothing.

For internal use only.

BaseApiTracerFactory

Base factory that will buildApiTracers that do nothing.

For internal use only.

OpencensusTracer

Implementation ofApiTracer that uses OpenCensus.

This implementation wraps an OpenCensusSpan for every tracer and annotates thatSpan with various events throughout the lifecycle of the logical operation.

Each span will be namedClientName.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 seecom.google.api.gax.rpc.ApiStreamObserver for more information.

OpencensusTracerFactory

AApiTracerFactory to build instances ofOpencensusTracer.

This class wraps theTracer provided by Opencensus inTracing.getTracer(). It will be used to create new spans and wrap them inOpencensusTracer defined in gax.

This class is thread safe.

SpanName

A value class to represent the name of the operation in anApiTracer.

TracedBatchingCallable<RequestT,ResponseT>

This callable wraps a batching callable chain in aApiTracer.

For internal use only.

TracedBidiCallable<RequestT,ResponseT>

A wrapper callable that will wrap a callable chain in a trace.

For internal use only.

TracedClientStreamingCallable<RequestT,ResponseT>

A wrapper callable that will wrap a callable chain in a trace.

This can be safely called from multiple threads. However the requestApiStreamObserver can only be used from a single thread.

For internal use only.

TracedOperationCallable<RequestT,ResponseT,MetadataT>

This callable wraps aOperationCallable in aApiTracer.

For internal use only.

TracedOperationInitialCallable<RequestT>

Traces the initial RPC of a long running operation.

It will trace it like a child unary RPC and will also contribute to the parent tracer (created byTracedOperationCallable) the result of the call.

TracedServerStreamingCallable<RequestT,ResponseT>

A wrapper callable that will wrap a callable chain in a trace.

For internal use only.

TracedUnaryCallable<RequestT,ResponseT>

This callable wraps a callable chain in aApiTracer.

For internal use only.

Interfaces

ApiTracer

Implementations of this class trace the logical flow of a google cloud client.

A single instance of a tracer represents a logical operation that can be annotated throughout its lifecycle. Constructing an instance of a subclass will implicitly signal the start of a new operation.

For internal use only. google-cloud-java libraries should extendBaseApiTracer.

ApiTracer.Scope

A context class to be used with#inScope() and a try-with-resources block. Closing aScope removes any context that the underlying implementation might've set in#inScope().

ApiTracerFactory

A factory to create new instances ofApiTracers.

In general a single instance of anApiTracer will correspond to a single logical operation.

For internal use only. google-cloud-java libraries should extendBaseApiTracerFactory.

Enums

ApiTracerFactory.OperationType

The type of operation theApiTracer is tracing.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.