telemetry

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 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 telemetry provides OpenTelemetry integration for GopherAgent via the EventHandler system. It is an optional import: applications that do not need tracing never pay for it.

Wire it at startup:

tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exporter))
tracer := tp.Tracer("gopheragent")
loop.OnEvent(telemetry.NewOTelHandler(tracer))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOTelHandler

func NewOTelHandler(tracer trace.Tracer) agent.EventHandler

NewOTelHandler returns an agent.EventHandler that instruments every agent iteration with OpenTelemetry tracing.

This is the lightweight, zero-configuration alternative to the richer instrumentation path (agent.WithTracer + the otelllm decorator + the oteltools middleware). It needs only an EventHandler registration and produces one coarse span per iteration derived from stream events, but — being event-driven — it cannot open true child spans for LLM calls or capture tool latency. Prefer the WithTracer path when you need nested spans and per-call timings. The two are mutually exclusive: enabling both double-instruments each iteration.

Span lifecycle per session key:

  • Root span "agent.iteration" is opened lazily on the first event.
  • "tool_call" → span event "tool.execute" with tool name attribute.
  • "action_required" → span event "hitl.action_required".
  • "error" → RecordError + SetStatus(Error) + End.
  • "done" → SetStatus(Ok) + End.

The tracer's parent context is the ctx passed to RunIteration / RunIterationStream, so the agent spans nest correctly inside existing traces.

Types

This section is empty.

Directories

Path Synopsis
Package otelllm provides an OpenTelemetry instrumenting decorator for any agent.LLMProvider.
Package otelllm provides an OpenTelemetry instrumenting decorator for any agent.LLMProvider.
Package otelsetup wires an OpenTelemetry OTLP pipeline for gopheragent with a single call.
Package otelsetup wires an OpenTelemetry OTLP pipeline for gopheragent with a single call.
Package oteltools provides an OpenTelemetry tools.Middleware that traces each tool execution and records latency and error metrics.
Package oteltools provides an OpenTelemetry tools.Middleware that traces each tool execution and records latency and error metrics.
Package semconv holds the OpenTelemetry attribute keys and metric names shared by the gopheragent instrumentation packages (otelllm, oteltools, and the agent loop).
Package semconv holds the OpenTelemetry attribute keys and metric names shared by the gopheragent instrumentation packages (otelllm, oteltools, and the agent loop).

Jump to

Keyboard shortcuts

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