Skip to content

fix(agents): preserve custom tracer provider with Cloud tracing#2051

Open
dtran26 wants to merge 1 commit into
livekit:mainfrom
dtran26:agent/preserve-custom-tracer-provider
Open

fix(agents): preserve custom tracer provider with Cloud tracing#2051
dtran26 wants to merge 1 commit into
livekit:mainfrom
dtran26:agent/preserve-custom-tracer-provider

Conversation

@dtran26

@dtran26 dtran26 commented Jul 17, 2026

Copy link
Copy Markdown

Description

Preserves a caller-provided OpenTelemetry tracer provider when LiveKit Cloud tracing is enabled.

OpenTelemetry 2.x removed NodeTracerProvider.addSpanProcessor(). The previous fallback created a second provider and moved LiveKit's internal tracer to it, splitting application spans and LiveKit spans across different exporters.

Related to #1879.

Changes Made

  • Add an optional registerSpanProcessor callback to setTracerProvider for providers backed by a mutable or delegating span processor.
  • Retain addSpanProcessor() as the OpenTelemetry 1.x compatibility path.
  • Preserve an incompatible custom provider and emit an actionable warning instead of silently replacing it.
  • Add regression coverage for both the explicit registrar and no-registrar paths.
  • Add a patch changeset for @livekit/agents.

Pre-Review Checklist

  • Build passes: Package build, typecheck, lint, formatting, and focused tests pass locally
  • AI-generated code reviewed: Removed implementation-specific assertions and unnecessary comments
  • Changes explained: Root cause and compatibility behavior are documented above
  • Scope appropriate: Only tracer-provider composition, its tests, and release note are changed
  • Video demo: Not applicable; this is a telemetry-only change with automated regression coverage

Testing

  • pnpm test agents/src/telemetry/traces.test.ts
  • pnpm --filter @livekit/agents typecheck
  • pnpm --filter @livekit/agents build
  • pnpm -w format:write
  • pnpm -w lint:fix
  • Agent Playground smoke test not applicable; no agent media or session behavior changes

Additional Notes

pnpm --filter @livekit/agents api:check remains blocked on main by API Extractor's unsupported export * as syntax in dist/index.d.ts.


Note to reviewers: Please ensure the pre-review checklist is completed before starting your review.

@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e2c2f57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages
Name Type
@livekit/agents Patch
@livekit/agents-plugin-anam Patch
@livekit/agents-plugin-anthropic Patch
@livekit/agents-plugin-assemblyai Patch
@livekit/agents-plugin-azure Patch
@livekit/agents-plugin-baseten Patch
@livekit/agents-plugin-bey Patch
@livekit/agents-plugin-cartesia Patch
@livekit/agents-plugin-cerebras Patch
@livekit/agents-plugin-deepgram Patch
@livekit/agents-plugin-did Patch
@livekit/agents-plugin-elevenlabs Patch
@livekit/agents-plugin-fishaudio Patch
@livekit/agents-plugin-google Patch
@livekit/agents-plugin-hedra Patch
@livekit/agents-plugin-hume Patch
@livekit/agents-plugin-inworld Patch
@livekit/agents-plugin-lemonslice Patch
@livekit/agents-plugin-liveavatar Patch
@livekit/agents-plugin-livekit Patch
@livekit/agents-plugin-minimax Patch
@livekit/agents-plugin-mistral Patch
@livekit/agents-plugin-mistralai Patch
@livekit/agents-plugin-neuphonic Patch
@livekit/agents-plugin-openai Patch
@livekit/agents-plugin-perplexity Patch
@livekit/agents-plugin-phonic Patch
@livekit/agents-plugin-resemble Patch
@livekit/agents-plugin-rime Patch
@livekit/agents-plugin-runway Patch
@livekit/agents-plugin-sarvam Patch
@livekit/agents-plugin-silero Patch
@livekit/agents-plugin-soniox Patch
@livekit/agents-plugin-tavus Patch
@livekit/agents-plugins-test Patch
@livekit/agents-plugin-trugen Patch
@livekit/agents-plugin-xai Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dtran26
dtran26 force-pushed the agent/preserve-custom-tracer-provider branch from da3d7da to e2c2f57 Compare July 17, 2026 07:03
@dtran26
dtran26 marked this pull request as ready for review July 17, 2026 07:04
@dtran26
dtran26 requested a review from a team as a code owner July 17, 2026 07:04

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants