Interface TraceUtil (3.1.0)
Stay organized with collections
Save and categorize content based on your preferences.
public interface TraceUtil
Utility interface to manage OpenTelemetry tracing instrumentation based on the configuration.
Static Fields
ATTRIBUTE_SERVICE_PREFIX
public static final String ATTRIBUTE_SERVICE_PREFIX
| Field Value |
| Type |
Description |
String |
|
ENABLE_TRACING_ENV_VAR
public static final String ENABLE_TRACING_ENV_VAR
| Field Value |
| Type |
Description |
String |
|
LIBRARY_NAME
public static final String LIBRARY_NAME
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_ALLOCATE_IDS
public static final String SPAN_NAME_ALLOCATE_IDS
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_BEGIN_TRANSACTION
public static final String SPAN_NAME_BEGIN_TRANSACTION
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_COMMIT
public static final String SPAN_NAME_COMMIT
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_LOOKUP
public static final String SPAN_NAME_LOOKUP
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_RESERVE_IDS
public static final String SPAN_NAME_RESERVE_IDS
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_ROLLBACK
public static final String SPAN_NAME_ROLLBACK
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_RUN_AGGREGATION_QUERY
public static final String SPAN_NAME_RUN_AGGREGATION_QUERY
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_RUN_QUERY
public static final String SPAN_NAME_RUN_QUERY
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_TRANSACTION_COMMIT
public static final String SPAN_NAME_TRANSACTION_COMMIT
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_TRANSACTION_LOOKUP
public static final String SPAN_NAME_TRANSACTION_LOOKUP
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_TRANSACTION_RUN
public static final String SPAN_NAME_TRANSACTION_RUN
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY
public static final String SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY
| Field Value |
| Type |
Description |
String |
|
SPAN_NAME_TRANSACTION_RUN_QUERY
public static final String SPAN_NAME_TRANSACTION_RUN_QUERY
| Field Value |
| Type |
Description |
String |
|
Static Methods
getInstance(DatastoreOptions datastoreOptions)
public static TraceUtil getInstance(DatastoreOptions datastoreOptions)
Creates and returns an instance of the TraceUtil class.
| Parameter |
| Name |
Description |
datastoreOptions |
DatastoreOptions
The DatastoreOptions object that is requesting an instance of
TraceUtil.
|
| Returns |
| Type |
Description |
TraceUtil |
An instance of the TraceUtil class.
|
Methods
addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder)
public abstract SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder)
Adds common SpanAttributes to the current span, useful when hand-creating a new Span without
using the TraceUtil.Span interface.
| Parameter |
| Name |
Description |
spanBuilder |
io.opentelemetry.api.trace.SpanBuilder
|
| Returns |
| Type |
Description |
io.opentelemetry.api.trace.SpanBuilder |
|
getChannelConfigurator()
public abstract ApiFunction<ManagedChannelBuilder,ManagedChannelBuilder> getChannelConfigurator()
Returns a channel configurator for gRPC, or null if tracing is disabled.
| Returns |
| Type |
Description |
ApiFunction<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder> |
|
getCurrentContext()
public abstract TraceUtil.Context getCurrentContext()
Returns the current Context.
getCurrentSpan()
public abstract TraceUtil.Span getCurrentSpan()
Returns the current span.
getTracer()
public abstract Tracer getTracer()
Returns the current OpenTelemetry Tracer when OpenTelemetry SDK is provided.
| Returns |
| Type |
Description |
io.opentelemetry.api.trace.Tracer |
|
startSpan(String spanName)
public abstract TraceUtil.Span startSpan(String spanName)
Starts a new span with the given name, sets it as the current span, and returns it.
| Parameter |
| Name |
Description |
spanName |
String
|
startSpan(String spanName, TraceUtil.Span parentSpan)
public abstract TraceUtil.Span startSpan(String spanName, TraceUtil.Span parentSpan)
Starts a new span with the given name and the span represented by the parentSpan as its parent,
sets it as the current span and returns it.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-06-18 UTC.
[null,null,["Last updated 2026-06-18 UTC."],[],[]]