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