Class OtelAgenorTelemetry
- All Implemented Interfaces:
AgenorTelemetry,AutoCloseable
AgenorTelemetry implementation backed by the OpenTelemetry SDK.
Each call to spanBuilder(String) captures the current OTel
Context, so spans started from it are automatically children of the
ambient parent span. Parent-child relationships are preserved across
virtual-thread boundaries as long as the caller holds the context correctly
(e.g., within a try-with-resources scope returned by
Context.makeCurrent()).
Use OtelTelemetryFactory to construct instances:
AgenorTelemetry telemetry = OtelTelemetryFactory.builder()
.serviceName("my-agent")
.exporter("otlp-http")
.endpoint("http://localhost:4318")
.build();
- Since:
- 0.19.0
-
Constructor Summary
ConstructorsConstructorDescriptionOtelAgenorTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Creates anOtelAgenorTelemetrybacked by the givenOpenTelemetryinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Flushes and shuts down the underlying OTel SDK.spanBuilder(String operationName) Returns aSpanBuilderfor the given operation name.
-
Constructor Details
-
OtelAgenorTelemetry
public OtelAgenorTelemetry(io.opentelemetry.api.OpenTelemetry openTelemetry) Creates anOtelAgenorTelemetrybacked by the givenOpenTelemetryinstance.The instance is retained so that
close()can flush and shut down the underlyingOpenTelemetrySdk(including itsBatchSpanProcessor) when the runtime stops. Without holding a reference the SDK would be eligible for GC immediately after construction, silently discarding all buffered spans.- Parameters:
openTelemetry- the configured OTel instance; nevernull
-
-
Method Details
-
close
public void close()Flushes and shuts down the underlying OTel SDK.Forces the
BatchSpanProcessorto export any buffered spans before the process exits. Called automatically byAgenorRuntime.stop()when telemetry isAutoCloseable.- Specified by:
closein interfaceAutoCloseable
-
spanBuilder
Description copied from interface:AgenorTelemetryReturns aSpanBuilderfor the given operation name.The returned builder captures the current tracing context so that spans started from it are automatically children of the ambient parent span.
- Specified by:
spanBuilderin interfaceAgenorTelemetry- Parameters:
operationName- the name of the span (e.g."llm.chat"); nevernull- Returns:
- a new span builder; never
null
-