-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Changes from all commits
da6fccf
ae47cea
52f6d98
ab72f62
934be68
91fda65
269a678
f6fadf8
81c6193
33290ad
f46c8c4
06e8d3b
e5cea2e
File filter
Filter by extension
Conversations
Jump to
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-trace meta. | ||
* 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) { | ||
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.
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. But |
||
return { | ||
...sentrytraceData, | ||
...(tracestateData && { metadata: { tracestate: tracestateData } }), | ||
}; | ||
} | ||
|
||
return undefined; | ||
|
Uh oh!
There was an error while loading. Please reload this page.