oteltools

package
v0.41.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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).

Types

type Option

type Option func(*config)

Option configures Instrument.

func WithMeter

func WithMeter(m metric.Meter) Option

WithMeter supplies the Meter used to record execution latency and errors.

func WithTracer

func WithTracer(t trace.Tracer) Option

WithTracer supplies the Tracer used to open per-Execute spans.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL