Skip to main content
Agent SDK for Go emits distributed traces via OpenTelemetry. Traces are no-op by default — no extra imports or init code required until you wire an exporter.

Default: no-op

Without WithObservabilityConfig or WithTracer, the agent uses built-in no-op tracers. Zero overhead. Requires a running OpenTelemetry-compatible collector (e.g. OpenTelemetry Collector or Jaeger). Quick local setup:
Configure traces, metrics, and logs in one block with WithObservabilityConfig:
defer a.Close() is required to flush buffered OTLP spans before process exit. Without it, spans from the last batch may be silently dropped. Similarly, call w.Stop() on AgentWorker processes.
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

Use WithTracer when you already have an OpenTelemetry provider or need fine-grained control via pkg/observability:
When 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

Minimal otel-collector-config.yaml — accepts OTLP gRPC and exports to Jaeger and logging:
Run with:

Worker shutdown

  • Agenta.Close() flushes trace exporters
  • Workerw.Stop() flushes OTLP on standalone worker processes
Embedded local workers flush via Agent.Close(). Example: Observability · Hooks.

Example

Observability

OTLP traces, metrics, and logs

Metrics

Counters and histograms alongside traces

Logs

OTLP log export