Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core)!: Enable span streaming by default#22642
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,21 @@ | ||
| import { expect } from '@playwright/test'; | ||
| import { sentryTest } from '../../../../utils/fixtures'; | ||
| import { | ||
| envelopeRequestParser, | ||
| shouldSkipTracingTest, | ||
| waitForTransactionRequestOnUrl, | ||
| } from '../../../../utils/helpers'; | ||
| import { shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
| import { getSpanOp, waitForStreamedSpan } from '../../../../utils/spanUtils'; | ||
| sentryTest('should create a pageload transaction', async ({ getLocalTestUrl, page }) => { | ||
| sentryTest('should create a pageload span', async ({ getLocalTestUrl, page }) => { | ||
| if (shouldSkipTracingTest()) { | ||
| sentryTest.skip(); | ||
| } | ||
| const spanPromise = waitForStreamedSpan(page, s => getSpanOp(s) === 'pageload'); | ||
| const url = await getLocalTestUrl({ testDir: __dirname }); | ||
| const req = await waitForTransactionRequestOnUrl(page, url); | ||
| await page.goto(url); | ||
| const pageloadSpan = await spanPromise; | ||
| const eventData = envelopeRequestParser(req); | ||
| const timeOrigin = await page.evaluate<number>('window._testBaseTimestamp'); | ||
| const { start_timestamp: startTimestamp } = eventData; | ||
| expect(pageloadSpan.start_timestamp).toBeCloseTo(timeOrigin, 1); | ||
| expect(startTimestamp).toBeCloseTo(timeOrigin, 1); | ||
| expect(eventData.contexts?.trace?.op).toBe('pageload'); | ||
| expect(eventData.spans?.length).toBeGreaterThan(0); | ||
| expect(eventData.transaction_info?.source).toEqual('url'); | ||
| expect(pageloadSpan.attributes?.['sentry.segment.name.source'].value).toEqual('url'); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,6 +9,7 @@ | ||
| "SENTRY_ENVIRONMENT": "qa", | ||
| "SENTRY_TRACES_SAMPLE_RATE": "1.0", | ||
| "SENTRY_TUNNEL": "http://localhost:3031/", | ||
| "SENTRY_TRACE_LIFECYCLE": "static", | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SDK for Astro 3-5 on cloudflare can only be configured via env variables (known issue, see docs). This makes opt-out less intuitive (but still possible). Astro 6 again pulls in the correct | ||
| }, | ||
| "assets": { | ||
| "binding": "ASSETS", | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AWS Lambda layer is another case where the opt-out must happen via env variables, as long as users use the auto init. I think this is a fair tradeoff. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -14,16 +14,6 @@ export const spanStreamingIntegration = defineIntegration(() => { | ||
| return { | ||
| name: 'SpanStreaming' as const, | ||
| beforeSetup(client) { | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| // If users only set spanStreamingIntegration, without traceLifecycle, we set it to "stream" for them. | ||
| // This avoids the classic double-opt-in problem we'd otherwise have in the browser SDK. | ||
| const clientOptions = client.getOptions(); | ||
| if (!clientOptions.traceLifecycle) { | ||
| DEBUG_BUILD && debug.log('[SpanStreaming] setting `traceLifecycle` to "stream"'); | ||
| clientOptions.traceLifecycle = 'stream'; | ||
| } | ||
| }, | ||
| setup(client) { | ||
| const initialMessage = 'SpanStreaming integration requires'; | ||
| const fallbackMsg = 'Falling back to static trace lifecycle.'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,6 +19,7 @@ import { globalHandlersIntegration } from './integrations/globalhandlers'; | ||
| import { httpContextIntegration } from './integrations/httpcontext'; | ||
| import { linkedErrorsIntegration } from './integrations/linkederrors'; | ||
| import { spotlightBrowserIntegration } from './integrations/spotlight'; | ||
| import { spanStreamingIntegration } from './integrations/spanstreaming'; | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import { defaultStackParser } from './stack-parsers'; | ||
| import { makeFetchTransport } from './transports/fetch'; | ||
| import { normalizeStringifyValue } from './normalizeStringifyValue'; | ||
| @@ -110,14 +111,22 @@ export function init(options: BrowserOptions = {}): Client | undefined { | ||
| } | ||
| /*! rollup-include-development-only-end */ | ||
| const integrations = getIntegrationsToSetup({ | ||
| integrations: options.integrations, | ||
| defaultIntegrations, | ||
| }); | ||
| options.traceLifecycle ??= 'stream'; | ||
| if (options.traceLifecycle === 'stream' && !integrations.some(integration => integration.name === 'SpanStreaming')) { | ||
| integrations.push(spanStreamingIntegration()); | ||
| } | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| const clientOptions: BrowserClientOptions = { | ||
| ...options, | ||
| enabled: shouldDisableBecauseIsBrowserExtenstion ? false : options.enabled, | ||
| stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), | ||
| integrations: getIntegrationsToSetup({ | ||
| integrations: options.integrations, | ||
| defaultIntegrations, | ||
| }), | ||
| integrations, | ||
| transport: options.transport || makeFetchTransport, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,6 +27,7 @@ export function createSentryInstance( | ||
| dsn: 'https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737', | ||
| tracesSampleRate: 1, | ||
| traceLifecycle: 'static', | ||
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. decided to keep bundler plugins' trace lifecycle static as well. We can opt into streaming in a separate PR. This is an interesting case because traces in the plugin have higher chance of actually getting streamed due to the longer execution time. | ||
| sampleRate: 1, | ||
| release: LIB_VERSION, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -234,7 +234,7 @@ export abstract class Client<O extends ClientOptions = ClientOptions> { | ||
| * @param options Options for the client. | ||
| */ | ||
| protected constructor(options: O) { | ||
| this._options = { attachStacktrace: true, ...options }; | ||
| this._options = { attachStacktrace: true, traceLifecycle: 'stream', ...options }; | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| this._integrations = {}; | ||
| this._numProcessing = 0; | ||
| this._outcomes = {}; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to migrate this test to span streaming since it specifically tests the
Sentry.init-less loader setup. In this case, the default will be span streaming. The only way to opt-out of it would be to callSentry.initinonload. Doing this in this test would defeat the purpose of thenoOnloadtest scenario 😅