MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / extractTraceparentData

Function extractTraceparentData

packages/core/src/utils/tracing.ts:31–53  ·  view source on GitHub ↗
(traceparent?: string)

Source from the content-addressed store, hash-verified

29 * @returns Object containing data from the header, or undefined if traceparent string is malformed
30 */
31export function extractTraceparentData(traceparent?: string): TraceparentData | undefined {
32 if (!traceparent) {
33 return undefined;
34 }
35
36 const matches = traceparent.match(TRACEPARENT_REGEXP);
37 if (!matches) {
38 return undefined;
39 }
40
41 let parentSampled: boolean | undefined;
42 if (matches[3] === '1') {
43 parentSampled = true;
44 } else if (matches[3] === '0') {
45 parentSampled = false;
46 }
47
48 return {
49 traceId: matches[1],
50 parentSampled,
51 parentSpanId: matches[2],
52 };
53}
54
55/**
56 * Create a propagation context from incoming headers or

Callers 15

tracing.test.tsFile · 0.90
renderMethod · 0.90
applyFunction · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90
test.tsFile · 0.90

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected