-
-
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.
Closes #11632
- Loading branch information
Showing
13 changed files
with
278 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,7 +208,7 @@ module.exports = [ | |
'tls', | ||
], | ||
gzip: true, | ||
limit: '150 KB', | ||
limit: '160 KB', | ||
}, | ||
]; | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/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,9 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [Sentry.browserTracingIntegration()], | ||
tracesSampleRate: 1, | ||
}); |
3 changes: 3 additions & 0 deletions
3
dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/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,3 @@ | ||
fetch('/test-req/0').then( | ||
fetch('/test-req/1', { headers: { 'X-Test-Header': 'existing-header' } }).then(fetch('/test-req/2')), | ||
); |
79 changes: 79 additions & 0 deletions
79
dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/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,79 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { TEST_HOST, sentryTest } from '../../../../utils/fixtures'; | ||
import { | ||
envelopeRequestParser, | ||
shouldSkipTracingTest, | ||
waitForTransactionRequestOnUrl, | ||
} from '../../../../utils/helpers'; | ||
|
||
sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
const req = await waitForTransactionRequestOnUrl(page, url); | ||
const tracingEvent = envelopeRequestParser(req); | ||
|
||
const requestSpans = tracingEvent.spans?.filter(({ op }) => op === 'http.client'); | ||
|
||
expect(requestSpans).toHaveLength(3); | ||
|
||
requestSpans?.forEach((span, index) => | ||
expect(span).toMatchObject({ | ||
description: `GET /test-req/${index}`, | ||
parent_span_id: tracingEvent.contexts?.trace?.span_id, | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: tracingEvent.contexts?.trace?.trace_id, | ||
data: { | ||
'http.method': 'GET', | ||
'http.url': `${TEST_HOST}/test-req/${index}`, | ||
url: `/test-req/${index}`, | ||
'server.address': 'sentry-test.io', | ||
type: 'fetch', | ||
}, | ||
}), | ||
); | ||
}); | ||
|
||
sentryTest('should attach `sentry-trace` header to fetch requests', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
const requests = ( | ||
await Promise.all([ | ||
page.goto(url), | ||
Promise.all([0, 1, 2].map(idx => page.waitForRequest(`${TEST_HOST}/test-req/${idx}`))), | ||
]) | ||
)[1]; | ||
|
||
expect(requests).toHaveLength(3); | ||
|
||
const request1 = requests[0]; | ||
const requestHeaders1 = request1.headers(); | ||
expect(requestHeaders1).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
}); | ||
|
||
const request2 = requests[1]; | ||
const requestHeaders2 = request2.headers(); | ||
expect(requestHeaders2).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
'x-test-header': 'existing-header', | ||
}); | ||
|
||
const request3 = requests[2]; | ||
const requestHeaders3 = request3.headers(); | ||
expect(requestHeaders3).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
}); | ||
}); |
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
9 changes: 9 additions & 0 deletions
9
dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/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,9 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [Sentry.browserTracingIntegration()], | ||
tracesSampleRate: 1, | ||
}); |
12 changes: 12 additions & 0 deletions
12
dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/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,12 @@ | ||
const xhr_1 = new XMLHttpRequest(); | ||
xhr_1.open('GET', '/test-req/0'); | ||
xhr_1.send(); | ||
|
||
const xhr_2 = new XMLHttpRequest(); | ||
xhr_2.open('GET', '/test-req/1'); | ||
xhr_2.setRequestHeader('X-Test-Header', 'existing-header'); | ||
xhr_2.send(); | ||
|
||
const xhr_3 = new XMLHttpRequest(); | ||
xhr_3.open('GET', '/test-req/2'); | ||
xhr_3.send(); |
79 changes: 79 additions & 0 deletions
79
dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/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,79 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { TEST_HOST, sentryTest } from '../../../../utils/fixtures'; | ||
import { | ||
envelopeRequestParser, | ||
shouldSkipTracingTest, | ||
waitForTransactionRequestOnUrl, | ||
} from '../../../../utils/helpers'; | ||
|
||
sentryTest('should create spans for xhr requests', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
const req = await waitForTransactionRequestOnUrl(page, url); | ||
const tracingEvent = envelopeRequestParser(req); | ||
|
||
const requestSpans = tracingEvent.spans?.filter(({ op }) => op === 'http.client'); | ||
|
||
expect(requestSpans).toHaveLength(3); | ||
|
||
requestSpans?.forEach((span, index) => | ||
expect(span).toMatchObject({ | ||
description: `GET /test-req/${index}`, | ||
parent_span_id: tracingEvent.contexts?.trace?.span_id, | ||
span_id: expect.any(String), | ||
start_timestamp: expect.any(Number), | ||
timestamp: expect.any(Number), | ||
trace_id: tracingEvent.contexts?.trace?.trace_id, | ||
data: { | ||
'http.method': 'GET', | ||
'http.url': `${TEST_HOST}/test-req/${index}`, | ||
url: `/test-req/${index}`, | ||
'server.address': 'sentry-test.io', | ||
type: 'xhr', | ||
}, | ||
}), | ||
); | ||
}); | ||
|
||
sentryTest('should attach `sentry-trace` header to xhr requests', async ({ getLocalTestUrl, page }) => { | ||
if (shouldSkipTracingTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
const requests = ( | ||
await Promise.all([ | ||
page.goto(url), | ||
Promise.all([0, 1, 2].map(idx => page.waitForRequest(`${TEST_HOST}/test-req/${idx}`))), | ||
]) | ||
)[1]; | ||
|
||
expect(requests).toHaveLength(3); | ||
|
||
const request1 = requests[0]; | ||
const requestHeaders1 = request1.headers(); | ||
expect(requestHeaders1).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
}); | ||
|
||
const request2 = requests[1]; | ||
const requestHeaders2 = request2.headers(); | ||
expect(requestHeaders2).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
'x-test-header': 'existing-header', | ||
}); | ||
|
||
const request3 = requests[2]; | ||
const requestHeaders3 = request3.headers(); | ||
expect(requestHeaders3).toMatchObject({ | ||
'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), | ||
baggage: expect.any(String), | ||
}); | ||
}); |
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
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.