@sentry/opentelemetry 9.17.0 → 9.19.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 +21 -10
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +21 -10
- package/build/esm/index.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/types/custom/client.d.ts.map +1 -1
- package/build/types/spanExporter.d.ts.map +1 -1
- package/build/types/utils/getParentSpanId.d.ts +8 -0
- package/build/types/utils/getParentSpanId.d.ts.map +1 -0
- package/build/types/utils/groupSpansWithParents.d.ts.map +1 -1
- package/build/types/utils/spanTypes.d.ts.map +1 -1
- package/build/types-ts3.8/utils/getParentSpanId.d.ts +8 -0
- package/package.json +7 -7
package/build/esm/index.js
CHANGED
|
@@ -12,6 +12,21 @@ const SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = 'sentry.parentIsRemote';
|
|
|
12
12
|
// These are not standardized yet, but used by the graphql instrumentation
|
|
13
13
|
const SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = 'sentry.graphql.operation';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Get the parent span id from a span.
|
|
17
|
+
* In OTel v1, the parent span id is accessed as `parentSpanId`
|
|
18
|
+
* In OTel v2, the parent span id is accessed as `spanId` on the `parentSpanContext`
|
|
19
|
+
*/
|
|
20
|
+
function getParentSpanId(span) {
|
|
21
|
+
if ('parentSpanId' in span) {
|
|
22
|
+
return span.parentSpanId ;
|
|
23
|
+
} else if ('parentSpanContext' in span) {
|
|
24
|
+
return (span.parentSpanContext )?.spanId;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
/**
|
|
16
31
|
* Check if a given span has attributes.
|
|
17
32
|
* This is necessary because the base `Span` type does not have attributes,
|
|
@@ -65,7 +80,7 @@ function spanHasParentId(
|
|
|
65
80
|
span,
|
|
66
81
|
) {
|
|
67
82
|
const castSpan = span ;
|
|
68
|
-
return !!castSpan
|
|
83
|
+
return !!getParentSpanId(castSpan);
|
|
69
84
|
}
|
|
70
85
|
|
|
71
86
|
/**
|
|
@@ -168,12 +183,7 @@ function wrapClientClass
|
|
|
168
183
|
*/
|
|
169
184
|
async flush(timeout) {
|
|
170
185
|
const provider = this.traceProvider;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (spanProcessor) {
|
|
174
|
-
await spanProcessor.forceFlush();
|
|
175
|
-
}
|
|
176
|
-
|
|
186
|
+
await provider?.forceFlush();
|
|
177
187
|
return super.flush(timeout);
|
|
178
188
|
}
|
|
179
189
|
}
|
|
@@ -1442,7 +1452,7 @@ function getLocalParentId(span) {
|
|
|
1442
1452
|
const parentIsRemote = span.attributes[SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE] === true;
|
|
1443
1453
|
// If the parentId is the trace parent ID, we pretend it's undefined
|
|
1444
1454
|
// As this means the parent exists somewhere else
|
|
1445
|
-
return !parentIsRemote ? span
|
|
1455
|
+
return !parentIsRemote ? getParentSpanId(span) : undefined;
|
|
1446
1456
|
}
|
|
1447
1457
|
|
|
1448
1458
|
function createOrUpdateSpanNodeAndRefs(nodeMap, span) {
|
|
@@ -1792,7 +1802,7 @@ function createTransactionForOtelSpan(span) {
|
|
|
1792
1802
|
// even if `span.parentSpanId` is set
|
|
1793
1803
|
// this is the case when we are starting a new trace, where we have a virtual span based on the propagationContext
|
|
1794
1804
|
// We only want to continue the traceId in this case, but ignore the parent span
|
|
1795
|
-
const parent_span_id = span
|
|
1805
|
+
const parent_span_id = getParentSpanId(span);
|
|
1796
1806
|
|
|
1797
1807
|
const status = mapStatus(span);
|
|
1798
1808
|
|
|
@@ -1858,8 +1868,9 @@ function createAndFinishSpanForOtelSpan(node, spans, sentSpans) {
|
|
|
1858
1868
|
|
|
1859
1869
|
const span_id = span.spanContext().spanId;
|
|
1860
1870
|
const trace_id = span.spanContext().traceId;
|
|
1871
|
+
const parentSpanId = getParentSpanId(span);
|
|
1861
1872
|
|
|
1862
|
-
const { attributes, startTime, endTime,
|
|
1873
|
+
const { attributes, startTime, endTime, links } = span;
|
|
1863
1874
|
|
|
1864
1875
|
const { op, description, data, origin = 'manual' } = getSpanData(span);
|
|
1865
1876
|
const allData = {
|