Interface TraceUtil

All Known Implementing Classes:
DisabledTraceUtil, EnabledTraceUtil

@InternalExtensionOnly public interface TraceUtil
Utility interface to manage OpenTelemetry tracing instrumentation based on the configuration.
  • Field Details

  • Method Details

    • getInstance

      static TraceUtil getInstance(@Nonnull DatastoreOptions datastoreOptions)
      Creates and returns an instance of the TraceUtil class.
      Parameters:
      datastoreOptions - The DatastoreOptions object that is requesting an instance of TraceUtil.
      Returns:
      An instance of the TraceUtil class.
    • getChannelConfigurator

      @Nullable com.google.api.core.ApiFunction<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder> getChannelConfigurator()
      Returns a channel configurator for gRPC, or null if tracing is disabled.
    • startSpan

      TraceUtil.Span startSpan(String spanName)
      Starts a new span with the given name, sets it as the current span, and returns it.
    • startSpan

      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.
    • addSettingsAttributesToCurrentSpan

      io.opentelemetry.api.trace.SpanBuilder addSettingsAttributesToCurrentSpan(io.opentelemetry.api.trace.SpanBuilder spanBuilder)
      Adds common SpanAttributes to the current span, useful when hand-creating a new Span without using the TraceUtil.Span interface.
    • getCurrentSpan

      @Nonnull TraceUtil.Span getCurrentSpan()
      Returns the current span.
    • getCurrentContext

      @Nonnull TraceUtil.Context getCurrentContext()
      Returns the current Context.
    • getTracer

      io.opentelemetry.api.trace.Tracer getTracer()
      Returns the current OpenTelemetry Tracer when OpenTelemetry SDK is provided.