Skip to content

test(e2e): Port cloudflare-autoinstrument to span streaming - #23861

Open
JPeer264 wants to merge 1 commit into
jp/e2e-stream-cloudflare-orchestrion-mysqlfrom
jp/e2e-stream-cloudflare-autoinstrument
Open

test(e2e): Port cloudflare-autoinstrument to span streaming#23861
JPeer264 wants to merge 1 commit into
jp/e2e-stream-cloudflare-orchestrion-mysqlfrom
jp/e2e-stream-cloudflare-autoinstrument

Conversation

@JPeer264

@JPeer264 JPeer264 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Ports cloudflare-autoinstrument to span streaming (pin removed from src/instrument.server.ts).

  • The environment: 'qa' proof now reads the sentry.environment span attribute.
  • The agent tests locate the greet rpc span directly and use collectStreamedSpans until the owning webSocketMessage segment of the same trace has arrived, since the child is streamed before its segment.
  • The plain-DO negative check filters by the trace of the /plain-do segment.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.94 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.83 kB - -
@sentry/browser (incl. Tracing) 48.87 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.88 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.8 kB - -
@sentry/browser (incl. Tracing, Replay) 88.36 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.76 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.05 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.02 kB - -
@sentry/browser (incl. Feedback) 46.06 kB - -
@sentry/browser (incl. sendFeedback) 33.64 kB - -
@sentry/browser (incl. FeedbackAsync) 38.74 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.81 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.32 kB - -
@sentry/react (incl. Tracing) 51.08 kB - -
@sentry/vue 35.74 kB - -
@sentry/vue (incl. Tracing) 51.14 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.52 kB - -
CDN Bundle (incl. Logs, Metrics) 32.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.19 kB - -
CDN Bundle (incl. Tracing, Replay) 87 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.83 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.57 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.26 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.43 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.74 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.43 kB - -
@sentry/nextjs (client) 53.7 kB - -
@sentry/sveltekit (client) 49.3 kB - -
@sentry/core/server 40.74 kB - -
@sentry/core/browser 13.42 kB - -
@sentry/node 124.12 kB +0.02% +19 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.51 kB - -
@sentry/node - without tracing 88.3 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 103.42 kB +0.02% +20 B 🔺
@sentry/aws-serverless 96.66 kB +0.03% +25 B 🔺
@sentry/cloudflare (withSentry) - minified 200.81 kB - -
@sentry/cloudflare (withSentry) 499.76 kB - -

View base workflow run

@JPeer264
JPeer264 force-pushed the jp/e2e-stream-cloudflare-autoinstrument branch from 07903f7 to a44c247 Compare September 1, 2026 15:21
@JPeer264
JPeer264 force-pushed the jp/e2e-stream-cloudflare-autoinstrument branch from a44c247 to 71e611b Compare September 2, 2026 06:21
@JPeer264
JPeer264 force-pushed the jp/e2e-stream-cloudflare-autoinstrument branch from 71e611b to 6a8bb1c Compare September 2, 2026 07:10
@JPeer264
JPeer264 marked this pull request as ready for review September 2, 2026 07:13
@JPeer264
JPeer264 force-pushed the jp/e2e-stream-cloudflare-autoinstrument branch from 6a8bb1c to 6c19779 Compare September 2, 2026 07:46
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you rebase on develop, the traceid distinction is no longer needed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/e2e-stream-cloudflare-autoinstrument branch from 6c19779 to 116adf9 Compare September 2, 2026 11:30
@JPeer264
JPeer264 requested a review from andreiborza September 2, 2026 11:32
Comment on lines +60 to +64
spans =>
spans.some(
span =>
getSpanOp(span) === 'rpc' &&
span.name === 'greet' &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants