Skip to content

feat: flags to log stats#766

Open
oortlieb wants to merge 4 commits into
livekit:mainfrom
ultra-robotics:log-stats
Open

feat: flags to log stats#766
oortlieb wants to merge 4 commits into
livekit:mainfrom
ultra-robotics:log-stats

Conversation

@oortlieb
Copy link
Copy Markdown

We're using the client to publish videos to a room, and want to be able to get stats about the connection. This PR adds two flags to room join (--stats and --stats`).

   --stats                                    Periodically log publisher WebRTC GetStats as one JSON object per line to stderr (default: false)
   --stats-interval float                     Seconds between stats logs when --stats is set (default: 5)

It's helpful for our use case so wanted to offer it back to the project!

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 12, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 3 committers have signed the CLA.

✅ oortlieb
❌ Sandeep Jain
❌ deepinsand


Sandeep Jain seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sandeep Jain and others added 3 commits May 20, 2026 10:45
…stats

pc.GetStats() on a publisher PeerConnection only returns ICE/transport
stats because pion's rtpsender has no collectStats implementation. The
per-track RTCP Receiver Report data (packetsLost, jitter, RTT,
fractionLost) exists in the pion interceptor stats recorder but is
never surfaced.

Register a stats.InterceptorFactory via WithInterceptors and capture
the Getter in OnNewPeerConnection. In the stats ticker, enumerate
senders via pc.GetSenders(), look up each SSRC in the Getter, and
append remote-inbound-rtp entries to the combined stats map alongside
the existing ICE/transport stats.

The JSON output now includes entries with type "remote-inbound-rtp"
containing packetsLost, jitter, roundTripTime, and fractionLost for
each published track's SSRC.
OnNewPeerConnection fires for both publisher and subscriber PCs since
WithInterceptors applies to both. Previously we overwrote statsGetter
with the last (subscriber) getter, so g.Get(ssrc) always returned nil
for sender SSRCs. Now we collect all getters and try each one per SSRC,
breaking on the first hit (the publisher getter).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stats: populate remote-inbound-rtp per-track packet loss via pion interceptor
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.

3 participants