Skip to content

Module github.com/bide-ai/bide/trace ​

Go module github.com/bide-ai/bide/trace; all modules.

trace ​

github.com/bide-ai/bide/trace · pkg.go.dev · Stability: core

Package trace adds OpenTelemetry GenAI instrumentation to an agent, opt-in, so the core agent package carries NO OTel dependency (a user who doesn't import trace pays nothing; contrast frameworks whose core drags the full OTel + Temporal stack into every binary).

Functions

  • func Instrument(tracer oteltrace.Tracer, opts ...Option) agent.Option: Instrument is the agent option that wires the gen_ai span taxonomy onto an agent in one call: the "chat" span (via Model) and the "execute_tool" span (via Tool), using tracer.
  • func Invoke(ctx context.Context, tracer oteltrace.Tracer, name string) (context.Context, func(error)): Invoke starts a top-level gen_ai "invoke_agent" span; call the returned end(err) when the run finishes.
  • func Model(tracer oteltrace.Tracer, opts ...Option) agent.Middleware: Model returns middleware that wraps each model call in a gen_ai "chat" span with token usage, the finish reason and status.
  • func Tool(tracer oteltrace.Tracer) agent.ToolMiddleware: Tool returns tool middleware that wraps every tool call in a gen_ai "execute_tool" span.

type Option ​

go
type Option func(*config)

Option configures the chat span.

Constructors and functions

  • func WithRates(r middleware.Rates) Option: WithRates records USD cost on the chat span (attribute gen_ai.usage.cost), computed from token usage at these rates.

Apache-2.0 licensed.