-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tracing): Add experiment to capture http timings (#8371)
This adds an experiment that will allow http timings to be captured. We currently capture timings on Sentry SaaS with some custom code and append them to the spans, which has been helpful to identify some performance problems that were previously hidden (http/1.1 stall time). Following this work we can add these to the waterfall to represent measurements as subtimings and will power an upcoming http/1.1 stall performance issue.
- Loading branch information
Showing
5 changed files
with
143 additions
and
8 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/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,17 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import { Integrations } from '@sentry/tracing'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
integrations: [ | ||
new Integrations.BrowserTracing({ | ||
idleTimeout: 1000, | ||
_experiments: { | ||
enableHTTPTimings: true, | ||
}, | ||
}), | ||
], | ||
tracesSampleRate: 1, | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/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 @@ | ||
fetch('http://example.com/0').then(fetch('http://example.com/1').then(fetch('http://example.com/2'))); |
50 changes: 50 additions & 0 deletions
50
packages/browser-integration-tests/suites/tracing/browsertracing/http-timings/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,50 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Event } from '@sentry/types'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
sentryTest('should create fetch spans with http timing', async ({ browserName, getLocalTestPath, page }) => { | ||
const supportedBrowsers = ['chromium', 'firefox']; | ||
|
||
if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) { | ||
sentryTest.skip(); | ||
} | ||
await page.route('http://example.com/*', async route => { | ||
const request = route.request(); | ||
const postData = await request.postDataJSON(); | ||
|
||
await route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify(Object.assign({ id: 1 }, postData)), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
const envelopes = await getMultipleSentryEnvelopeRequests<Event>(page, 2, { url, timeout: 10000 }); | ||
const tracingEvent = envelopes[envelopes.length - 1]; // last envelope contains tracing data on all browsers | ||
|
||
const requestSpans = tracingEvent.spans?.filter(({ op }) => op === 'http.client'); | ||
|
||
expect(requestSpans).toHaveLength(3); | ||
|
||
await page.pause(); | ||
requestSpans?.forEach((span, index) => | ||
expect(span).toMatchObject({ | ||
description: `GET http://example.com/${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: expect.objectContaining({ | ||
'http.request.connect_start': expect.any(Number), | ||
'http.request.request_start': expect.any(Number), | ||
'http.request.response_start': expect.any(Number), | ||
'network.protocol.version': 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