You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test(cloudflare): Add shared streamed-span helpers to the integration test runner
Adds `spanUtils.ts` next to `runner.ts`, and two span collection methods on
the runner. The suites ported to span streaming then do not each write their
own envelope handling.
`spanUtils.ts` reads a single envelope: `getSpanContainer` and
`getSpansFromEnvelope`. It re-exports `getSpanOp` from
`@sentry-internal/test-utils`, which this package already depends on. That
avoids a third copy of the function in the repo. The runner reads across
envelopes: `collectStreamedSpans` and `collectStreamedSpansUntilSegment`. The
names follow `dev-packages/test-utils/src/event-proxy-server.ts`, so a streamed
span assertion reads the same in this package and in the E2E apps.
A trace does not arrive in one envelope when several isolates send spans. The
collecting helpers therefore group the spans by trace, and resolve on the first
trace that satisfies the predicate.
Span waiters observe the envelope stream and never consume it. `.expect(...)`
stays usable for error envelopes at the same time. Span waiters also receive the
runner rejection, so a worker that fails to boot gives the real error instead of
a Vitest timeout.
`collectStreamedSpansUntilSegment` is for asserting on the segment span alone. Each
envelope is its own request to the mock server, so the segment can be received
before the envelope carrying its children even though it ends last. A suite that
asserts on the children waits for those children instead, by name or by count.
A runner now tears down its own workers from `onTestFinished`, and that teardown
kills only its own workers rather than running the shared cleanup. Both halves
are needed. A suite that asserts on streamed spans never calls `completed()`, so
its runner never settles and its `wrangler dev` would otherwise stay alive until
the Vitest process exits. A full run left 32 of them behind. Running the shared
cleanup instead would kill the worker the next test had already started. The
process-exit cleanup still covers every worker.
Renames `public-api/startSpan-streamed` to `public-api/startSpan`, and
`tracing/ignoreSpans-streamed` to `tracing/ignoreSpans`. Ports both suites onto
the helpers, which proves the shape before the bulk of the port. Span streaming
is the default, so a `-streamed` suffix no longer marks a difference, and the
explicit `traceLifecycle: 'stream'` those four suites carried says nothing
either. It goes with the suffix.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments