next.js
f5fad055 - test: reduce flakiness in opentelemetry test for prod mode (#88102)

Commit
20 days ago
test: reduce flakiness in opentelemetry test for prod mode (#88102) ## Summary Reduces flakiness in the OpenTelemetry e2e test (`test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts`) for production mode. ### Root Cause In production mode, Next.js generates additional spans from: - RSC prefetch requests (with `?_rsc` query param) - Edge runtime boundary spans These extra root spans cause `toMatchObject` assertions to fail because they receive more spans than expected. ### Changes 1. **Filter spans by expected `http.target`** in `expectTrace()`: - Extract expected `http.target` values from the match object - Filter root spans to only include those with matching targets - This excludes RSC prefetch and edge boundary spans that aren't part of the test assertion 2. **Fix TestExporter callback bug** in `instrumentation-test.ts`: - The success callback was called unconditionally (even after errors) - Added early `return` after error callback - Moved success callback inside the success path ## Test Plan - [x] All 34 tests pass in production mode (`NEXT_TEST_MODE=start`) - [ ] CI passes
Author
Committer
Parents
Loading