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(tracing): Handle incoming tracestate data, allow for third-party data#3275
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
da6fccfae47cea52f6d98ab72f62934be6891fda65269a678f6fadf881c619333290adf46c8c406e8d3be5cea2eFile 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 |
|---|---|---|
| @@ -5,7 +5,7 @@ import { getGlobalObject, logger } from '@sentry/utils'; | ||
| import { startIdleTransaction } from '../hubextensions'; | ||
| import { DEFAULT_IDLE_TIMEOUT, IdleTransaction } from '../idletransaction'; | ||
| import { SpanStatus } from '../spanstatus'; | ||
| import { extractTraceparentData, secToMs } from '../utils'; | ||
| import { extractSentrytraceData, extractTracestateData, secToMs } from '../utils'; | ||
| import { registerBackgroundTabDetection } from './backgroundtab'; | ||
| import { MetricsInstrumentation } from './metrics'; | ||
| import { | ||
| @@ -191,7 +191,7 @@ export class BrowserTracing implements Integration { | ||
| // eslint-disable-next-line @typescript-eslint/unbound-method | ||
| const { beforeNavigate, idleTimeout, maxTransactionDuration } = this.options; | ||
| const parentContextFromHeader = context.op === 'pageload' ? getHeaderContext() : undefined; | ||
| const parentContextFromHeader = context.op === 'pageload' ? extractTraceDataFromMetaTags() : undefined; | ||
| const expandedContext = { | ||
| ...context, | ||
| @@ -230,14 +230,22 @@ export class BrowserTracing implements Integration { | ||
| } | ||
| /** | ||
| * Gets transaction context from a sentry-tracemeta. | ||
| * Gets transaction context data from `sentry-trace` and `tracestate` <meta> tags. | ||
| * | ||
| * @returns Transaction context data from the header or undefined if there's no header or the header is malformed | ||
| * @returns Transaction context data or undefined neither tag exists or has valid data | ||
| */ | ||
| export function getHeaderContext(): Partial<TransactionContext> | undefined { | ||
| const header = getMetaContent('sentry-trace'); | ||
| if (header) { | ||
| return extractTraceparentData(header); | ||
| export function extractTraceDataFromMetaTags(): Partial<TransactionContext> | undefined { | ||
| const sentrytraceValue = getMetaContent('sentry-trace'); | ||
| const tracestateValue = getMetaContent('tracestate'); | ||
| const sentrytraceData = sentrytraceValue ? extractSentrytraceData(sentrytraceValue) : undefined; | ||
| const tracestateData = tracestateValue ? extractTracestateData(tracestateValue) : undefined; | ||
| if (sentrytraceData || tracestateData?.sentry || tracestateData?.thirdparty) { | ||
| ||
| return { | ||
| ...sentrytraceData, | ||
| ...(tracestateData && { metadata: { tracestate: tracestateData } }), | ||
| }; | ||
| } | ||
| return undefined; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.