Documentation
¶
Overview ¶
Package otelllm provides an OpenTelemetry instrumenting decorator for any agent.LLMProvider. It wraps GenerateStream with a span and records call latency plus prompt/completion token metrics, without touching the concrete provider packages (pkg/llm/*).
It imports only the OpenTelemetry API (trace + metric), never the SDK, so it is a no-op — and returns the wrapped provider unchanged — when no Tracer or Meter is supplied.
Usage:
llm := otelllm.NewProvider(p,
otelllm.WithSystem("anthropic"), otelllm.WithModel(model),
otelllm.WithTracer(tel.Tracer), otelllm.WithMeter(tel.Meter))
loop := agent.New(sessions, registry, llm)
For a RouterProvider, wrap each backing provider before registering it so the gen_ai.request.model attribute is correct per route.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
func NewProvider(next agent.LLMProvider, opts ...Option) agent.LLMProvider
NewProvider wraps next with tracing and metrics. When neither a Tracer nor a Meter is supplied it returns next unchanged, so wiring the decorator without providers costs nothing on the hot path.
Types ¶
type Option ¶
type Option func(*config)
Option configures NewProvider.
func WithMeter ¶
WithMeter supplies the Meter used to record latency and token metrics. Without it, no metrics are produced.
func WithSystem ¶
WithSystem sets the gen_ai.system attribute (model vendor), e.g. "anthropic".
func WithTracer ¶
WithTracer supplies the Tracer used to open per-call spans. Without it, no spans are produced.