@sentry/opentelemetry 8.41.0-beta.0 → 8.41.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/build/cjs/index.js +131 -95
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +132 -97
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/propagator.d.ts +10 -1
- package/build/types/propagator.d.ts.map +1 -1
- package/build/types/spanExporter.d.ts +5 -7
- package/build/types/spanExporter.d.ts.map +1 -1
- package/build/types/trace.d.ts +6 -1
- package/build/types/trace.d.ts.map +1 -1
- package/build/types/utils/getTraceData.d.ts +4 -2
- package/build/types/utils/getTraceData.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +1 -1
- package/build/types-ts3.8/propagator.d.ts +10 -1
- package/build/types-ts3.8/spanExporter.d.ts +5 -7
- package/build/types-ts3.8/trace.d.ts +9 -1
- package/build/types-ts3.8/utils/getTraceData.d.ts +4 -2
- package/package.json +3 -3
package/build/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _optionalChain } from '@sentry/core';
|
|
2
2
|
import { ATTR_URL_FULL, SEMATTRS_HTTP_URL, ATTR_HTTP_REQUEST_METHOD, SEMATTRS_HTTP_METHOD, SEMATTRS_DB_SYSTEM, SEMATTRS_RPC_SERVICE, SEMATTRS_MESSAGING_SYSTEM, SEMATTRS_FAAS_TRIGGER, SEMATTRS_DB_STATEMENT, SEMATTRS_HTTP_TARGET, ATTR_HTTP_ROUTE, ATTR_HTTP_RESPONSE_STATUS_CODE, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_RPC_GRPC_STATUS_CODE } from '@opentelemetry/semantic-conventions';
|
|
3
|
-
import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, isSentryRequestUrl, getClient, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, stripUrlQueryAndFragment, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, dynamicSamplingContextToSentryBaggageHeader, baggageHeaderToDynamicSamplingContext, getDynamicSamplingContextFromSpan, getRootSpan, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, propagationContextFromHeaders, getCurrentScope, getIsolationScope, stringMatchesSomePattern,
|
|
3
|
+
import { parseUrl, getSanitizedUrlString, SDK_VERSION, addNonEnumerableProperty, isSentryRequestUrl, getClient, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, stripUrlQueryAndFragment, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, dynamicSamplingContextToSentryBaggageHeader, baggageHeaderToDynamicSamplingContext, getDynamicSamplingContextFromSpan, getRootSpan, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, propagationContextFromHeaders, getCurrentScope, getIsolationScope, stringMatchesSomePattern, getDynamicSamplingContextFromScope, handleCallbackErrors, continueTrace as continueTrace$1, spanToTraceContext, getTraceContextFromScope, dropUndefinedKeys, getCapturedScopesOnSpan, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, getStatusMessage, spanTimeInputToSeconds, getMetricSummaryJsonForSpan, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, hasTracingEnabled, sampleSpan } from '@sentry/core';
|
|
4
4
|
export { getClient, getCurrentHubShim, getDynamicSamplingContextFromSpan } from '@sentry/core';
|
|
5
5
|
import * as api from '@opentelemetry/api';
|
|
6
6
|
import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, INVALID_SPANID, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
|
|
@@ -771,6 +771,9 @@ class SentryPropagator extends W3CBaggagePropagator {
|
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
773
|
|
|
774
|
+
/**
|
|
775
|
+
* Get propagation injection data for the given context.
|
|
776
|
+
*/
|
|
774
777
|
function getInjectionData(context)
|
|
775
778
|
|
|
776
779
|
{
|
|
@@ -781,8 +784,7 @@ function getInjectionData(context)
|
|
|
781
784
|
if (span && !spanIsRemote) {
|
|
782
785
|
const spanContext = span.spanContext();
|
|
783
786
|
|
|
784
|
-
const
|
|
785
|
-
const dynamicSamplingContext = getDynamicSamplingContext(propagationContext, spanContext.traceId);
|
|
787
|
+
const dynamicSamplingContext = getDynamicSamplingContextFromSpan(span);
|
|
786
788
|
return {
|
|
787
789
|
dynamicSamplingContext,
|
|
788
790
|
traceId: spanContext.traceId,
|
|
@@ -793,9 +795,10 @@ function getInjectionData(context)
|
|
|
793
795
|
|
|
794
796
|
// Else we try to use the propagation context from the scope
|
|
795
797
|
const scope = _optionalChain$6([getScopesFromContext, 'call', _8 => _8(context), 'optionalAccess', _9 => _9.scope]) || getCurrentScope();
|
|
798
|
+
const client = getClient();
|
|
796
799
|
|
|
797
800
|
const propagationContext = scope.getPropagationContext();
|
|
798
|
-
const dynamicSamplingContext =
|
|
801
|
+
const dynamicSamplingContext = client ? getDynamicSamplingContextFromScope(client, scope) : undefined;
|
|
799
802
|
return {
|
|
800
803
|
dynamicSamplingContext,
|
|
801
804
|
traceId: propagationContext.traceId,
|
|
@@ -804,26 +807,6 @@ function getInjectionData(context)
|
|
|
804
807
|
};
|
|
805
808
|
}
|
|
806
809
|
|
|
807
|
-
/** Get the DSC from a context, or fall back to use the one from the client. */
|
|
808
|
-
function getDynamicSamplingContext(
|
|
809
|
-
propagationContext,
|
|
810
|
-
traceId,
|
|
811
|
-
) {
|
|
812
|
-
// If we have a DSC on the propagation context, we just use it
|
|
813
|
-
if (_optionalChain$6([propagationContext, 'optionalAccess', _10 => _10.dsc])) {
|
|
814
|
-
return propagationContext.dsc;
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
// Else, we try to generate a new one
|
|
818
|
-
const client = getClient();
|
|
819
|
-
|
|
820
|
-
if (client) {
|
|
821
|
-
return getDynamicSamplingContextFromClient(traceId || propagationContext.traceId, client);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
return undefined;
|
|
825
|
-
}
|
|
826
|
-
|
|
827
810
|
function getContextWithRemoteActiveSpan(
|
|
828
811
|
ctx,
|
|
829
812
|
{ sentryTrace, baggage },
|
|
@@ -871,13 +854,13 @@ function getCurrentURL(span) {
|
|
|
871
854
|
const spanData = spanToJSON(span).data;
|
|
872
855
|
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_URL`, for now.
|
|
873
856
|
// eslint-disable-next-line deprecation/deprecation
|
|
874
|
-
const urlAttribute = _optionalChain$6([spanData, 'optionalAccess',
|
|
857
|
+
const urlAttribute = _optionalChain$6([spanData, 'optionalAccess', _10 => _10[SEMATTRS_HTTP_URL]]) || _optionalChain$6([spanData, 'optionalAccess', _11 => _11[ATTR_URL_FULL]]);
|
|
875
858
|
if (urlAttribute) {
|
|
876
859
|
return urlAttribute;
|
|
877
860
|
}
|
|
878
861
|
|
|
879
862
|
// Also look at the traceState, which we may set in the sampler even for unsampled spans
|
|
880
|
-
const urlTraceState = _optionalChain$6([span, 'access',
|
|
863
|
+
const urlTraceState = _optionalChain$6([span, 'access', _12 => _12.spanContext, 'call', _13 => _13(), 'access', _14 => _14.traceState, 'optionalAccess', _15 => _15.get, 'call', _16 => _16(SENTRY_TRACE_STATE_URL)]);
|
|
881
864
|
if (urlTraceState) {
|
|
882
865
|
return urlTraceState;
|
|
883
866
|
}
|
|
@@ -1043,8 +1026,9 @@ function ensureTimestampInMilliseconds(timestamp) {
|
|
|
1043
1026
|
|
|
1044
1027
|
function getContext(scope, forceTransaction) {
|
|
1045
1028
|
const ctx = getContextForScope(scope);
|
|
1029
|
+
// Note: If the context is the ROOT_CONTEXT, no scope is attached
|
|
1030
|
+
// Thus we will not use the propagation context in this case, which is desired
|
|
1046
1031
|
const actualScope = _optionalChain$5([getScopesFromContext, 'call', _ => _(ctx), 'optionalAccess', _2 => _2.scope]);
|
|
1047
|
-
|
|
1048
1032
|
const parentSpan = trace.getSpan(ctx);
|
|
1049
1033
|
|
|
1050
1034
|
// In the case that we have no parent span, we need to "simulate" one to ensure the propagation context is correct
|
|
@@ -1145,6 +1129,25 @@ function continueTrace(options, callback) {
|
|
|
1145
1129
|
});
|
|
1146
1130
|
}
|
|
1147
1131
|
|
|
1132
|
+
/**
|
|
1133
|
+
* Get the trace context for a given scope.
|
|
1134
|
+
* We have a custom implemention here because we need an OTEL-specific way to get the span from a scope.
|
|
1135
|
+
*/
|
|
1136
|
+
function getTraceContextForScope(
|
|
1137
|
+
client,
|
|
1138
|
+
scope,
|
|
1139
|
+
) {
|
|
1140
|
+
const ctx = getContextFromScope(scope);
|
|
1141
|
+
const span = ctx && trace.getSpan(ctx);
|
|
1142
|
+
|
|
1143
|
+
const traceContext = span ? spanToTraceContext(span) : getTraceContextFromScope(scope);
|
|
1144
|
+
|
|
1145
|
+
const dynamicSamplingContext = span
|
|
1146
|
+
? getDynamicSamplingContextFromSpan(span)
|
|
1147
|
+
: getDynamicSamplingContextFromScope(client, scope);
|
|
1148
|
+
return [dynamicSamplingContext, traceContext];
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1148
1151
|
function getActiveSpanWrapper(parentSpan) {
|
|
1149
1152
|
return parentSpan !== undefined
|
|
1150
1153
|
? (callback) => {
|
|
@@ -1207,19 +1210,21 @@ function setupEventContextTrace(client) {
|
|
|
1207
1210
|
* Otel-specific implementation of `getTraceData`.
|
|
1208
1211
|
* @see `@sentry/core` version of `getTraceData` for more information
|
|
1209
1212
|
*/
|
|
1210
|
-
function getTraceData() {
|
|
1211
|
-
|
|
1213
|
+
function getTraceData({ span } = {}) {
|
|
1214
|
+
let ctx = api.context.active();
|
|
1212
1215
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1216
|
+
if (span) {
|
|
1217
|
+
const { scope } = getCapturedScopesOnSpan(span);
|
|
1218
|
+
// fall back to current context if for whatever reason we can't find the one of the span
|
|
1219
|
+
ctx = (scope && getContextFromScope(scope)) || api.trace.setSpan(api.context.active(), span);
|
|
1217
1220
|
}
|
|
1218
1221
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1222
|
+
const { traceId, spanId, sampled, dynamicSamplingContext } = getInjectionData(ctx);
|
|
1223
|
+
|
|
1224
|
+
return {
|
|
1225
|
+
'sentry-trace': generateSentryTraceHeader(traceId, spanId, sampled),
|
|
1226
|
+
baggage: dynamicSamplingContextToSentryBaggageHeader(dynamicSamplingContext),
|
|
1227
|
+
};
|
|
1223
1228
|
}
|
|
1224
1229
|
|
|
1225
1230
|
/**
|
|
@@ -1560,52 +1565,105 @@ const DEFAULT_TIMEOUT = 300; // 5 min
|
|
|
1560
1565
|
*/
|
|
1561
1566
|
class SentrySpanExporter {
|
|
1562
1567
|
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1568
|
+
/*
|
|
1569
|
+
* A quick explanation on the buckets: We do bucketing of finished spans for efficiency. This span exporter is
|
|
1570
|
+
* accumulating spans until a root span is encountered and then it flushes all the spans that are descendants of that
|
|
1571
|
+
* root span. Because it is totally in the realm of possibilities that root spans are never finished, and we don't
|
|
1572
|
+
* want to accumulate spans indefinitely in memory, we need to periodically evacuate spans. Naively we could simply
|
|
1573
|
+
* store the spans in an array and each time a new span comes in we could iterate through the entire array and
|
|
1574
|
+
* evacuate all spans that have an end-timestamp that is older than our limit. This could get quite expensive because
|
|
1575
|
+
* we would have to iterate a potentially large number of spans every time we evacuate. We want to avoid these large
|
|
1576
|
+
* bursts of computation.
|
|
1577
|
+
*
|
|
1578
|
+
* Instead we go for a bucketing approach and put spans into buckets, based on what second
|
|
1579
|
+
* (modulo the time limit) the span was put into the exporter. With buckets, when we decide to evacuate, we can
|
|
1580
|
+
* iterate through the bucket entries instead, which have an upper bound of items, making the evacuation much more
|
|
1581
|
+
* efficient. Cleaning up also becomes much more efficient since it simply involves de-referencing a bucket within the
|
|
1582
|
+
* bucket array, and letting garbage collection take care of the rest.
|
|
1583
|
+
*/
|
|
1584
|
+
|
|
1585
|
+
constructor(options
|
|
1586
|
+
|
|
1587
|
+
) {
|
|
1588
|
+
this._finishedSpanBucketSize = _optionalChain$2([options, 'optionalAccess', _ => _.timeout]) || DEFAULT_TIMEOUT;
|
|
1589
|
+
this._finishedSpanBuckets = new Array(this._finishedSpanBucketSize).fill(undefined);
|
|
1590
|
+
this._lastCleanupTimestampInS = Math.floor(Date.now() / 1000);
|
|
1591
|
+
this._spansToBucketEntry = new WeakMap();
|
|
1566
1592
|
}
|
|
1567
1593
|
|
|
1568
1594
|
/** Export a single span. */
|
|
1569
1595
|
export(span) {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1596
|
+
const currentTimestampInS = Math.floor(Date.now() / 1000);
|
|
1597
|
+
|
|
1598
|
+
if (this._lastCleanupTimestampInS !== currentTimestampInS) {
|
|
1599
|
+
let droppedSpanCount = 0;
|
|
1600
|
+
this._finishedSpanBuckets.forEach((bucket, i) => {
|
|
1601
|
+
if (bucket && bucket.timestampInS <= currentTimestampInS - this._finishedSpanBucketSize) {
|
|
1602
|
+
droppedSpanCount += bucket.spans.size;
|
|
1603
|
+
this._finishedSpanBuckets[i] = undefined;
|
|
1604
|
+
}
|
|
1605
|
+
});
|
|
1606
|
+
if (droppedSpanCount > 0) {
|
|
1607
|
+
DEBUG_BUILD &&
|
|
1608
|
+
logger.log(
|
|
1609
|
+
`SpanExporter dropped ${droppedSpanCount} spans because they were pending for more than ${this._finishedSpanBucketSize} seconds.`,
|
|
1610
|
+
);
|
|
1611
|
+
}
|
|
1612
|
+
this._lastCleanupTimestampInS = currentTimestampInS;
|
|
1578
1613
|
}
|
|
1579
1614
|
|
|
1580
|
-
this.
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1615
|
+
const currentBucketIndex = currentTimestampInS % this._finishedSpanBucketSize;
|
|
1616
|
+
const currentBucket = this._finishedSpanBuckets[currentBucketIndex] || {
|
|
1617
|
+
timestampInS: currentTimestampInS,
|
|
1618
|
+
spans: new Set(),
|
|
1619
|
+
};
|
|
1620
|
+
this._finishedSpanBuckets[currentBucketIndex] = currentBucket;
|
|
1621
|
+
currentBucket.spans.add(span);
|
|
1622
|
+
this._spansToBucketEntry.set(span, currentBucket);
|
|
1623
|
+
|
|
1624
|
+
// If the span doesn't have a local parent ID (it's a root span), we're gonna flush all the ended spans
|
|
1625
|
+
if (!getLocalParentId(span)) {
|
|
1626
|
+
this._clearTimeout();
|
|
1627
|
+
|
|
1628
|
+
// If we got a parent span, we try to send the span tree
|
|
1629
|
+
// Wait a tick for this, to ensure we avoid race conditions
|
|
1630
|
+
this._flushTimeout = setTimeout(() => {
|
|
1631
|
+
this.flush();
|
|
1632
|
+
}, 1);
|
|
1633
|
+
}
|
|
1587
1634
|
}
|
|
1588
1635
|
|
|
1589
1636
|
/** Try to flush any pending spans immediately. */
|
|
1590
1637
|
flush() {
|
|
1591
1638
|
this._clearTimeout();
|
|
1592
1639
|
|
|
1593
|
-
const
|
|
1640
|
+
const finishedSpans = [];
|
|
1641
|
+
this._finishedSpanBuckets.forEach(bucket => {
|
|
1642
|
+
if (bucket) {
|
|
1643
|
+
finishedSpans.push(...bucket.spans);
|
|
1644
|
+
}
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
const sentSpans = maybeSend(finishedSpans);
|
|
1594
1648
|
|
|
1595
|
-
const
|
|
1649
|
+
const sentSpanCount = sentSpans.size;
|
|
1596
1650
|
|
|
1597
|
-
const remainingOpenSpanCount =
|
|
1598
|
-
const sentSpanCount = openSpanCount - remainingOpenSpanCount;
|
|
1651
|
+
const remainingOpenSpanCount = finishedSpans.length - sentSpanCount;
|
|
1599
1652
|
|
|
1600
1653
|
DEBUG_BUILD &&
|
|
1601
1654
|
logger.log(`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} unsent spans remaining`);
|
|
1602
1655
|
|
|
1603
|
-
|
|
1656
|
+
sentSpans.forEach(span => {
|
|
1657
|
+
const bucketEntry = this._spansToBucketEntry.get(span);
|
|
1658
|
+
if (bucketEntry) {
|
|
1659
|
+
bucketEntry.spans.delete(span);
|
|
1660
|
+
}
|
|
1661
|
+
});
|
|
1604
1662
|
}
|
|
1605
1663
|
|
|
1606
1664
|
/** Clear the exporter. */
|
|
1607
1665
|
clear() {
|
|
1608
|
-
this.
|
|
1666
|
+
this._finishedSpanBuckets = this._finishedSpanBuckets.fill(undefined);
|
|
1609
1667
|
this._clearTimeout();
|
|
1610
1668
|
}
|
|
1611
1669
|
|
|
@@ -1616,31 +1674,12 @@ class SentrySpanExporter {
|
|
|
1616
1674
|
this._flushTimeout = undefined;
|
|
1617
1675
|
}
|
|
1618
1676
|
}
|
|
1619
|
-
|
|
1620
|
-
/**
|
|
1621
|
-
* Remove any span that is older than 5min.
|
|
1622
|
-
* We do this to avoid leaking memory.
|
|
1623
|
-
*/
|
|
1624
|
-
_cleanupOldSpans(spans = this._finishedSpans) {
|
|
1625
|
-
const currentTimeSeconds = Date.now() / 1000;
|
|
1626
|
-
this._finishedSpans = spans.filter(span => {
|
|
1627
|
-
const shouldDrop = shouldCleanupSpan(span, currentTimeSeconds, this._timeout);
|
|
1628
|
-
DEBUG_BUILD &&
|
|
1629
|
-
shouldDrop &&
|
|
1630
|
-
logger.log(
|
|
1631
|
-
`SpanExporter dropping span ${span.name} (${
|
|
1632
|
-
span.spanContext().spanId
|
|
1633
|
-
}) because it is pending for more than 5 minutes.`,
|
|
1634
|
-
);
|
|
1635
|
-
return !shouldDrop;
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
1677
|
}
|
|
1639
1678
|
|
|
1640
1679
|
/**
|
|
1641
1680
|
* Send the given spans, but only if they are part of a finished transaction.
|
|
1642
1681
|
*
|
|
1643
|
-
* Returns the
|
|
1682
|
+
* Returns the sent spans.
|
|
1644
1683
|
* Spans remain unsent when their parent span is not yet finished.
|
|
1645
1684
|
* This will happen regularly, as child spans are generally finished before their parents.
|
|
1646
1685
|
* But it _could_ also happen because, for whatever reason, a parent span was lost.
|
|
@@ -1648,20 +1687,20 @@ class SentrySpanExporter {
|
|
|
1648
1687
|
*/
|
|
1649
1688
|
function maybeSend(spans) {
|
|
1650
1689
|
const grouped = groupSpansWithParents(spans);
|
|
1651
|
-
const
|
|
1690
|
+
const sentSpans = new Set();
|
|
1652
1691
|
|
|
1653
1692
|
const rootNodes = getCompletedRootNodes(grouped);
|
|
1654
1693
|
|
|
1655
1694
|
rootNodes.forEach(root => {
|
|
1656
|
-
remaining.delete(root);
|
|
1657
1695
|
const span = root.span;
|
|
1696
|
+
sentSpans.add(span);
|
|
1658
1697
|
const transactionEvent = createTransactionForOtelSpan(span);
|
|
1659
1698
|
|
|
1660
1699
|
// We'll recursively add all the child spans to this array
|
|
1661
1700
|
const spans = transactionEvent.spans || [];
|
|
1662
1701
|
|
|
1663
1702
|
root.children.forEach(child => {
|
|
1664
|
-
createAndFinishSpanForOtelSpan(child, spans,
|
|
1703
|
+
createAndFinishSpanForOtelSpan(child, spans, sentSpans);
|
|
1665
1704
|
});
|
|
1666
1705
|
|
|
1667
1706
|
// spans.sort() mutates the array, but we do not use this anymore after this point
|
|
@@ -1679,9 +1718,7 @@ function maybeSend(spans) {
|
|
|
1679
1718
|
captureEvent(transactionEvent);
|
|
1680
1719
|
});
|
|
1681
1720
|
|
|
1682
|
-
return
|
|
1683
|
-
.map(node => node.span)
|
|
1684
|
-
.filter((span) => !!span);
|
|
1721
|
+
return sentSpans;
|
|
1685
1722
|
}
|
|
1686
1723
|
|
|
1687
1724
|
function nodeIsCompletedRootNode(node) {
|
|
@@ -1692,11 +1729,6 @@ function getCompletedRootNodes(nodes) {
|
|
|
1692
1729
|
return nodes.filter(nodeIsCompletedRootNode);
|
|
1693
1730
|
}
|
|
1694
1731
|
|
|
1695
|
-
function shouldCleanupSpan(span, currentTimeSeconds, maxStartTimeOffsetSeconds) {
|
|
1696
|
-
const cutoff = currentTimeSeconds - maxStartTimeOffsetSeconds;
|
|
1697
|
-
return spanTimeInputToSeconds(span.startTime) < cutoff;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
1732
|
function parseSpan(span) {
|
|
1701
1733
|
const attributes = span.attributes;
|
|
1702
1734
|
|
|
@@ -1777,16 +1809,19 @@ function createTransactionForOtelSpan(span) {
|
|
|
1777
1809
|
return transactionEvent;
|
|
1778
1810
|
}
|
|
1779
1811
|
|
|
1780
|
-
function createAndFinishSpanForOtelSpan(node, spans,
|
|
1781
|
-
remaining.delete(node);
|
|
1812
|
+
function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
|
|
1782
1813
|
const span = node.span;
|
|
1783
1814
|
|
|
1815
|
+
if (span) {
|
|
1816
|
+
sentSpans.add(span);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1784
1819
|
const shouldDrop = !span;
|
|
1785
1820
|
|
|
1786
1821
|
// If this span should be dropped, we still want to create spans for the children of this
|
|
1787
1822
|
if (shouldDrop) {
|
|
1788
1823
|
node.children.forEach(child => {
|
|
1789
|
-
createAndFinishSpanForOtelSpan(child, spans,
|
|
1824
|
+
createAndFinishSpanForOtelSpan(child, spans, sentSpans);
|
|
1790
1825
|
});
|
|
1791
1826
|
return;
|
|
1792
1827
|
}
|
|
@@ -1825,7 +1860,7 @@ function createAndFinishSpanForOtelSpan(node, spans, remaining) {
|
|
|
1825
1860
|
spans.push(spanJSON);
|
|
1826
1861
|
|
|
1827
1862
|
node.children.forEach(child => {
|
|
1828
|
-
createAndFinishSpanForOtelSpan(child, spans,
|
|
1863
|
+
createAndFinishSpanForOtelSpan(child, spans, sentSpans);
|
|
1829
1864
|
});
|
|
1830
1865
|
}
|
|
1831
1866
|
|
|
@@ -2173,5 +2208,5 @@ function addOpenTelemetryInstrumentation(...instrumentations) {
|
|
|
2173
2208
|
});
|
|
2174
2209
|
}
|
|
2175
2210
|
|
|
2176
|
-
export { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, SentryPropagator, SentrySampler, SentrySpanProcessor, addOpenTelemetryInstrumentation, continueTrace, enhanceDscWithOpenTelemetryRootSpanName, generateSpanContextForPropagationContext, getActiveSpan, getPropagationContextFromSpan, getRequestSpanData, getScopesFromContext, getSpanKind, isSentryRequestSpan, openTelemetrySetupCheck, setOpenTelemetryContextAsyncContextStrategy, setupEventContextTrace, spanHasAttributes, spanHasEvents, spanHasKind, spanHasName, spanHasParentId, spanHasStatus, startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan, wrapClientClass, wrapContextManagerClass, wrapSamplingDecision };
|
|
2211
|
+
export { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, SentryPropagator, SentrySampler, SentrySpanProcessor, addOpenTelemetryInstrumentation, continueTrace, enhanceDscWithOpenTelemetryRootSpanName, generateSpanContextForPropagationContext, getActiveSpan, getPropagationContextFromSpan, getRequestSpanData, getScopesFromContext, getSpanKind, getTraceContextForScope, isSentryRequestSpan, openTelemetrySetupCheck, setOpenTelemetryContextAsyncContextStrategy, setupEventContextTrace, spanHasAttributes, spanHasEvents, spanHasKind, spanHasName, spanHasParentId, spanHasStatus, startInactiveSpan, startSpan, startSpanManual, suppressTracing, withActiveSpan, wrapClientClass, wrapContextManagerClass, wrapSamplingDecision };
|
|
2177
2212
|
//# sourceMappingURL=index.js.map
|