Package codes.grow.packages.tempo
Class TempoTracing
java.lang.Object
codes.grow.packages.tempo.TempoTracing
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 Summary
Modifier and TypeMethodDescriptionstatic io.opentelemetry.sdk.trace.export.SpanExportercreateExporter(TracingConfig config) Builds the official OTLP exporter:grpc→ OTLP/gRPC (lower-case metadata, e.g.static SpanExporterFactoryThe Tempo exporter factory forTracing.initWith(codes.grow.packages.tempo.tracing.TracingConfig, codes.grow.packages.tempo.tracing.SpanExporterFactory): applies the Tempo defaults and builds the official OTLP exporter.static TracingHandleinitTracing(TempoTracingConfig config) Starts tracing: settings fromconfig, then the process environment, then Tempo defaults (seeTempoTracingConfig).static TracingHandleinitTracing(TempoTracingConfig config, EnvReader env) initTracing(TempoTracingConfig)with an explicit environment.static TracingHandleinitTracing(TracingConfig config) Starts tracing from a generic config: every field is used as given; only an unset endpoint and a missingX-Scope-OrgIDheader are filled from the environment, andnativemeans OTLP over HTTP.static TracingConfigwithDefaults(TracingConfig config) Applies the Tempo defaults:native→http/protobuf, unset endpoint →http://127.0.0.1:4318(:4317for gRPC), gRPC header names lower-cased.static TracingConfigwithTenant(TracingConfig config, String tenantId) Returns a copy ofconfigthat sendstenantIdasX-Scope-OrgIDwith every export.
-
Method Details
-
initTracing
Starts tracing: settings fromconfig, then the process environment, then Tempo defaults (seeTempoTracingConfig). CallTracingHandle.shutdown()before the process exits.- Parameters:
config- settings- Returns:
- handle
- Throws:
ConfigException- for invalid settings or variables
-
initTracing
initTracing(TempoTracingConfig)with an explicit environment.- Parameters:
config- settingsenv- environment reader- Returns:
- handle
-
initTracing
Starts tracing from a generic config: every field is used as given; only an unset endpoint and a missingX-Scope-OrgIDheader are filled from the environment, andnativemeans OTLP over HTTP.- Parameters:
config- generic config- Returns:
- handle
-
exporterFactory
The Tempo exporter factory forTracing.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
Builds the official OTLP exporter:grpc→ OTLP/gRPC (lower-case metadata, e.g.x-scope-orgid);http/protobufandnative→ OTLP/HTTP protobuf to<endpoint>/v1/traces. An unset endpoint takes the Tempo default.- Parameters:
config- tracing config- Returns:
- exporter
-
withDefaults
Applies the Tempo defaults:native→http/protobuf, unset endpoint →http://127.0.0.1:4318(:4317for gRPC), gRPC header names lower-cased.- Parameters:
config- config- Returns:
- config with defaults
-
withTenant
Returns a copy ofconfigthat sendstenantIdasX-Scope-OrgIDwith every export. An empty ornulltenant removes the header.- Parameters:
config- configtenantId- tenant- Returns:
- new config
- Throws:
ConfigException- for an invalid tenant id
-