Plugins
OpenTelemetry
Export the SDK's spans and metrics via OpenTelemetry.
The otel plugin implements the SDK's telemetry hooks with OpenTelemetry,
exporting spans and metrics to a Prometheus scrape endpoint or an OTLP collector.
Without it, telemetry defaults to a no-op tracer.
Capabilities
Telemetry (telemetry.Tracer)
Install & import
import otelplugin "github.com/webdeveloperben/agents-go/plugins/otel"No build tag.
Build a pipeline
NewPipeline returns a pipeline whose Plugin field satisfies both
telemetry.Tracer (pass to Config.Telemetry) and plugin.Plugin (register for
lifecycle):
pipeline, err := otelplugin.NewPipeline(ctx,
otelplugin.WithServiceName("support-agent"),
otelplugin.WithSink(otelplugin.NewPrometheusSink(otelplugin.PrometheusSinkOptions{
Server: &otelplugin.MetricsServerConfig{ListenAddress: ":9464"},
})),
)
session, _ := agents.NewSession(agents.Config{LLM: "openai/gpt-4o", Telemetry: pipeline.Plugin})Sinks & options
| Option | Purpose |
|---|---|
WithServiceName | Service name on emitted resource. |
WithSink | Where to send — NewPrometheusSink / NewOTLPGRPCSink / NewOTLPHTTPSink. |
WithContentCapture | Opt-in capture of message content (off by default). |
WithResource / WithNamingProfile / WithSignalPolicy / WithAttributeFilter | Resource, naming, signal, and attribute tuning. |
Sink option types: PrometheusSinkOptions (MetricsServerConfig),
OTLPGRPCSinkOptions, OTLPHTTPSinkOptions.
Notes
plugins/otelcompat is a small compatibility helper (e.g. LiveKit trace
interop); most setups only need plugins/otel.
Related
- Telemetry — the how-to, incl. Prometheus scraping.
- Latency & interruption — telemetry runs off the response path.