Documentation
¶
Overview ¶
Package oteltools provides an OpenTelemetry tools.Middleware that traces each tool execution and records latency and error metrics. It wraps tools through the existing tools.Chain mechanism, so pkg/tools itself is never modified.
It imports only the OpenTelemetry API (trace + metric), never the SDK. When no Tracer or Meter is supplied it returns an identity middleware, so wiring it without providers leaves the tool unwrapped and costs nothing on the hot path.
Usage:
reg.Register(tools.Chain(myTool,
oteltools.Instrument(oteltools.WithTracer(tel.Tracer), oteltools.WithMeter(tel.Meter))))
When wired under an agent loop that opens iteration spans (agent.WithTracer), these tool spans nest as children of the iteration span automatically via ctx.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Instrument ¶
func Instrument(opts ...Option) tools.Middleware
Instrument returns a tools.Middleware that opens an "execute_tool <name>" span and records duration + error metrics for each call. With neither a Tracer nor a Meter it returns an identity middleware (the tool is passed through unwrapped).