test(e2e): Port cloudflare-autoinstrument to span streaming - #23861
Open
JPeer264 wants to merge 1 commit into
Open
test(e2e): Port cloudflare-autoinstrument to span streaming#23861JPeer264 wants to merge 1 commit into
JPeer264 wants to merge 1 commit into
Conversation
Contributor
size-limit report 📦
|
JPeer264
force-pushed
the
jp/e2e-stream-cloudflare-autoinstrument
branch
from
September 1, 2026 15:21
07903f7 to
a44c247
Compare
JPeer264
force-pushed
the
jp/e2e-stream-cloudflare-autoinstrument
branch
from
September 2, 2026 06:21
a44c247 to
71e611b
Compare
JPeer264
force-pushed
the
jp/e2e-stream-cloudflare-autoinstrument
branch
from
September 2, 2026 07:10
71e611b to
6a8bb1c
Compare
JPeer264
marked this pull request as ready for review
September 2, 2026 07:13
JPeer264
force-pushed
the
jp/e2e-stream-cloudflare-autoinstrument
branch
from
September 2, 2026 07:46
6a8bb1c to
6c19779
Compare
andreiborza
reviewed
Sep 2, 2026
| event.transaction === 'webSocketMessage' && | ||
| (event.spans ?? []).some(span => span.op === 'rpc' && span.description === 'greet') | ||
| !!rpcSpan && | ||
| spans.some(span => span.is_segment && span.name === 'webSocketMessage' && span.trace_id === rpcSpan.trace_id) |
Member
There was a problem hiding this comment.
If you rebase on develop, the traceid distinction is no longer needed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
JPeer264
force-pushed
the
jp/e2e-stream-cloudflare-autoinstrument
branch
from
September 2, 2026 11:30
6c19779 to
116adf9
Compare
Comment on lines
+60
to
+64
| spans => | ||
| spans.some( | ||
| span => | ||
| getSpanOp(span) === 'rpc' && | ||
| span.name === 'greet' && |
Contributor
There was a problem hiding this comment.
Bug: The waitForStreamedSpan test utility lacks trace isolation, which can cause race conditions and flaky results when tests are run in parallel.
Severity: MEDIUM
Suggested Fix
Modify waitForStreamedSpan to implement trace isolation. It should group spans by trace_id before evaluating them, similar to how collectStreamedSpans is implemented. This will ensure that the function only resolves with a span that belongs to the same trace as the action that triggered it, preventing cross-test contamination during parallel execution.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/cloudflare-autoinstrument/tests/autoinstrument.test.ts#L60-L64
Potential issue: The `waitForStreamedSpan` test utility function lacks trace isolation.
It filters incoming spans by a timestamp but not by `trace_id`. When tests are run in
parallel, as configured with `workers: '100%'`, a race condition can occur. If two tests
concurrently make requests that generate similar spans, the test calling
`waitForStreamedSpan` may incorrectly capture and validate a span generated by the other
test. This can lead to flaky tests that pass or fail based on timing and not because
their own specific action was correctly instrumented.
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.
Ports
cloudflare-autoinstrumentto span streaming (pin removed fromsrc/instrument.server.ts).environment: 'qa'proof now reads thesentry.environmentspan attribute.greetrpc span directly and usecollectStreamedSpansuntil the owningwebSocketMessagesegment of the same trace has arrived, since the child is streamed before its segment./plain-dosegment.