-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into lforst-nextjs-otel
- Loading branch information
Showing
14 changed files
with
312 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
10 changes: 10 additions & 0 deletions
10
...ages/browser-integration-tests/suites/tracing/trace-lifetime/trace-header-merging/init.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [Sentry.browserTracingIntegration()], | ||
tracePropagationTargets: ['http://example.com'], | ||
tracesSampleRate: 1, | ||
}); |
53 changes: 53 additions & 0 deletions
53
...s/browser-integration-tests/suites/tracing/trace-lifetime/trace-header-merging/subject.js
This file contains 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
fetchPojo.addEventListener('click', () => { | ||
const fetchOptions = { | ||
headers: { | ||
'sentry-trace': '12312012123120121231201212312012-1121201211212012-1', | ||
baggage: 'sentry-release=4.2.0', | ||
}, | ||
}; | ||
|
||
// Make two fetch requests that reuse the same fetch object | ||
Sentry.startSpan({ name: 'does-not-matter-1' }, () => | ||
fetch('http://example.com/fetch-pojo', fetchOptions) | ||
.then(res => res.text()) | ||
.then(() => | ||
Sentry.startSpan({ name: 'does-not-matter-2' }, () => fetch('http://example.com/fetch-pojo', fetchOptions)), | ||
), | ||
); | ||
}); | ||
|
||
fetchArray.addEventListener('click', () => { | ||
const fetchOptions = { | ||
headers: [ | ||
['sentry-trace', '12312012123120121231201212312012-1121201211212012-1'], | ||
['baggage', 'sentry-release=4.2.0'], | ||
], | ||
}; | ||
|
||
// Make two fetch requests that reuse the same fetch object | ||
Sentry.startSpan({ name: 'does-not-matter-1' }, () => | ||
fetch('http://example.com/fetch-array', fetchOptions) | ||
.then(res => res.text()) | ||
.then(() => | ||
Sentry.startSpan({ name: 'does-not-matter-2' }, () => fetch('http://example.com/fetch-array', fetchOptions)), | ||
), | ||
); | ||
}); | ||
|
||
fetchHeaders.addEventListener('click', () => { | ||
const fetchOptions = { | ||
headers: new Headers({ | ||
'sentry-trace': '12312012123120121231201212312012-1121201211212012-1', | ||
baggage: 'sentry-release=4.2.0', | ||
}), | ||
}; | ||
|
||
// Make two fetch requests that reuse the same fetch object | ||
Sentry.startSpan({ name: 'does-not-matter-1' }, () => | ||
fetch('http://example.com/fetch-headers', fetchOptions) | ||
.then(res => res.text()) | ||
.then(() => | ||
Sentry.startSpan({ name: 'does-not-matter-2' }, () => fetch('http://example.com/fetch-headers', fetchOptions)), | ||
), | ||
); | ||
}); |
11 changes: 11 additions & 0 deletions
11
...rowser-integration-tests/suites/tracing/trace-lifetime/trace-header-merging/template.html
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<button id="fetchPojo">Fetch POJO</button> | ||
<button id="fetchArray">Fetch array</button> | ||
<button id="fetchHeaders">Fetch Headers</button> | ||
</body> | ||
</html> |
64 changes: 64 additions & 0 deletions
64
...ages/browser-integration-tests/suites/tracing/trace-lifetime/trace-header-merging/test.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import type { Page, Request } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
async function assertRequests({ | ||
page, | ||
buttonSelector, | ||
requestMatcher, | ||
}: { page: Page; buttonSelector: string; requestMatcher: string }) { | ||
const requests = await new Promise<Request[]>(resolve => { | ||
const requests: Request[] = []; | ||
page | ||
.route(requestMatcher, (route, request) => { | ||
requests.push(request); | ||
if (requests.length === 2) { | ||
resolve(requests); | ||
} | ||
|
||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({}), | ||
}); | ||
}) | ||
.then(() => { | ||
page.click(buttonSelector); | ||
}); | ||
}); | ||
|
||
requests.forEach(request => { | ||
const headers = request.headers(); | ||
|
||
// No merged sentry trace headers | ||
expect(headers['sentry-trace']).not.toContain(','); | ||
|
||
// No multiple baggage entries | ||
expect(headers['baggage'].match(/sentry-trace_id/g) ?? []).toHaveLength(1); | ||
}); | ||
} | ||
|
||
sentryTest( | ||
'Ensure the SDK does not infinitely append tracing headers to outgoing requests', | ||
async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
await page.goto(url); | ||
|
||
await sentryTest.step('fetch with POJO', () => | ||
assertRequests({ page, buttonSelector: '#fetchPojo', requestMatcher: 'http://example.com/fetch-pojo' }), | ||
); | ||
|
||
await sentryTest.step('fetch with array', () => | ||
assertRequests({ page, buttonSelector: '#fetchArray', requestMatcher: 'http://example.com/fetch-array' }), | ||
); | ||
|
||
await sentryTest.step('fetch with Headers instance', () => | ||
assertRequests({ page, buttonSelector: '#fetchHeaders', requestMatcher: 'http://example.com/fetch-headers' }), | ||
); | ||
}, | ||
); |
This file contains 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 |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
"test:dev": "TEST_ENV=development playwright test", | ||
"test:build": "pnpm install && npx playwright install && pnpm build", | ||
"test:build-canary": "pnpm install && pnpm add next@canary && pnpm add react@beta && pnpm add react-dom@beta && npx playwright install && pnpm build", | ||
"test:build-latest": "pnpm install && pnpm add next@rc && pnpm add react@beta && pnpm add react-dom@beta && npx playwright install && pnpm build", | ||
"//": "15.0.0-canary.194 is the canary release attached to Next.js RC 1. We need to use the canary version instead of the RC because PPR will not work without. The specific react version is also attached to RC 1.", | ||
"test:build-latest": "pnpm install && pnpm add [email protected] && pnpm add [email protected] && pnpm add [email protected] && npx playwright install && pnpm build", | ||
"test:assert": "pnpm test:prod && pnpm test:dev" | ||
}, | ||
"dependencies": { | ||
|
This file contains 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 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
Oops, something went wrong.