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 extend BaseApiTracer.
Methods
attemptCancelled()
publicdefaultvoidattemptCancelled()
Add an annotation that the attempt was cancelled by the user.
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.
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.
the local connection identifier of the selected connection.
inScope()
publicdefaultApiTracer.ScopeinScope()
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eApiTracer\u003c/code\u003e interface traces the logical flow of a Google Cloud client's operations.\u003c/p\u003e\n"],["\u003cp\u003eIt allows for the annotation of various stages of an operation's lifecycle, including start, success, failure, and cancellation.\u003c/p\u003e\n"],["\u003cp\u003eThe interface provides methods for tracing individual attempts, such as \u003ccode\u003eattemptStarted\u003c/code\u003e, \u003ccode\u003eattemptFailed\u003c/code\u003e, and \u003ccode\u003eattemptSucceeded\u003c/code\u003e, including methods to indicate when retries are exhausted or the failure is permanent.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003elroStartSucceeded\u003c/code\u003e and \u003ccode\u003elroStartFailed\u003c/code\u003e are used for tracing long-running operations.\u003c/p\u003e\n"],["\u003cp\u003eThe webpage references documentation for the latest version, 2.63.1, along with numerous older versions, all relating to \u003ccode\u003ecom.google.api.gax.tracing.ApiTracer\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Interface ApiTracer (2.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.69.0 (latest)](/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer)\n- [2.68.2](/java/docs/reference/gax/2.68.2/com.google.api.gax.tracing.ApiTracer)\n- [2.67.0](/java/docs/reference/gax/2.67.0/com.google.api.gax.tracing.ApiTracer)\n- [2.66.0](/java/docs/reference/gax/2.66.0/com.google.api.gax.tracing.ApiTracer)\n- [2.65.0](/java/docs/reference/gax/2.65.0/com.google.api.gax.tracing.ApiTracer)\n- [2.63.1](/java/docs/reference/gax/2.63.1/com.google.api.gax.tracing.ApiTracer)\n- [2.62.0](/java/docs/reference/gax/2.62.0/com.google.api.gax.tracing.ApiTracer)\n- [2.61.0](/java/docs/reference/gax/2.61.0/com.google.api.gax.tracing.ApiTracer)\n- [2.60.0](/java/docs/reference/gax/2.60.0/com.google.api.gax.tracing.ApiTracer)\n- [2.59.1](/java/docs/reference/gax/2.59.1/com.google.api.gax.tracing.ApiTracer)\n- [2.58.0](/java/docs/reference/gax/2.58.0/com.google.api.gax.tracing.ApiTracer)\n- [2.57.0](/java/docs/reference/gax/2.57.0/com.google.api.gax.tracing.ApiTracer)\n- [2.55.0](/java/docs/reference/gax/2.55.0/com.google.api.gax.tracing.ApiTracer)\n- [2.54.1](/java/docs/reference/gax/2.54.1/com.google.api.gax.tracing.ApiTracer)\n- [2.53.0](/java/docs/reference/gax/2.53.0/com.google.api.gax.tracing.ApiTracer)\n- [2.52.0](/java/docs/reference/gax/2.52.0/com.google.api.gax.tracing.ApiTracer)\n- [2.51.0](/java/docs/reference/gax/2.51.0/com.google.api.gax.tracing.ApiTracer)\n- [2.50.0](/java/docs/reference/gax/2.50.0/com.google.api.gax.tracing.ApiTracer)\n- [2.49.0](/java/docs/reference/gax/2.49.0/com.google.api.gax.tracing.ApiTracer)\n- [2.48.1](/java/docs/reference/gax/2.48.1/com.google.api.gax.tracing.ApiTracer)\n- [2.47.0](/java/docs/reference/gax/2.47.0/com.google.api.gax.tracing.ApiTracer)\n- [2.46.1](/java/docs/reference/gax/2.46.1/com.google.api.gax.tracing.ApiTracer)\n- [2.45.0](/java/docs/reference/gax/2.45.0/com.google.api.gax.tracing.ApiTracer)\n- [2.43.0](/java/docs/reference/gax/2.43.0/com.google.api.gax.tracing.ApiTracer)\n- [2.42.0](/java/docs/reference/gax/2.42.0/com.google.api.gax.tracing.ApiTracer)\n- [2.41.0](/java/docs/reference/gax/2.41.0/com.google.api.gax.tracing.ApiTracer)\n- [2.39.0](/java/docs/reference/gax/2.39.0/com.google.api.gax.tracing.ApiTracer)\n- [2.38.0](/java/docs/reference/gax/2.38.0/com.google.api.gax.tracing.ApiTracer)\n- [2.37.0](/java/docs/reference/gax/2.37.0/com.google.api.gax.tracing.ApiTracer)\n- [2.36.0](/java/docs/reference/gax/2.36.0/com.google.api.gax.tracing.ApiTracer)\n- [2.35.0](/java/docs/reference/gax/2.35.0/com.google.api.gax.tracing.ApiTracer)\n- [2.34.1](/java/docs/reference/gax/2.34.1/com.google.api.gax.tracing.ApiTracer)\n- [2.33.0](/java/docs/reference/gax/2.33.0/com.google.api.gax.tracing.ApiTracer)\n- [2.32.1](/java/docs/reference/gax/2.32.1/com.google.api.gax.tracing.ApiTracer)\n- [2.31.1](/java/docs/reference/gax/2.31.1/com.google.api.gax.tracing.ApiTracer)\n- [2.30.1](/java/docs/reference/gax/2.30.1/com.google.api.gax.tracing.ApiTracer)\n- [2.24.0](/java/docs/reference/gax/2.24.0/com.google.api.gax.tracing.ApiTracer)\n- [2.23.3](/java/docs/reference/gax/2.23.3/com.google.api.gax.tracing.ApiTracer)\n- [2.22.0](/java/docs/reference/gax/2.22.0/com.google.api.gax.tracing.ApiTracer)\n- [2.21.0](/java/docs/reference/gax/2.21.0/com.google.api.gax.tracing.ApiTracer)\n- [2.20.1](/java/docs/reference/gax/2.20.1/com.google.api.gax.tracing.ApiTracer)\n- [2.19.6](/java/docs/reference/gax/2.19.6/com.google.api.gax.tracing.ApiTracer)\n- [2.18.7](/java/docs/reference/gax/2.18.7/com.google.api.gax.tracing.ApiTracer)\n- [2.17.0](/java/docs/reference/gax/2.17.0/com.google.api.gax.tracing.ApiTracer)\n- [2.16.0](/java/docs/reference/gax/2.16.0/com.google.api.gax.tracing.ApiTracer)\n- [2.15.0](/java/docs/reference/gax/2.15.0/com.google.api.gax.tracing.ApiTracer)\n- [2.14.0](/java/docs/reference/gax/2.14.0/com.google.api.gax.tracing.ApiTracer)\n- [2.13.0](/java/docs/reference/gax/2.13.0/com.google.api.gax.tracing.ApiTracer)\n- [2.12.2](/java/docs/reference/gax/2.12.2/com.google.api.gax.tracing.ApiTracer)\n- [2.11.0](/java/docs/reference/gax/2.11.0/com.google.api.gax.tracing.ApiTracer)\n- [2.10.0](/java/docs/reference/gax/2.10.0/com.google.api.gax.tracing.ApiTracer)\n- [2.9.0](/java/docs/reference/gax/2.9.0/com.google.api.gax.tracing.ApiTracer)\n- [2.8.1](/java/docs/reference/gax/2.8.1/com.google.api.gax.tracing.ApiTracer)\n- [2.7.1](/java/docs/reference/gax/2.7.1/com.google.api.gax.tracing.ApiTracer) \n\n public interface ApiTracer\n\nImplementations of this class trace the logical flow of a google cloud client.\n\nA single instance of a tracer represents a logical operation that can be annotated throughout\nits lifecycle. Constructing an instance of a subclass will implicitly signal the start of a new\noperation.\n\nFor internal use only. google-cloud-java libraries should extend [BaseApiTracer](/java/docs/reference/gax/latest/com.google.api.gax.tracing.BaseApiTracer).\n\nMethods\n-------\n\n### attemptCancelled()\n\n public default void attemptCancelled()\n\nAdd an annotation that the attempt was cancelled by the user.\n\n### attemptFailed(Throwable error, Duration delay)\n\n public default void attemptFailed(Throwable error, Duration delay)\n\n| **Obsolete**\n|\n| *Use attemptFailedDuration(Throwable, java.time.Duration) instead*\n|\n| This feature is stable for usage in this major version, but may be deprecated in a future release.\n\nThis method is obsolete. Use [#attemptFailedDuration(Throwable, java.time.Duration)](/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer#com_google_api_gax_tracing_ApiTracer_attemptFailedDuration_)\ninstead.\n\n### attemptFailedDuration(Throwable error, Duration delay)\n\n public default void attemptFailedDuration(Throwable error, Duration delay)\n\nAdds an annotation that the attempt failed, but another attempt will be made after the delay.\n\n### attemptFailedRetriesExhausted(Throwable error)\n\n public default void attemptFailedRetriesExhausted(Throwable error)\n\nAdds an annotation that the attempt failed and that no further attempts will be made because\nretry limits have been reached.\n\n### attemptPermanentFailure(Throwable error)\n\n public default void attemptPermanentFailure(Throwable error)\n\nAdds an annotation that the attempt failed and that no further attempts will be made because\nthe last error was not retryable.\n\n### attemptStarted(int attemptNumber) (deprecated)\n\n public default void attemptStarted(int attemptNumber)\n\n**Deprecated.** *Please use [#attemptStarted(Object, int)](/java/docs/reference/gax/latest/com.google.api.gax.tracing.ApiTracer#com_google_api_gax_tracing_ApiTracer_attemptStarted_java_lang_Object_int_) instead.*\n\nAdds an annotation that an attempt is about to start. In general this should occur at the very\nstart of the operation. The attemptNumber is zero based. So the initial attempt will be 0.\n\n### attemptStarted(Object request, int attemptNumber)\n\n public default void attemptStarted(Object request, int attemptNumber)\n\nAdds an annotation that an attempt is about to start with additional information from the\nrequest. In general this should occur at the very start of the operation. The attemptNumber is\nzero based. So the initial attempt will be 0.\n\n### attemptSucceeded()\n\n public default void attemptSucceeded()\n\nAdds an annotation that the attempt succeeded.\n\n### batchRequestSent(long elementCount, long requestSize)\n\n public default void batchRequestSent(long elementCount, long requestSize)\n\nAdds an annotation that a batch of writes has been flushed.\n\n### connectionSelected(String id)\n\n public default void connectionSelected(String id)\n\nAnnotates the operation with selected connection id from the `ChannelPool`.\n\n### inScope()\n\n public default ApiTracer.Scope inScope()\n\nAsks the underlying implementation to install itself as a thread local. This allows for interop\nbetween clients using gax and external resources to share the same implementation of the\ntracing. For example OpenCensus will install a thread local that can read by the GRPC.\n\n### lroStartFailed(Throwable error)\n\n public default void lroStartFailed(Throwable error)\n\nSignals that the initial RPC for the long running operation failed.\n\n### lroStartSucceeded()\n\n public default void lroStartSucceeded()\n\nSignals that the initial RPC successfully started the long running operation. The long running\noperation will now be polled for completion.\n\n### operationCancelled()\n\n public default void operationCancelled()\n\nSignals that the operation was cancelled by the user. The tracer is now considered closed and\nshould no longer be used.\n\n### operationFailed(Throwable error)\n\n public default void operationFailed(Throwable error)\n\nSignals that the overall operation has failed and no further attempts will be made. The tracer\nis now considered closed and should no longer be used.\n\n### operationSucceeded()\n\n public default void operationSucceeded()\n\nSignals that the overall operation has finished successfully. The tracer is now considered\nclosed and should no longer be used.\n\n### requestSent()\n\n public default void requestSent()\n\nAdds an annotation that a streaming request has been sent.\n\n### responseReceived()\n\n public default void responseReceived()\n\nAdds an annotation that a streaming response has been received."]]