Skip to content

Proposal: add OpenTelemetry gen_ai.* instrumentation #876

Description

@meshailabs

Proposal

Add opt-in OpenTelemetry instrumentation conforming to the OTel gen_ai.* semantic conventions, so downstream observability tools (Datadog, Honeycomb, Phoenix, Langfuse, OTLP collectors, Vercel's built-in observability) get structured visibility into agent execution. Off by default, zero runtime cost when disabled.

Context

The agent workflow currently emits useful logs and platform metrics but no structured spans. As background coding agents move toward production, teams need a standard wire format for tracing. The gen_ai.* conventions are the emerging standard, and AI agent workflows are an active focus area in the OpenTelemetry GenAI SIG (open-telemetry/semantic-conventions#2912).

Implementation

I prepared a branch with the change. It's six files / +174 lines:

  • apps/web/instrumentation.ts — Next.js server-side OTel registration via @vercel/otel, dynamic-imported only when OTEL_ENABLED=true
  • packages/agent/telemetry.tsgetAgentTelemetry() helper returning the AI SDK experimental_telemetry config
  • packages/agent/open-agent.tsprepareCall now sets experimental_telemetry so all openAgent.stream() callers get instrumented automatically
  • packages/agent/index.ts — re-exports the helper
  • apps/web/package.json + bun.lock — adds @vercel/otel ^1.13.0
  • apps/web/.env.example — adds OTEL_ENABLED, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT
  • README.md — new "Telemetry" section

Branch (passes bun run ci locally): https://github.com/meshailabs/open-agents/tree/feat/otel-gen-ai-instrumentation

Diff against main: main...meshailabs:open-agents:feat/otel-gen-ai-instrumentation

Why I'm opening an issue

I tried to submit this as a PR but the repo is gated to collaborators only. Happy to clean up, scope down, or split the patch in any direction the maintainers prefer — let me know if there's a path you'd like to take here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions