Tighten up publish latency stat. (#4615)

Previously it was anchored to participant transitioning to `ACTIVE` if
the add track request happened before that. But, that has a few issues
1.`ACTIVE` is for primary peer connection which could be subscriber peer
connection.
2. `ACTIVE` also include data channel establishment.

Switch to first connected time of publisher peer connection for that to
get a more accurate measure of track publish time.
This commit is contained in:
Raja Subramanian
2026-06-22 17:36:06 +05:30
committed by GitHub
parent 13ce35fc87
commit f7085535da
3 changed files with 23 additions and 4 deletions
+4 -4
View File
@@ -3248,11 +3248,11 @@ func (p *ParticipantImpl) mediaTrackReceived(
mt = p.addMediaTrack(signalCid, ti)
newTrack = true
// if the addTrackRequest is sent before participant active then it means the client tries to publish
// before fully connected, in this case we only record the time when the participant is active since
// if the addTrackRequest is sent before publisher peer connection is established, then it means the client tries to publish
// before fully connected, in this case we only record the time when publisher peer connection is established since
// we want this metric to represent the time cost by publishing.
if activeAt := p.lastActiveAt.Load(); activeAt != nil && createdAt.Before(*activeAt) {
createdAt = *activeAt
if connectedAt := p.TransportManager.PublisherFirstConnectedAt(); !connectedAt.IsZero() && createdAt.Before(connectedAt) {
createdAt = connectedAt
}
pubTime = time.Since(createdAt)
p.dirty.Store(true)