-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(e2e): Port the create-remix-app-v2-non-vite E2E app to span streaming #24063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andreiborza
merged 2 commits into
develop
from
ab/e2e-create-remix-app-v2-non-vite-streaming
Sep 4, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
1 change: 0 additions & 1 deletion
1
dev-packages/e2e-tests/test-applications/create-remix-app-v2-non-vite/instrument.server.cjs
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
52 changes: 23 additions & 29 deletions
52
...2e-tests/test-applications/create-remix-app-v2-non-vite/tests/client-transactions.test.ts
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
94 changes: 50 additions & 44 deletions
94
...2e-tests/test-applications/create-remix-app-v2-non-vite/tests/server-transactions.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,64 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import { waitForTransaction } from '@sentry-internal/test-utils'; | ||
| import type { SerializedStreamedSpan } from '@sentry-internal/test-utils'; | ||
| import { getSpanOp, waitForStreamedSpan, waitForStreamedSpans } from '@sentry-internal/test-utils'; | ||
|
|
||
| const APP_NAME = 'create-remix-app-v2-non-vite'; | ||
|
|
||
| test.describe.configure({ mode: 'serial' }); | ||
|
|
||
| test('Sends parameterized transaction name to Sentry', async ({ page }) => { | ||
| const transactionPromise = waitForTransaction('create-remix-app-v2-non-vite', transactionEvent => { | ||
| return transactionEvent.contexts?.trace?.op === 'http.server'; | ||
| test('Sends a parameterized span name to Sentry', async ({ page }) => { | ||
| const spanPromise = waitForStreamedSpan(APP_NAME, span => { | ||
| return getSpanOp(span) === 'http.server' && span.is_segment && span.name === 'GET user/:id'; | ||
| }); | ||
|
|
||
| await page.goto('/user/123'); | ||
|
|
||
| const transaction = await transactionPromise; | ||
| const span = await spanPromise; | ||
|
|
||
| expect(transaction).toBeDefined(); | ||
| expect(transaction.transaction).toBe('GET user/:id'); | ||
| expect(span.attributes['http.route']?.value).toBe('user/:id'); | ||
| }); | ||
|
|
||
| test('Sends two linked transactions (server & client) to Sentry', async ({ page }) => { | ||
| // We use this to identify the transactions | ||
| const testTag = crypto.randomUUID(); | ||
|
|
||
| const httpServerTransactionPromise = waitForTransaction('create-remix-app-v2-non-vite', transactionEvent => { | ||
| return transactionEvent.contexts?.trace?.op === 'http.server' && transactionEvent.tags?.['sentry_test'] === testTag; | ||
| }); | ||
|
|
||
| const pageLoadTransactionPromise = waitForTransaction('create-remix-app-v2-non-vite', transactionEvent => { | ||
| return transactionEvent.contexts?.trace?.op === 'pageload' && transactionEvent.tags?.['sentry_test'] === testTag; | ||
| test('Sends two linked spans (server & client) to Sentry', async ({ page }) => { | ||
| // Streamed spans are buffered before they flush, so spans from an earlier page load can still be | ||
| // arriving here. The document advertises its own trace in the `sentry-trace` meta tag, so that is | ||
| // what tells this page load's spans apart rather than the op or the URL. | ||
| const streamedSpans: SerializedStreamedSpan[] = []; | ||
| void waitForStreamedSpans(APP_NAME, spans => { | ||
| streamedSpans.push(...spans); | ||
| return false; | ||
| }); | ||
|
|
||
| page.goto(`/?tag=${testTag}`); | ||
|
|
||
| const pageloadTransaction = await pageLoadTransactionPromise; | ||
| const httpServerTransaction = await httpServerTransactionPromise; | ||
|
|
||
| expect(pageloadTransaction).toBeDefined(); | ||
| expect(httpServerTransaction).toBeDefined(); | ||
|
|
||
| const httpServerTraceId = httpServerTransaction.contexts?.trace?.trace_id; | ||
| const httpServerSpanId = httpServerTransaction.contexts?.trace?.span_id; | ||
| const loaderSpanId = httpServerTransaction?.spans?.find( | ||
| span => span.data && span.data['code.function.name'] === 'loader', | ||
| )?.span_id; | ||
|
|
||
| const pageLoadTraceId = pageloadTransaction.contexts?.trace?.trace_id; | ||
| const pageLoadSpanId = pageloadTransaction.contexts?.trace?.span_id; | ||
| const pageLoadParentSpanId = pageloadTransaction.contexts?.trace?.parent_span_id; | ||
|
|
||
| expect(httpServerTransaction.transaction).toBe('GET /'); | ||
| expect(pageloadTransaction.transaction).toBe('routes/_index'); | ||
|
|
||
| expect(httpServerTraceId).toBeDefined(); | ||
| expect(httpServerSpanId).toBeDefined(); | ||
|
|
||
| expect(pageLoadTraceId).toEqual(httpServerTraceId); | ||
| expect(pageLoadParentSpanId).toEqual(loaderSpanId); | ||
| expect(pageLoadSpanId).not.toEqual(httpServerSpanId); | ||
| await page.goto('/'); | ||
|
|
||
| // Remix injects the meta tag from inside the root loader, so the span it names is the loader span. | ||
| const sentryTrace = await page.getAttribute('meta[name="sentry-trace"]', 'content'); | ||
| const [traceId, loaderSpanId] = (sentryTrace ?? '').split('-'); | ||
| expect(traceId).toMatch(/^[a-f0-9]{32}$/); | ||
| expect(loaderSpanId).toMatch(/^[a-f0-9]{16}$/); | ||
|
|
||
| // The client continues the server trace, so its pageload span hangs off the span the meta tag | ||
| // names. Selecting it that way, rather than by op, is what makes the trace assertion below mean | ||
| // something: a pageload that failed to continue the trace would have no parent at all. | ||
| const findPageloadSpan = () => | ||
| streamedSpans.find( | ||
| span => getSpanOp(span) === 'pageload' && span.is_segment && span.parent_span_id === loaderSpanId, | ||
| ); | ||
| await expect.poll(findPageloadSpan).toBeDefined(); | ||
| expect(findPageloadSpan()!.trace_id).toBe(traceId); | ||
| expect(findPageloadSpan()!.name).toBe('routes/_index'); | ||
|
|
||
| const findServerSegmentSpan = () => | ||
| streamedSpans.find(span => getSpanOp(span) === 'http.server' && span.is_segment && span.trace_id === traceId); | ||
| await expect.poll(findServerSegmentSpan).toBeDefined(); | ||
| const serverSegmentSpan = findServerSegmentSpan()!; | ||
|
|
||
| // The index route has no path of its own, so the segment keeps the low-cardinality method-only | ||
| // name it starts with. | ||
| expect(serverSegmentSpan.name).toBe('GET'); | ||
| expect(findPageloadSpan()!.span_id).not.toBe(serverSegmentSpan.span_id); | ||
|
|
||
| const findLoaderSpan = () => streamedSpans.find(span => span.span_id === loaderSpanId); | ||
| await expect.poll(findLoaderSpan).toBeDefined(); | ||
| expect(findLoaderSpan()!.attributes['code.function.name']?.value).toBe('loader'); | ||
| expect(findLoaderSpan()!.parent_span_id).toBe(serverSegmentSpan.span_id); | ||
| }); | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.