Skip to content

Agent observability: OpenTelemetry export to a user-configured endpoint #332

Description

@cevheri

Why

Self-hosting teams already run their own observability stacks (Grafana, Prometheus, Datadog - anything that speaks OTLP). Agent runs should be observable there: the user's data and metrics stay in the user's infrastructure. No hosted collector, no consent flow, no default network activity, no new always-on dependency.

Rescoped 2026-08-10: this issue originally proposed opt-in anonymous product telemetry to a project-hosted collector. That idea is deliberately deferred (revisit at the 1.0 decision). The instrumentation built here keeps that path cheap if it is ever wanted - the same OTLP pipeline could later point at a project collector behind an explicit consent switch.

Behavior

  • Activation is endpoint-driven, following the standard OTLP convention: when OTEL_EXPORTER_OTLP_ENDPOINT (plus the usual companion vars) is set, the agent runtime registers @ai-sdk/otel and exports; when unset, the exporter module is never loaded (dynamic import) - zero runtime cost, zero network calls.
  • Default span/metric attributes are metadata-only: run id, workflowType, executionMode, tool name, outcome status/errorClass, duration, budget counters, model family, token buckets. SQL text, schema identifiers, prompts and result data are never attached by default - on a multi-user instance the operator reading the dashboards is not necessarily the query author.
  • A documented verbose opt-in flag may widen attributes; the exact delta is listed in the docs, not left implicit.
  • Embedded/platform builds: the host application owns OTel registration; the package must not register a second global SDK.

Scope

  • Endpoint-gated registration of @ai-sdk/otel + OTLP exporter (dormant unless configured)
  • Semantic span coverage mirroring the AgentEvent model: run lifecycle, tool calls, repairs, denials, budget
  • Attribute policy: metadata-only default + documented verbose flag; fixture test asserting denylisted fields never appear in default spans
  • docs/OBSERVABILITY.md: env vars, span catalogue, a Grafana/Prometheus quickstart
  • No-endpoint contract test: unset endpoint means no exporter module loaded and no network calls

Target

Ships with the M2 preview (#329); documented as an enterprise-facing capability ("your data, your metrics, your stack").


Part of #325

Metadata

Metadata

Assignees

No one assigned

    Labels

    aiArtificial intelligenceenhancementNew feature or requestloop:needs-moderator-actionFlagged by the maintainer loop: suspicious content or a decision only a human can make

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions