Skip to content

feat: integrate OpenTelemetry tracing for LLM agent observability #13

@STRRL

Description

@STRRL

Summary

Add OpenTelemetry (OTel) tracing support to LAPP so that LLM agent calls (via eino ADK) are observable in standard tracing backends (Jaeger, Grafana Tempo, etc.).

Background

eino provides a callbacks.Handler mechanism that fires on every component invocation (ChatModel, Tool, etc.) within the ADK agent execution graph. Global handlers registered via callbacks.AppendGlobalHandlers() work transparently with ADK — no changes to analyzer.go needed.

Current state of eino-ext tracing

  • eino-ext/callbacks/apmplus — OTel-based but vendor-locked to Volcengine APMPlus (requires AppKey)
  • eino-ext/callbacks/langfuse — works well but uses Langfuse's own API, not OTLP
  • No vendor-neutral OTel callback handler exists in eino-ext

Proposal

Write a custom callbacks.Handler that uses standard go.opentelemetry.io/otel/trace to:

  1. OnStart — create a span with GenAI semantic attributes (gen_ai.request.model, prompt messages, etc.)
  2. OnEnd — end the span, record token usage (gen_ai.usage.prompt_tokens, gen_ai.usage.completion_tokens), response content
  3. OnError — set span error status
  4. Streaming variantsOnStartWithStreamInput / OnEndWithStreamOutput

Register it globally at process startup. The handler should accept a standard trace.TracerProvider so users can plug in any OTel-compatible backend.

Scope

  • ~100-200 lines for the callback handler
  • OTel SDK initialization (TracerProvider + OTLP exporter) configurable via env vars (OTEL_EXPORTER_OTLP_ENDPOINT, etc.)
  • Opt-in: tracing is enabled only when an OTLP endpoint is configured

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions