add sample observer interface to improve observability with NewLocalReaderTrack - #970
Draft
haffi96 wants to merge 1 commit into
Draft
add sample observer interface to improve observability with NewLocalReaderTrack#970haffi96 wants to merge 1 commit into
haffi96 wants to merge 1 commit into
Conversation
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.
This PR adds an optional, telemetry framework agnostic observer for the
LocalTracksample write loop.Applications using
NewLocalReaderTrackcurrently cannot observe the complete lifecycle of an encoded sample because reading, writing, and pacing happen inside the privatewriteWorker. The new observer exposes those lifecycle boundaries without requiring applications to duplicate the SDK’s reader, packetization, and pacing behavior.Motivation
Applications publishing media from streaming sources often need to measure:
WriteSamplecallsWriteSampleWrapping the source
io.Readeris insufficient because reads do not correspond reliably to encoded frames. Implementing a customSampleProviderexposes completed samples, but it cannot observe the subsequentWriteSampleresult or SDK pacing state.The SDK’s
writeWorkeris the only location that has authoritative access to all three stages:Without a hook at this boundary, applications must reimplement significant portions of
ReaderSampleProviderand the local-track write loop.Design
The change deliberately does not introduce an OpenTelemetry or metrics dependency. Instead, it exposes a general-purpose synchronous observer which applications can connect to any telemetry implementation.
New
SampleObserverinterfaceNew
SampleWriteResultThis provides enough information to calculate read-to-write latency and write duration without prescribing any particular telemetry system.