agents-go
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

OptionPurpose
WithServiceNameService name on emitted resource.
WithSinkWhere to send — NewPrometheusSink / NewOTLPGRPCSink / NewOTLPHTTPSink.
WithContentCaptureOpt-in capture of message content (off by default).
WithResource / WithNamingProfile / WithSignalPolicy / WithAttributeFilterResource, 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.

On this page