Skip to content

feat: Add trace context propagation API for Node.js SDK (parity with Python)Β #924

@golergka

Description

@golergka

Problem

When building production agents with the Node.js SDK, I need to correlate my application's OpenTelemetry spans with LiveKit's internal spans (agent_session, agent_turn, user_turn_completed).

Currently, the Python SDK exposes set_tracer_provider() for trace context configuration, but the Node.js SDK has no equivalent API. This means:

  1. LiveKit's spans and my application's spans have separate trace IDs
  2. I cannot visualize the full call flow in a single trace tree
  3. Debugging requires manually correlating spans by room_sid across two separate traces

Current Behavior

  • @livekit/rtc-node registers an OpenTelemetry TracerProvider at import time
  • My observability code can add span processors to this provider (so spans export to the same backend)
  • But there's no way to share trace context - each creates its own root span

Desired Behavior

An API similar to Python's set_tracer_provider() that allows:

  1. Setting a custom TracerProvider, OR
  2. Propagating a parent span context so LiveKit's spans become children of my trace

Use Case

I have an agent with an 8-phase initialization pipeline (init:entry, init:connect_room, init:prepare_session, etc.). I want all of these phases PLUS LiveKit's internal spans to appear in a single trace tree for end-to-end observability.

Environment

  • @livekit/agents: v1.0.x
  • Node.js: v22.x
  • OpenTelemetry SDK: v2.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions