Skip to content

test(node): Fix flaky negative sampling (static) envelope ordering#22038

Merged
mydea merged 1 commit into
developfrom
fix/flaky-sampling-static-envelope-order
Jul 8, 2026
Merged

test(node): Fix flaky negative sampling (static) envelope ordering#22038
mydea merged 1 commit into
developfrom
fix/flaky-sampling-static-envelope-order

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The negative sampling (static) integration test (suites/tracing/sampling-static/test.ts) intermittently failed on CI with an envelope-ordering assertion error.

Root cause

The test used ordered envelope matching, expecting the GET /ok transaction to arrive before the client_report that records the negatively-sampled /health sample_rate outcome. These two envelopes originate from independent flush mechanisms:

  • The GET /ok transaction is transmitted as soon as its root span ends.
  • The discarded /health outcome only leaves the SDK via the client report flushed on clientReportFlushInterval (1000ms).

Because the flush timings are independent, their relative arrival order is racy. When the client-report interval fires after the /health outcome is recorded but before the /ok transaction is transmitted, the client_report arrives first and the ordered matcher throws Expected envelope item type 'transaction' but got 'client_report'.

Fix

Add .unordered() so envelope arrival order no longer matters. Both assertions (the transaction and the client_report) are still required to arrive and are checked exactly as before — only the strict sequencing is relaxed. This mirrors the pattern already used in tracing/postgresjs, tracing/apollo-graphql, and express/handle-error.

Fixes #21990

@github-actions github-actions Bot requested a review from a team as a code owner July 8, 2026 07:39
@github-actions github-actions Bot requested review from JPeer264, andreiborza and mydea and removed request for a team July 8, 2026 07:39
@mydea mydea enabled auto-merge (squash) July 8, 2026 07:41
@mydea mydea merged commit f642455 into develop Jul 8, 2026
57 checks passed
@mydea mydea deleted the fix/flaky-sampling-static-envelope-order branch July 8, 2026 08:02
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.

[Flaky CI]: Node Integration Tests - suites/tracing/sampling-static/test.ts > negative sampling (static)

2 participants