Default: no-op
WithoutWithObservabilityConfig or WithTracer, the agent uses built-in no-op tracers. Zero overhead.
Wire OTLP (recommended)
Requires a running OpenTelemetry-compatible collector (e.g. OpenTelemetry Collector or Jaeger). Quick local setup:WithObservabilityConfig:
Insecure: true disables TLS on the collector connection. Use only in development or trusted internal networks. Omit it (defaults to TLS) for production OTLP endpoints.
Use the same
WithObservabilityConfig on NewAgent and NewAgentWorker so worker activity spans reach the same backend.
Observability config participates in the Temporal agent fingerprint — caller and worker must match.
Bring your own tracer
UseWithTracer when you already have an OpenTelemetry provider or need fine-grained control via pkg/observability:
WithObservabilityConfig enables traces, any WithTracer value is replaced by the OTLP tracer built from config.
pkg/observability exposes additional options not on ObservabilityConfig — sampling ratio, batch timeout, export timeout, custom headers, service version, and deployment environment. See observability.Config.
Spans
Common attributes
Spans and metrics share attribute keys where applicable:Temporal workflow traces
On the Temporal runtime, the agent loop runs as a Temporal workflow. The SDK emits its own spans (agent.loop, llm.generate, tool.execute, etc.) as child spans under the workflow execution — visible in any OTLP-connected backend. Temporal’s own server-side traces (workflow scheduling, history replay) are separate and require a Temporal-instrumented deployment.
To correlate agent spans with Temporal workflow IDs, use WithObservabilityConfig on both the agent and worker process. The workflow.id appears as an attribute on the agent.run span.
Example collector config
Minimalotel-collector-config.yaml — accepts OTLP gRPC and exports to Jaeger and logging:
Worker shutdown
- Agent —
a.Close()flushes trace exporters - Worker —
w.Stop()flushes OTLP on standalone worker processes
Agent.Close().
Example: Observability · Hooks.
Example
Observability
OTLP traces, metrics, and logs
Related
Metrics
Counters and histograms alongside traces
Logs
OTLP log export