Repository navigation
fix(otel): record observed first-chunk timing for pass-through streams - #45590
hiteshPrabhu wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 05b8c3c70a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await GLOBAL_LOGGING_WORKER.flush() | ||
| assert logging.model_call_details["stream"] is True | ||
| assert logging.completion_start_time is None | ||
| assert await anext(response) == first |
There was a problem hiding this comment.
Inject a deterministic clock into timing tests
The first-chunk tests consume datetime.now() directly, so wall-clock jumps can change pass/fail outcomes; inject a deterministic clock for unit coverage
AGENTS.md reference: tests/unit/AGENTS.md:L3-L3
Useful? React with 👍 / 👎.
|
|
||
|
|
||
| def _resolved_bool(value: object) -> bool | None: | ||
| """``value`` as a real bool; never truthifies a string like "false".""" |
There was a problem hiding this comment.
Remove the redundant helper docstring
This helper docstring merely restates the return expression; remove it because comments are reserved for complex business logic, tooling directives, or TODOs
AGENTS.md reference: AGENTS.md:L1-L7
Useful? React with 👍 / 👎.
| chunk: Final = await self._iterator.asend(value) | ||
| _stamp_first_chunk_if_needed(self._litellm_logging_obj, chunk) | ||
| return chunk |
There was a problem hiding this comment.
Collect chunks returned by send and asend
send(None) and asend(None) timestamp but never collect their chunks, so one-chunk streams export no TTFT; added tests check only internal state
AGENTS.md reference: AGENTS.md:L24-L24
Useful? React with 👍 / 👎.
TLDR
Problem this solves:
How it solves it:
User Flow
Before: a streamed response succeeds without first-chunk timing
After: telemetry measures when the first chunk arrives
Relevant issues
Fixes #45588
Related: #30384 concerns a different generic proxy streaming handler; #31385 and #32284 cover Messages/Responses timing
Pre-Submission checklist
Tests
On this independent branch,
tests/unit/integrations/otel/plustests/unit/passthrough/: 1,102 passedThe decorated async route regression uses real
Logging, real OTel recording and an injected external HTTP transport. It failed before the dispatch correction and passes afterward. It checks unchanged bytes, no premature timestamp, once-only first-chunk observation and one terminal callbackAdditional tests cover sync/async wrappers,
send/asend, existing observations, empty/unconsumed streams, boolean precedence, missing/negative/non-finite timing, and metric/span parity. Independent local review findings were addressedCombined-patch strict Ruff, type-discipline and test-quality delta gates passed. Expanded utility tests also exposed three retry failures reproducible on the unchanged baseline; they are not represented as passing
Screenshots / Proof of Fix
Native real-provider proof is pending. The evidence below uses a real local proxy, a scripted Bedrock HTTP upstream and a local OTLP receiver. No paid provider was called
Shared setup: the synthetic configuration in #45588. The upstream delays its first event-stream bytes by 150 ms, then completes about 650 ms later
Before (63a4f3f)
After (05b8c3c)
Type
Bug Fix
Caveats
Medium
Final Attestation