tool

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tool instruments Core tool execution with OpenTelemetry.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("otel/tool: invalid config")
	ErrInvalidTool   = errors.New("otel/tool: invalid tool")
)

Functions

This section is empty.

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware instruments exact Tool.Call boundaries without recording model arguments or results. It is immutable after construction and safe for concurrent use.

func NewMiddleware

func NewMiddleware(config MiddlewareConfig) (Middleware, error)

NewMiddleware fixes instrument identity and provider binding once so every tool invocation contributes to the same telemetry series.

func (Middleware) Wrap

func (m Middleware) Wrap(next coretool.Tool) (coretool.Tool, error)

Wrap freezes the Tool definition used for both execution identity and model exposure. Optional capabilities remain discoverable through Tool.Unwrap.

type MiddlewareConfig

type MiddlewareConfig struct {
	TracerProvider trace.TracerProvider
	MeterProvider  metric.MeterProvider
}

MiddlewareConfig takes providers rather than a tracer and meter so the choice of telemetry destination stays with the composition root. A nil provider falls back to the OpenTelemetry global, which is the convenient default for an application and the wrong one for a test that must observe only its own instruments.

Jump to

Keyboard shortcuts

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