feat(browser): Defer fetch span end until stream body resolves#20778
Draft
nicohrubec wants to merge 3 commits intodevelopfrom
Draft
feat(browser): Defer fetch span end until stream body resolves#20778nicohrubec wants to merge 3 commits intodevelopfrom
nicohrubec wants to merge 3 commits intodevelopfrom
Conversation
Add a `processSpan` hook alongside the existing event processor to support the span streaming path for fetch stream timestamp corrections. Ref: #20376 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Instead of ending the span at header arrival and patching timestamps later via event processor, defer the span end until the response body fully resolves. Removes the event processor entirely. Closes #20376 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
size-limit report 📦
|
Instead of reimplementing endSpan logic (HTTP status, content-length, onRequestSpanEnd), stash the original handlerData, put the span back in the spans record, and let instrumentFetchRequest handle everything. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Previously, when trackFetchStreamPerformance was enabled, the SDK ended http.client spans immediately when response headers arrived, then retroactively patched the end timestamp via an event processor when the transaction flushed. Now, instead of patching after the fact, the span end is deferred entirely until the response body stream resolves. The span naturally gets the correct end timestamp, which removes the need for the event processor and works for both transaction and span streaming paths.
Closes #20376