rtc: emit per-data-track bytes via BytesTrackStats#4540
Merged
Conversation
Data tracks (the new _data_track datachannel) previously only updated a private dataTrackStats that logged a single summary at Close. Bytes never reached the OnTrackStats -> TelemetryService.TrackStats pipeline that media tracks and signal channels feed. Wire DataTrack (UPSTREAM, publisher-home) and DataDownTrack (DOWNSTREAM, per-subscriber) into BytesTrackStats on the same 5s cadence, mirroring the media-track convention: subscriber's country and ID with publisher's track ID for DOWNSTREAM. Cross-region proxy DataTracks leave the stats pointer nil (no publisher reporter on that node, and relayed bytes would double-count). Legacy dataTrackStats packet-loss/frame counters are preserved.
anunaym14
approved these changes
May 23, 2026
Member
|
livekit/pkg/rtc/participant.go Line 291 in 2e22911 this probably needs to be removed? |
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.
Summary
_data_trackdatachannel) previously only updated a privatedataTrackStatsthat logged a single summary atClose. Bytes never reached theOnTrackStats → TelemetryService.TrackStatspipeline that media tracks and signal channels feed.DataTrack(UPSTREAM, at the publisher's home node whereHandlePacketfires) andDataDownTrack(DOWNSTREAM, per local subscriber, atWritePacketpost-marshal) intoBytesTrackStatson the established 5s cadence.BytesTrackStatsfor DOWNSTREAM is constructed insideDataTrack.AddSubscriberfrom the subscriber'sLocalParticipantaccessors; UPSTREAM is constructed at the two publisher-homeNewDataTrackcall sites (HandlePublishDataTrackRequestand the migration path).DataTrackinstances (e.g. cloud'sRemoteParticipant) leave the new params field nil — they have no publisher reporter on that node, and relayed bytes routed throughHandlePacketwould double-count.dataTrackStatspacket-loss / out-of-order / frame counters are preserved unchanged.Test plan
go test -short ./pkg/rtc/...passesgo test -short ./pkg/rtc/...passes (no cloud edits needed — additive params field defaults to nil at proxy and replay sites)OnTrackStatsreceives bothStatsKeyForData(UPSTREAM, publisherID, dataTrackID)(publisher node) andStatsKeyForData(DOWNSTREAM, subscriberID, dataTrackID)(subscriber node) on ~5s cadence with a final flush on CloseDataTrackon subscriber node emits no UPSTREAM (no nil panic, no double accounting)