Conversation
🦋 Changeset detectedLatest commit: c64e497 The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
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 |
davidzhao
added this pull request to stack #2502
September 15, 2026 06:32
davidzhao
force-pushed
the
dz/telemetry-rpc
branch
from
September 15, 2026 06:46
f87c0f2 to
c0a9e8c
Compare
davidzhao
force-pushed
the
dz/telemetry-rpc
branch
from
September 16, 2026 04:28
c0a9e8c to
4976e41
Compare
Port of livekit/agents#7134. `telemetry.rpc` installs one tracing interceptor on the job's local participant and turns each RPC into a span following the OpenTelemetry RPC semantic conventions: `rpc_call` (CLIENT, under the current span, so an RPC issued from a tool nests under `function_tool`) and `rpc_handler` (SERVER, under the primary session's root span). Attributes cover method, ids, identities, payload and response sizes, the response timeout in seconds, the RpcError code and whether a handler was registered; request and response bodies are recorded truncated to 1 KiB under `lk.pii.rpc.*` keys. Installed from JobContext.connect() after the room connects and from RoomIO on every connected transition; both are idempotent, the SDK dedups the singleton interceptor by identity. `StartSpanOptions` gains `kind`. Adaptation: the installed @livekit/rtc-node predates LocalParticipant.addRpcInterceptor (it is in an open SDK PR), so the interceptor and call shapes are declared structurally here and `install` feature-detects the hook, degrading to one debug log and a no-op like the Python layer on an older livekit-rtc. Not ported: the Python handling of asyncio cancellation of the handler chain (promises are not cancelled in Node; the SDK maps timeouts on the caller's side). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
davidzhao
force-pushed
the
dz/telemetry-rpc
branch
from
September 16, 2026 04:34
4976e41 to
c64e497
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of livekit/agents#7134. Stacked on #2497.
Description
Neither user-registered RPC methods nor the avatar datastream RPCs appeared in a trace. This installs a tracing interceptor on the job's local participant and turns each RPC into a span.
rpc_callfunction_toolrpc_handlerjob_entrypoint) before or after the sessionAttributes:
rpc.method,lk.rpc.request_id,lk.rpc.caller_identity,lk.rpc.destination_identity,lk.rpc.payload_size,lk.rpc.response_size,lk.rpc.response_timeout,lk.rpc.error_code,lk.rpc.handler_registered. Request and response bodies are under PII keyslk.pii.rpc.payload/lk.pii.rpc.response, truncated to 1 KiB.RpcErrorand handler exceptions set error status.Installed from
JobContext.connect()after the room connects, and fromRoomIO.start()on every connect for a room connected elsewhere. One interceptor per process; the SDK dedups registrations by identity.Depends on the SDK
The interceptor hook is
LocalParticipant.addRpcInterceptorfrom livekit/node-sdks#724, not yet in the installed@livekit/rtc-node. Like the Python layer, this degrades to a no-op with one debug log on an SDK without it: the interceptor shapes are declared structurally intelemetry/rpc.ts, install feature-detects the method, and no dependency bump is needed now. Once the SDK ships, bumping@livekit/rtc-nodeturns tracing on without further code changes.Note that the FFI layer answers
UNSUPPORTED_METHODfor unregistered methods before the SDK's handler runs, solk.rpc.handler_registered=falseis only set on the defensive path where the chain sees that error.Changes Made
telemetry/rpc.ts(new):TracingRpcInterceptor,install; exported astelemetry.rpc.telemetry/traces.ts:StartSpanOptions.kindpassed throughstartSpan/startActiveSpan/startActiveSpanSync.telemetry/trace_types.ts: eleven new attributes (the twolk.pii.rpc.*keys are PII).job.ts,voice/room_io/room_io.ts: install points.Adaptations from the Python source
CancelledError/cancel_reasonbranch and its tests are not ported: Node promises are not cancelled and the SDK never cancels the handler chain.install(undefined)is tolerated sinceroom.localParticipantis optional in the JS SDK types.Testing
telemetry/rpc.test.ts(11 tests) with fake continuations: attributes and parenting both directions, truncation and byte sizes, error codes and status, the unregistered flag on the defensive path, handler exceptions, install once / degrade;room_io.test.tsinstall-on-connect case.agentssuite green; build, typecheck, lint, API report updated.🤖 Generated with Claude Code