Interface TraceUtil (2.33.0)

publicinterface TraceUtil

Utility interface to manage OpenTelemetry tracing instrumentation based on the configuration.

Static Fields

ATTRIBUTES_KEY_DEFERRED

publicstaticfinalStringATTRIBUTES_KEY_DEFERRED
Field Value
Type Description
String

ATTRIBUTES_KEY_DOCUMENT_COUNT

publicstaticfinalStringATTRIBUTES_KEY_DOCUMENT_COUNT
Field Value
Type Description
String

ATTRIBUTES_KEY_MISSING

publicstaticfinalStringATTRIBUTES_KEY_MISSING
Field Value
Type Description
String

ATTRIBUTES_KEY_MORE_RESULTS

publicstaticfinalStringATTRIBUTES_KEY_MORE_RESULTS
Field Value
Type Description
String

ATTRIBUTES_KEY_READ_CONSISTENCY

publicstaticfinalStringATTRIBUTES_KEY_READ_CONSISTENCY
Field Value
Type Description
String

ATTRIBUTES_KEY_RECEIVED

publicstaticfinalStringATTRIBUTES_KEY_RECEIVED
Field Value
Type Description
String

ATTRIBUTES_KEY_TRANSACTIONAL

publicstaticfinalStringATTRIBUTES_KEY_TRANSACTIONAL
Field Value
Type Description
String

ATTRIBUTES_KEY_TRANSACTION_ID

publicstaticfinalStringATTRIBUTES_KEY_TRANSACTION_ID
Field Value
Type Description
String

ATTRIBUTE_SERVICE_PREFIX

publicstaticfinalStringATTRIBUTE_SERVICE_PREFIX
Field Value
Type Description
String

ENABLE_TRACING_ENV_VAR

publicstaticfinalStringENABLE_TRACING_ENV_VAR
Field Value
Type Description
String

LIBRARY_NAME

publicstaticfinalStringLIBRARY_NAME
Field Value
Type Description
String

SPAN_NAME_ALLOCATE_IDS

publicstaticfinalStringSPAN_NAME_ALLOCATE_IDS
Field Value
Type Description
String

SPAN_NAME_BEGIN_TRANSACTION

publicstaticfinalStringSPAN_NAME_BEGIN_TRANSACTION
Field Value
Type Description
String

SPAN_NAME_COMMIT

publicstaticfinalStringSPAN_NAME_COMMIT
Field Value
Type Description
String

SPAN_NAME_LOOKUP

publicstaticfinalStringSPAN_NAME_LOOKUP
Field Value
Type Description
String

SPAN_NAME_RESERVE_IDS

publicstaticfinalStringSPAN_NAME_RESERVE_IDS
Field Value
Type Description
String

SPAN_NAME_ROLLBACK

publicstaticfinalStringSPAN_NAME_ROLLBACK
Field Value
Type Description
String

SPAN_NAME_RUN_AGGREGATION_QUERY

publicstaticfinalStringSPAN_NAME_RUN_AGGREGATION_QUERY
Field Value
Type Description
String

SPAN_NAME_RUN_QUERY

publicstaticfinalStringSPAN_NAME_RUN_QUERY
Field Value
Type Description
String

SPAN_NAME_TRANSACTION_COMMIT

publicstaticfinalStringSPAN_NAME_TRANSACTION_COMMIT
Field Value
Type Description
String

SPAN_NAME_TRANSACTION_LOOKUP

publicstaticfinalStringSPAN_NAME_TRANSACTION_LOOKUP
Field Value
Type Description
String

SPAN_NAME_TRANSACTION_RUN

publicstaticfinalStringSPAN_NAME_TRANSACTION_RUN
Field Value
Type Description
String

SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY

publicstaticfinalStringSPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY
Field Value
Type Description
String

SPAN_NAME_TRANSACTION_RUN_QUERY

publicstaticfinalStringSPAN_NAME_TRANSACTION_RUN_QUERY
Field Value
Type Description
String

Static Methods

getInstance(DatastoreOptions datastoreOptions)

publicstaticTraceUtilgetInstance(DatastoreOptionsdatastoreOptions)

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)

publicabstractSpanBuilderaddSettingsAttributesToCurrentSpan(SpanBuilderspanBuilder)

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()

publicabstractApiFunction<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()

publicabstractTraceUtil.ContextgetCurrentContext()

Returns the current Context.

Returns
Type Description
TraceUtil.Context

getCurrentSpan()

publicabstractTraceUtil.SpangetCurrentSpan()

Returns the current span.

Returns
Type Description
TraceUtil.Span

getTracer()

publicabstractTracergetTracer()

Returns the current OpenTelemetry Tracer when OpenTelemetry SDK is provided.

Returns
Type Description
io.opentelemetry.api.trace.Tracer

startSpan(String spanName)

publicabstractTraceUtil.SpanstartSpan(StringspanName)

Starts a new span with the given name, sets it as the current span, and returns it.

Parameter
Name Description
spanName String
Returns
Type Description
TraceUtil.Span

startSpan(String spanName, TraceUtil.Span parentSpan)

publicabstractTraceUtil.SpanstartSpan(StringspanName,TraceUtil.SpanparentSpan)

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.

Parameters
Name Description
spanName String
parentSpan TraceUtil.Span
Returns
Type Description
TraceUtil.Span

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 2025年11月19日 UTC.