deepgram-stt: report connection-lifetime remainder so usage matches billing#5506
Open
joaquinhuigomez wants to merge 1 commit intolivekit:mainfrom
Open
deepgram-stt: report connection-lifetime remainder so usage matches billing#5506joaquinhuigomez wants to merge 1 commit intolivekit:mainfrom
joaquinhuigomez wants to merge 1 commit intolivekit:mainfrom
Conversation
…illing STTMetrics.audio_duration accumulated only the duration of audio frames pushed to the Deepgram WebSocket via the PeriodicCollector. Deepgram bills for the full WebSocket connection lifetime, so cost-tracking users saw a consistent 4–5 s per-stream undercount against Deepgram's usage reports (much worse on short calls). Track the connection open timestamp and the total duration already reported via _on_audio_duration_report, and on close emit any remainder between wall-clock connection lifetime and reported frames. The collector is also flushed before the remainder calc so pending frame duration is accounted for first. Fixes livekit#5498
sluceno
approved these changes
Apr 21, 2026
theomonnom
approved these changes
Apr 21, 2026
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.
STTMetrics.audio_durationaccumulated only the duration of audio frames pushed to the Deepgram WebSocket via thePeriodicCollector. Deepgram bills for the full WebSocket connection lifetime, so cost-tracking users saw a consistent 4–5 s per-stream undercount against Deepgram's usage reports (much worse on short calls, ~17% on a 20 s call).Track the connection open timestamp and the total duration already reported via
_on_audio_duration_report, and on close emit any remainder between wall-clock connection lifetime and reported frames. The collector is also flushed before the remainder calc so pending frame duration is accounted for first.Fixes #5498