Class TempoTracing

java.lang.Object
codes.grow.packages.tempo.TempoTracing

public final class TempoTracing extends Object
OpenTelemetry tracing that exports to Grafana Tempo over OTLP (SPEC section 5), built on the official OpenTelemetry Java SDK.

 TracingHandle tracing = TempoTracing.initTracing(
     TempoTracingConfig.builder("checkout").tenantId("team-a").build());
 Spans.withSpan("work", () -> doWork());
 tracing.shutdown();
 

Use the span helpers of codes.grow.packages.tempo.tracing (Spans, Traced, HttpSpans, TracingFilter, TracedHttpClient, TracingInterceptor) with the handle. Read spans back with TempoQueryClient.

  • Method Details

    • initTracing

      public static TracingHandle initTracing(TempoTracingConfig config)
      Starts tracing: settings from config, then the process environment, then Tempo defaults (see TempoTracingConfig). Call TracingHandle.shutdown() before the process exits.
      Parameters:
      config - settings
      Returns:
      handle
      Throws:
      ConfigException - for invalid settings or variables
    • initTracing

      public static TracingHandle initTracing(TempoTracingConfig config, EnvReader env)
      initTracing(TempoTracingConfig) with an explicit environment.
      Parameters:
      config - settings
      env - environment reader
      Returns:
      handle
    • initTracing

      public static TracingHandle initTracing(TracingConfig config)
      Starts tracing from a generic config: every field is used as given; only an unset endpoint and a missing X-Scope-OrgID header are filled from the environment, and native means OTLP over HTTP.
      Parameters:
      config - generic config
      Returns:
      handle
    • exporterFactory

      public static SpanExporterFactory exporterFactory()
      The Tempo exporter factory for Tracing.initWith(codes.grow.packages.tempo.tracing.TracingConfig, codes.grow.packages.tempo.tracing.SpanExporterFactory): applies the Tempo defaults and builds the official OTLP exporter.
      Returns:
      factory
    • createExporter

      public static io.opentelemetry.sdk.trace.export.SpanExporter createExporter(TracingConfig config)
      Builds the official OTLP exporter: grpc → OTLP/gRPC (lower-case metadata, e.g. x-scope-orgid); http/protobuf and native → OTLP/HTTP protobuf to <endpoint>/v1/traces. An unset endpoint takes the Tempo default.
      Parameters:
      config - tracing config
      Returns:
      exporter
    • withDefaults

      public static TracingConfig withDefaults(TracingConfig config)
      Applies the Tempo defaults: native → http/protobuf, unset endpoint → http://127.0.0.1:4318 (:4317 for gRPC), gRPC header names lower-cased.
      Parameters:
      config - config
      Returns:
      config with defaults
    • withTenant

      public static TracingConfig withTenant(TracingConfig config, String tenantId)
      Returns a copy of config that sends tenantId as X-Scope-OrgID with every export. An empty or null tenant removes the header.
      Parameters:
      config - config
      tenantId - tenant
      Returns:
      new config
      Throws:
      ConfigException - for an invalid tenant id