@sentry/opentelemetry 8.6.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +59 -33
- package/cjs/index.js.map +1 -1
- package/esm/index.js +61 -35
- package/esm/index.js.map +1 -1
- package/package.json +14 -14
- package/types/instrumentation.d.ts +2 -2
- package/types/instrumentation.d.ts.map +1 -1
- package/types/propagator.d.ts +1 -1
- package/types/propagator.d.ts.map +1 -1
- package/types/setupEventContextTrace.d.ts.map +1 -1
- package/types/spanExporter.d.ts.map +1 -1
- package/types/trace.d.ts.map +1 -1
- package/types/utils/parseSpanDescription.d.ts.map +1 -1
- package/types-ts3.8/instrumentation.d.ts +2 -2
- package/types-ts3.8/propagator.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { _optionalChain } from '@sentry/utils';
|
|
|
2
2
|
import { SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, SEMATTRS_DB_SYSTEM, SEMATTRS_RPC_SERVICE, SEMATTRS_MESSAGING_SYSTEM, SEMATTRS_FAAS_TRIGGER, SEMATTRS_DB_STATEMENT, SEMATTRS_HTTP_TARGET, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_RPC_GRPC_STATUS_CODE } from '@opentelemetry/semantic-conventions';
|
|
3
3
|
import { parseUrl, getSanitizedUrlString, addNonEnumerableProperty, baggageHeaderToDynamicSamplingContext, stripUrlQueryAndFragment, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, propagationContextFromHeaders, stringMatchesSomePattern, dynamicSamplingContextToSentryBaggageHeader, dropUndefinedKeys } from '@sentry/utils';
|
|
4
4
|
import * as api from '@opentelemetry/api';
|
|
5
|
-
import { trace, SpanKind, createContextKey, TraceFlags, propagation, context, SpanStatusCode, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
|
|
6
|
-
import { SDK_VERSION, getClient, getDynamicSamplingContextFromClient, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, isSentryRequestUrl, getCurrentScope, getIsolationScope, hasTracingEnabled, getRootSpan, spanToJSON, handleCallbackErrors,
|
|
5
|
+
import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, INVALID_SPANID, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
|
|
6
|
+
import { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, getClient, getDynamicSamplingContextFromClient, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, isSentryRequestUrl, getCurrentScope, getIsolationScope, hasTracingEnabled, getRootSpan, spanToJSON, handleCallbackErrors, continueTrace as continueTrace$1, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, getCapturedScopesOnSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getStatusMessage, getMetricSummaryJsonForSpan, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, sampleSpan } from '@sentry/core';
|
|
7
7
|
export { getClient, getCurrentHubShim } from '@sentry/core';
|
|
8
8
|
import { W3CBaggagePropagator, isTracingSuppressed, TraceState, suppressTracing as suppressTracing$1 } from '@opentelemetry/core';
|
|
9
9
|
import { SamplingDecision } from '@opentelemetry/sdk-trace-base';
|
|
@@ -117,7 +117,7 @@ function getRequestSpanData(span) {
|
|
|
117
117
|
return data;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
function _optionalChain$
|
|
120
|
+
function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
121
121
|
|
|
122
122
|
// Typescript complains if we do not use `...args: any[]` for the mixin, with:
|
|
123
123
|
// A mixin class must have a constructor with a single rest parameter of type 'any[]'.ts(2545)
|
|
@@ -158,7 +158,7 @@ function wrapClientClass
|
|
|
158
158
|
*/
|
|
159
159
|
async flush(timeout) {
|
|
160
160
|
const provider = this.traceProvider;
|
|
161
|
-
const spanProcessor = _optionalChain$
|
|
161
|
+
const spanProcessor = _optionalChain$9([provider, 'optionalAccess', _ => _.activeSpanProcessor]);
|
|
162
162
|
|
|
163
163
|
if (spanProcessor) {
|
|
164
164
|
await spanProcessor.forceFlush();
|
|
@@ -236,7 +236,7 @@ function getContextFromScope(scope) {
|
|
|
236
236
|
return (scope )[SCOPE_CONTEXT_FIELD];
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
function _optionalChain$
|
|
239
|
+
function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
240
240
|
|
|
241
241
|
/**
|
|
242
242
|
* OpenTelemetry only knows about SAMPLED or NONE decision,
|
|
@@ -266,10 +266,10 @@ function getSamplingDecision(spanContext) {
|
|
|
266
266
|
const dscString = traceState ? traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;
|
|
267
267
|
const dsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;
|
|
268
268
|
|
|
269
|
-
if (_optionalChain$
|
|
269
|
+
if (_optionalChain$8([dsc, 'optionalAccess', _ => _.sampled]) === 'true') {
|
|
270
270
|
return true;
|
|
271
271
|
}
|
|
272
|
-
if (_optionalChain$
|
|
272
|
+
if (_optionalChain$8([dsc, 'optionalAccess', _2 => _2.sampled]) === 'false') {
|
|
273
273
|
return false;
|
|
274
274
|
}
|
|
275
275
|
|
|
@@ -294,9 +294,14 @@ function parseSpanDescription(span) {
|
|
|
294
294
|
return descriptionForHttpMethod({ attributes, name, kind: getSpanKind(span) }, httpMethod);
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
// If db.type exists then this is a database call span.
|
|
298
297
|
const dbSystem = attributes[SEMATTRS_DB_SYSTEM];
|
|
299
|
-
|
|
298
|
+
const opIsCache =
|
|
299
|
+
typeof attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'string' &&
|
|
300
|
+
attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP].startsWith('cache.');
|
|
301
|
+
|
|
302
|
+
// If db.type exists then this is a database call span
|
|
303
|
+
// If the Redis DB is used as a cache, the span description should not be changed
|
|
304
|
+
if (dbSystem && !opIsCache) {
|
|
300
305
|
return descriptionForDbSystem({ attributes, name });
|
|
301
306
|
}
|
|
302
307
|
|
|
@@ -425,7 +430,7 @@ function getSanitizedUrl(
|
|
|
425
430
|
return { urlPath: undefined, url, query, fragment, hasRoute: false };
|
|
426
431
|
}
|
|
427
432
|
|
|
428
|
-
function _optionalChain$
|
|
433
|
+
function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
429
434
|
/**
|
|
430
435
|
* Creates a dynamic sampling context from a span (and client and scope)
|
|
431
436
|
*
|
|
@@ -440,7 +445,7 @@ function getDynamicSamplingContextFromSpan(span) {
|
|
|
440
445
|
}
|
|
441
446
|
|
|
442
447
|
const traceState = span.spanContext().traceState;
|
|
443
|
-
const traceStateDsc = _optionalChain$
|
|
448
|
+
const traceStateDsc = _optionalChain$7([traceState, 'optionalAccess', _ => _.get, 'call', _2 => _2(SENTRY_TRACE_STATE_DSC)]);
|
|
444
449
|
|
|
445
450
|
// If the span has a DSC, we want it to take precedence
|
|
446
451
|
const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;
|
|
@@ -525,7 +530,7 @@ function setIsSetup(element) {
|
|
|
525
530
|
setupElements.add(element);
|
|
526
531
|
}
|
|
527
532
|
|
|
528
|
-
function _optionalChain$
|
|
533
|
+
function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
529
534
|
|
|
530
535
|
/** Get the Sentry propagation context from a span context. */
|
|
531
536
|
function getPropagationContextFromSpan(span) {
|
|
@@ -537,7 +542,7 @@ function getPropagationContextFromSpan(span) {
|
|
|
537
542
|
const dscString = traceState ? traceState.get(SENTRY_TRACE_STATE_DSC) : undefined;
|
|
538
543
|
const traceStateDsc = dscString ? baggageHeaderToDynamicSamplingContext(dscString) : undefined;
|
|
539
544
|
|
|
540
|
-
const parentSpanId = traceState ? traceState.get(SENTRY_TRACE_STATE_PARENT_SPAN_ID) : undefined;
|
|
545
|
+
const parentSpanId = traceState ? traceState.get(SENTRY_TRACE_STATE_PARENT_SPAN_ID) || undefined : undefined;
|
|
541
546
|
|
|
542
547
|
const sampled = getSamplingDecision(spanContext);
|
|
543
548
|
|
|
@@ -579,7 +584,7 @@ class SentryPropagator extends W3CBaggagePropagator {
|
|
|
579
584
|
const activeSpan = trace.getSpan(context);
|
|
580
585
|
const url = activeSpan && getCurrentURL(activeSpan);
|
|
581
586
|
|
|
582
|
-
const tracePropagationTargets = _optionalChain$
|
|
587
|
+
const tracePropagationTargets = _optionalChain$6([getClient, 'call', _ => _(), 'optionalAccess', _2 => _2.getOptions, 'call', _3 => _3(), 'optionalAccess', _4 => _4.tracePropagationTargets]);
|
|
583
588
|
if (
|
|
584
589
|
typeof url === 'string' &&
|
|
585
590
|
tracePropagationTargets &&
|
|
@@ -618,7 +623,7 @@ class SentryPropagator extends W3CBaggagePropagator {
|
|
|
618
623
|
}
|
|
619
624
|
|
|
620
625
|
// We also want to avoid setting the default OTEL trace ID, if we get that for whatever reason
|
|
621
|
-
if (traceId && traceId !==
|
|
626
|
+
if (traceId && traceId !== INVALID_TRACEID) {
|
|
622
627
|
setter.set(carrier, SENTRY_TRACE_HEADER, generateSentryTraceHeader(traceId, spanId, sampled));
|
|
623
628
|
}
|
|
624
629
|
|
|
@@ -686,16 +691,14 @@ function makeTraceState({
|
|
|
686
691
|
}
|
|
687
692
|
|
|
688
693
|
) {
|
|
689
|
-
if (!parentSpanId && !dsc && sampled !== false) {
|
|
690
|
-
return undefined;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
694
|
// We store the DSC as OTEL trace state on the span context
|
|
694
695
|
const dscString = dsc ? dynamicSamplingContextToSentryBaggageHeader(dsc) : undefined;
|
|
695
696
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
// We _always_ set the parent span ID, even if it is empty
|
|
698
|
+
// If we'd set this to 'undefined' we could not know if the trace state was set, but there was no parentSpanId,
|
|
699
|
+
// vs the trace state was not set at all (in which case we want to do fallback handling)
|
|
700
|
+
// If `''`, it should be considered "no parent"
|
|
701
|
+
const traceStateBase = new TraceState().set(SENTRY_TRACE_STATE_PARENT_SPAN_ID, parentSpanId || '');
|
|
699
702
|
|
|
700
703
|
const traceStateWithDsc = dscString ? traceStateBase.set(SENTRY_TRACE_STATE_DSC, dscString) : traceStateBase;
|
|
701
704
|
|
|
@@ -708,7 +711,7 @@ function getInjectionData(context)
|
|
|
708
711
|
|
|
709
712
|
{
|
|
710
713
|
const span = hasTracingEnabled() ? trace.getSpan(context) : undefined;
|
|
711
|
-
const spanIsRemote = _optionalChain$
|
|
714
|
+
const spanIsRemote = _optionalChain$6([span, 'optionalAccess', _5 => _5.spanContext, 'call', _6 => _6(), 'access', _7 => _7.isRemote]);
|
|
712
715
|
|
|
713
716
|
// If we have a local span, we can just pick everything from it
|
|
714
717
|
if (span && !spanIsRemote) {
|
|
@@ -725,7 +728,7 @@ function getInjectionData(context)
|
|
|
725
728
|
}
|
|
726
729
|
|
|
727
730
|
// Else we try to use the propagation context from the scope
|
|
728
|
-
const scope = _optionalChain$
|
|
731
|
+
const scope = _optionalChain$6([getScopesFromContext, 'call', _8 => _8(context), 'optionalAccess', _9 => _9.scope]) || getCurrentScope();
|
|
729
732
|
|
|
730
733
|
const propagationContext = scope.getPropagationContext();
|
|
731
734
|
const dynamicSamplingContext = getDynamicSamplingContext(propagationContext, propagationContext.traceId);
|
|
@@ -743,7 +746,7 @@ function getDynamicSamplingContext(
|
|
|
743
746
|
traceId,
|
|
744
747
|
) {
|
|
745
748
|
// If we have a DSC on the propagation context, we just use it
|
|
746
|
-
if (_optionalChain$
|
|
749
|
+
if (_optionalChain$6([propagationContext, 'optionalAccess', _10 => _10.dsc])) {
|
|
747
750
|
return propagationContext.dsc;
|
|
748
751
|
}
|
|
749
752
|
|
|
@@ -815,13 +818,13 @@ function getExistingBaggage(carrier) {
|
|
|
815
818
|
* 2. Else, if the active span has no URL attribute (e.g. it is unsampled), we check a special trace state (which we set in our sampler).
|
|
816
819
|
*/
|
|
817
820
|
function getCurrentURL(span) {
|
|
818
|
-
const urlAttribute = _optionalChain$
|
|
821
|
+
const urlAttribute = _optionalChain$6([spanToJSON, 'call', _11 => _11(span), 'access', _12 => _12.data, 'optionalAccess', _13 => _13[SEMATTRS_HTTP_URL]]);
|
|
819
822
|
if (urlAttribute) {
|
|
820
823
|
return urlAttribute;
|
|
821
824
|
}
|
|
822
825
|
|
|
823
826
|
// Also look at the traceState, which we may set in the sampler even for unsampled spans
|
|
824
|
-
const urlTraceState = _optionalChain$
|
|
827
|
+
const urlTraceState = _optionalChain$6([span, 'access', _14 => _14.spanContext, 'call', _15 => _15(), 'access', _16 => _16.traceState, 'optionalAccess', _17 => _17.get, 'call', _18 => _18(SENTRY_TRACE_STATE_URL)]);
|
|
825
828
|
if (urlTraceState) {
|
|
826
829
|
return urlTraceState;
|
|
827
830
|
}
|
|
@@ -829,7 +832,7 @@ function getCurrentURL(span) {
|
|
|
829
832
|
return undefined;
|
|
830
833
|
}
|
|
831
834
|
|
|
832
|
-
function _optionalChain$
|
|
835
|
+
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
833
836
|
|
|
834
837
|
/**
|
|
835
838
|
* Wraps a function with a transaction/span and finishes the span after the function is done.
|
|
@@ -981,7 +984,7 @@ function ensureTimestampInMilliseconds(timestamp) {
|
|
|
981
984
|
|
|
982
985
|
function getContext(scope, forceTransaction) {
|
|
983
986
|
const ctx = getContextForScope(scope);
|
|
984
|
-
const actualScope = _optionalChain$
|
|
987
|
+
const actualScope = _optionalChain$5([getScopesFromContext, 'call', _ => _(ctx), 'optionalAccess', _2 => _2.scope]);
|
|
985
988
|
|
|
986
989
|
const parentSpan = trace.getSpan(ctx);
|
|
987
990
|
|
|
@@ -1038,7 +1041,7 @@ function getContext(scope, forceTransaction) {
|
|
|
1038
1041
|
|
|
1039
1042
|
const traceState = makeTraceState({
|
|
1040
1043
|
dsc,
|
|
1041
|
-
parentSpanId: spanId,
|
|
1044
|
+
parentSpanId: spanId !== INVALID_SPANID ? spanId : undefined,
|
|
1042
1045
|
sampled,
|
|
1043
1046
|
});
|
|
1044
1047
|
|
|
@@ -1089,6 +1092,8 @@ function suppressTracing(callback) {
|
|
|
1089
1092
|
return context.with(ctx, callback);
|
|
1090
1093
|
}
|
|
1091
1094
|
|
|
1095
|
+
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1096
|
+
|
|
1092
1097
|
/** Ensure the `trace` context is set on all events. */
|
|
1093
1098
|
function setupEventContextTrace(client) {
|
|
1094
1099
|
client.on('preprocessEvent', event => {
|
|
@@ -1101,12 +1106,22 @@ function setupEventContextTrace(client) {
|
|
|
1101
1106
|
|
|
1102
1107
|
const spanContext = span.spanContext();
|
|
1103
1108
|
|
|
1109
|
+
// If we have a parent span id from trace state, use that ('' means no parent should be used)
|
|
1110
|
+
// Else, pick the one from the span
|
|
1111
|
+
const parentSpanIdFromTraceState = _optionalChain$4([spanContext, 'access', _ => _.traceState, 'optionalAccess', _2 => _2.get, 'call', _3 => _3(SENTRY_TRACE_STATE_PARENT_SPAN_ID)]);
|
|
1112
|
+
const parent_span_id =
|
|
1113
|
+
typeof parentSpanIdFromTraceState === 'string'
|
|
1114
|
+
? parentSpanIdFromTraceState || undefined
|
|
1115
|
+
: spanHasParentId(span)
|
|
1116
|
+
? span.parentSpanId
|
|
1117
|
+
: undefined;
|
|
1118
|
+
|
|
1104
1119
|
// If event has already set `trace` context, use that one.
|
|
1105
1120
|
event.contexts = {
|
|
1106
1121
|
trace: dropUndefinedKeys({
|
|
1107
1122
|
trace_id: spanContext.traceId,
|
|
1108
1123
|
span_id: spanContext.spanId,
|
|
1109
|
-
parent_span_id
|
|
1124
|
+
parent_span_id,
|
|
1110
1125
|
}),
|
|
1111
1126
|
...event.contexts,
|
|
1112
1127
|
};
|
|
@@ -1217,7 +1232,7 @@ function setOpenTelemetryContextAsyncContextStrategy() {
|
|
|
1217
1232
|
});
|
|
1218
1233
|
}
|
|
1219
1234
|
|
|
1220
|
-
function _optionalChain$
|
|
1235
|
+
function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1221
1236
|
|
|
1222
1237
|
/**
|
|
1223
1238
|
* Wrap an OpenTelemetry ContextManager in a way that ensures the context is kept in sync with the Sentry Scope.
|
|
@@ -1255,8 +1270,8 @@ function wrapContextManagerClass(
|
|
|
1255
1270
|
...args
|
|
1256
1271
|
) {
|
|
1257
1272
|
const currentScopes = getScopesFromContext(context);
|
|
1258
|
-
const currentScope = _optionalChain$
|
|
1259
|
-
const currentIsolationScope = _optionalChain$
|
|
1273
|
+
const currentScope = _optionalChain$3([currentScopes, 'optionalAccess', _ => _.scope]) || getCurrentScope();
|
|
1274
|
+
const currentIsolationScope = _optionalChain$3([currentScopes, 'optionalAccess', _2 => _2.isolationScope]) || getIsolationScope();
|
|
1260
1275
|
|
|
1261
1276
|
const shouldForkIsolationScope = context.getValue(SENTRY_FORK_ISOLATION_SCOPE_CONTEXT_KEY) === true;
|
|
1262
1277
|
const scope = context.getValue(SENTRY_FORK_SET_SCOPE_CONTEXT_KEY) ;
|
|
@@ -1437,6 +1452,8 @@ function mapStatus(span) {
|
|
|
1437
1452
|
}
|
|
1438
1453
|
}
|
|
1439
1454
|
|
|
1455
|
+
function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1456
|
+
|
|
1440
1457
|
const MAX_SPAN_COUNT = 1000;
|
|
1441
1458
|
|
|
1442
1459
|
/**
|
|
@@ -1605,7 +1622,16 @@ function createTransactionForOtelSpan(span) {
|
|
|
1605
1622
|
});
|
|
1606
1623
|
|
|
1607
1624
|
const { traceId: trace_id, spanId: span_id } = span.spanContext();
|
|
1608
|
-
|
|
1625
|
+
|
|
1626
|
+
const parentSpanIdFromTraceState = _optionalChain$2([span, 'access', _ => _.spanContext, 'call', _2 => _2(), 'access', _3 => _3.traceState, 'optionalAccess', _4 => _4.get, 'call', _5 => _5(SENTRY_TRACE_STATE_PARENT_SPAN_ID)]);
|
|
1627
|
+
|
|
1628
|
+
// If parentSpanIdFromTraceState is defined at all, we want it to take presedence
|
|
1629
|
+
// In that case, an empty string should be interpreted as "no parent span id",
|
|
1630
|
+
// even if `span.parentSpanId` is set
|
|
1631
|
+
// this is the case when we are starting a new trace, where we have a virtual span based on the propagationContext
|
|
1632
|
+
// We only want to continue the traceId in this case, but ignore the parent span
|
|
1633
|
+
const parent_span_id =
|
|
1634
|
+
typeof parentSpanIdFromTraceState === 'string' ? parentSpanIdFromTraceState || undefined : span.parentSpanId;
|
|
1609
1635
|
|
|
1610
1636
|
const status = mapStatus(span);
|
|
1611
1637
|
|