@sentry/opentelemetry 8.29.0 → 8.31.0-beta.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 +54 -26
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +56 -28
- package/build/esm/index.js.map +1 -1
- package/build/types/propagator.d.ts.map +1 -1
- package/build/types/sampler.d.ts.map +1 -1
- package/build/types/utils/getRequestSpanData.d.ts.map +1 -1
- package/build/types/utils/isSentryRequest.d.ts.map +1 -1
- package/build/types/utils/mapStatus.d.ts.map +1 -1
- package/build/types/utils/parseSpanDescription.d.ts.map +1 -1
- package/package.json +9 -9
package/build/cjs/index.js
CHANGED
|
@@ -95,9 +95,17 @@ function getRequestSpanData(span) {
|
|
|
95
95
|
return {};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
99
|
+
const maybeUrlAttribute = (span.attributes[semanticConventions.ATTR_URL_FULL] || span.attributes[semanticConventions.SEMATTRS_HTTP_URL])
|
|
100
|
+
|
|
101
|
+
;
|
|
102
|
+
|
|
98
103
|
const data = {
|
|
99
|
-
url:
|
|
100
|
-
|
|
104
|
+
url: maybeUrlAttribute,
|
|
105
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
106
|
+
'http.method': (span.attributes[semanticConventions.ATTR_HTTP_REQUEST_METHOD] || span.attributes[semanticConventions.SEMATTRS_HTTP_METHOD])
|
|
107
|
+
|
|
108
|
+
,
|
|
101
109
|
};
|
|
102
110
|
|
|
103
111
|
// Default to GET if URL is set but method is not
|
|
@@ -106,9 +114,8 @@ function getRequestSpanData(span) {
|
|
|
106
114
|
}
|
|
107
115
|
|
|
108
116
|
try {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const url = utils.parseUrl(urlStr);
|
|
117
|
+
if (typeof maybeUrlAttribute === 'string') {
|
|
118
|
+
const url = utils.parseUrl(maybeUrlAttribute);
|
|
112
119
|
|
|
113
120
|
data.url = utils.getSanitizedUrlString(url);
|
|
114
121
|
|
|
@@ -257,7 +264,9 @@ function isSentryRequestSpan(span) {
|
|
|
257
264
|
|
|
258
265
|
const { attributes } = span;
|
|
259
266
|
|
|
260
|
-
|
|
267
|
+
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `ATTR_HTTP_URL`, for now.
|
|
268
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
269
|
+
const httpUrl = attributes[semanticConventions.SEMATTRS_HTTP_URL] || attributes[semanticConventions.ATTR_URL_FULL];
|
|
261
270
|
|
|
262
271
|
if (!httpUrl) {
|
|
263
272
|
return false;
|
|
@@ -284,14 +293,13 @@ function inferSpanData(name, attributes, kind) {
|
|
|
284
293
|
}
|
|
285
294
|
|
|
286
295
|
// if http.method exists, this is an http request span
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
// conventions export an attribute key for it.
|
|
290
|
-
const httpMethod = attributes['http.request.method'] || attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
|
|
296
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
297
|
+
const httpMethod = attributes[semanticConventions.ATTR_HTTP_REQUEST_METHOD] || attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
|
|
291
298
|
if (httpMethod) {
|
|
292
299
|
return descriptionForHttpMethod({ attributes, name, kind }, httpMethod);
|
|
293
300
|
}
|
|
294
301
|
|
|
302
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
295
303
|
const dbSystem = attributes[semanticConventions.SEMATTRS_DB_SYSTEM];
|
|
296
304
|
const opIsCache =
|
|
297
305
|
typeof attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_OP] === 'string' &&
|
|
@@ -304,6 +312,7 @@ function inferSpanData(name, attributes, kind) {
|
|
|
304
312
|
}
|
|
305
313
|
|
|
306
314
|
// If rpc.service exists then this is a rpc call span.
|
|
315
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
307
316
|
const rpcService = attributes[semanticConventions.SEMATTRS_RPC_SERVICE];
|
|
308
317
|
if (rpcService) {
|
|
309
318
|
return {
|
|
@@ -314,6 +323,7 @@ function inferSpanData(name, attributes, kind) {
|
|
|
314
323
|
}
|
|
315
324
|
|
|
316
325
|
// If messaging.system exists then this is a messaging system span.
|
|
326
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
317
327
|
const messagingSystem = attributes[semanticConventions.SEMATTRS_MESSAGING_SYSTEM];
|
|
318
328
|
if (messagingSystem) {
|
|
319
329
|
return {
|
|
@@ -324,6 +334,7 @@ function inferSpanData(name, attributes, kind) {
|
|
|
324
334
|
}
|
|
325
335
|
|
|
326
336
|
// If faas.trigger exists then this is a function as a service span.
|
|
337
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
327
338
|
const faasTrigger = attributes[semanticConventions.SEMATTRS_FAAS_TRIGGER];
|
|
328
339
|
if (faasTrigger) {
|
|
329
340
|
return { op: faasTrigger.toString(), description: name, source: 'route' };
|
|
@@ -347,6 +358,7 @@ function parseSpanDescription(span) {
|
|
|
347
358
|
|
|
348
359
|
function descriptionForDbSystem({ attributes, name }) {
|
|
349
360
|
// Use DB statement (Ex "SELECT * FROM table") if possible as description.
|
|
361
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
350
362
|
const statement = attributes[semanticConventions.SEMATTRS_DB_STATEMENT];
|
|
351
363
|
|
|
352
364
|
const description = statement ? statement.toString() : name;
|
|
@@ -370,6 +382,11 @@ function descriptionForHttpMethod(
|
|
|
370
382
|
break;
|
|
371
383
|
}
|
|
372
384
|
|
|
385
|
+
// Spans for HTTP requests we have determined to be prefetch requests will have a `.prefetch` postfix in the op
|
|
386
|
+
if (attributes['sentry.http.prefetch']) {
|
|
387
|
+
opParts.push('prefetch');
|
|
388
|
+
}
|
|
389
|
+
|
|
373
390
|
const { urlPath, url, query, fragment, hasRoute } = getSanitizedUrl(attributes, kind);
|
|
374
391
|
|
|
375
392
|
if (!urlPath) {
|
|
@@ -446,11 +463,13 @@ function getSanitizedUrl(
|
|
|
446
463
|
|
|
447
464
|
{
|
|
448
465
|
// This is the relative path of the URL, e.g. /sub
|
|
466
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
449
467
|
const httpTarget = attributes[semanticConventions.SEMATTRS_HTTP_TARGET];
|
|
450
468
|
// This is the full URL, including host & query params etc., e.g. https://example.com/sub?foo=bar
|
|
451
|
-
|
|
469
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
470
|
+
const httpUrl = attributes[semanticConventions.SEMATTRS_HTTP_URL] || attributes[semanticConventions.ATTR_URL_FULL];
|
|
452
471
|
// This is the normalized route name - may not always be available!
|
|
453
|
-
const httpRoute = attributes[semanticConventions.
|
|
472
|
+
const httpRoute = attributes[semanticConventions.ATTR_HTTP_ROUTE];
|
|
454
473
|
|
|
455
474
|
const parsedUrl = typeof httpUrl === 'string' ? utils.parseUrl(httpUrl) : undefined;
|
|
456
475
|
const url = parsedUrl ? utils.getSanitizedUrlString(parsedUrl) : undefined;
|
|
@@ -772,7 +791,7 @@ class SentryPropagator extends core$1.W3CBaggagePropagator {
|
|
|
772
791
|
function getInjectionData(context)
|
|
773
792
|
|
|
774
793
|
{
|
|
775
|
-
const span =
|
|
794
|
+
const span = api.trace.getSpan(context);
|
|
776
795
|
const spanIsRemote = _optionalChain$6([span, 'optionalAccess', _5 => _5.spanContext, 'call', _6 => _6(), 'access', _7 => _7.isRemote]);
|
|
777
796
|
|
|
778
797
|
// If we have a local span, we can just pick everything from it
|
|
@@ -866,13 +885,16 @@ function getExistingBaggage(carrier) {
|
|
|
866
885
|
* 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).
|
|
867
886
|
*/
|
|
868
887
|
function getCurrentURL(span) {
|
|
869
|
-
const
|
|
888
|
+
const spanData = core.spanToJSON(span).data;
|
|
889
|
+
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_URL`, for now.
|
|
890
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
891
|
+
const urlAttribute = _optionalChain$6([spanData, 'optionalAccess', _11 => _11[semanticConventions.SEMATTRS_HTTP_URL]]) || _optionalChain$6([spanData, 'optionalAccess', _12 => _12[semanticConventions.ATTR_URL_FULL]]);
|
|
870
892
|
if (urlAttribute) {
|
|
871
893
|
return urlAttribute;
|
|
872
894
|
}
|
|
873
895
|
|
|
874
896
|
// Also look at the traceState, which we may set in the sampler even for unsampled spans
|
|
875
|
-
const urlTraceState = _optionalChain$6([span, 'access',
|
|
897
|
+
const urlTraceState = _optionalChain$6([span, 'access', _13 => _13.spanContext, 'call', _14 => _14(), 'access', _15 => _15.traceState, 'optionalAccess', _16 => _16.get, 'call', _17 => _17(SENTRY_TRACE_STATE_URL)]);
|
|
876
898
|
if (urlTraceState) {
|
|
877
899
|
return urlTraceState;
|
|
878
900
|
}
|
|
@@ -1522,7 +1544,9 @@ function mapStatus(span) {
|
|
|
1522
1544
|
function inferStatusFromAttributes(attributes) {
|
|
1523
1545
|
// If the span status is UNSET, we try to infer it from HTTP or GRPC status codes.
|
|
1524
1546
|
|
|
1525
|
-
|
|
1547
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1548
|
+
const httpCodeAttribute = attributes[semanticConventions.ATTR_HTTP_RESPONSE_STATUS_CODE] || attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
|
|
1549
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1526
1550
|
const grpcCodeAttribute = attributes[semanticConventions.SEMATTRS_RPC_GRPC_STATUS_CODE];
|
|
1527
1551
|
|
|
1528
1552
|
const numberHttpCode =
|
|
@@ -1851,6 +1875,7 @@ function removeSentryAttributes(data) {
|
|
|
1851
1875
|
/* eslint-disable @typescript-eslint/no-dynamic-delete */
|
|
1852
1876
|
delete cleanedData[core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
|
|
1853
1877
|
delete cleanedData[SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE];
|
|
1878
|
+
delete cleanedData['sentry.skip_span_data_inference'];
|
|
1854
1879
|
/* eslint-enable @typescript-eslint/no-dynamic-delete */
|
|
1855
1880
|
|
|
1856
1881
|
return cleanedData;
|
|
@@ -1864,9 +1889,10 @@ function getData(span) {
|
|
|
1864
1889
|
data['otel.kind'] = api.SpanKind[span.kind];
|
|
1865
1890
|
}
|
|
1866
1891
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1892
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1893
|
+
const maybeHttpStatusCodeAttribute = attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
|
|
1894
|
+
if (maybeHttpStatusCodeAttribute) {
|
|
1895
|
+
data[semanticConventions.ATTR_HTTP_RESPONSE_STATUS_CODE] = maybeHttpStatusCodeAttribute ;
|
|
1870
1896
|
}
|
|
1871
1897
|
|
|
1872
1898
|
const requestData = getRequestSpanData(span);
|
|
@@ -1998,13 +2024,13 @@ class SentrySampler {
|
|
|
1998
2024
|
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
1999
2025
|
}
|
|
2000
2026
|
|
|
2027
|
+
// `ATTR_HTTP_REQUEST_METHOD` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_METHOD`, for now.
|
|
2028
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
2029
|
+
const maybeSpanHttpMethod = spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD] || spanAttributes[semanticConventions.ATTR_HTTP_REQUEST_METHOD];
|
|
2030
|
+
|
|
2001
2031
|
// If we have a http.client span that has no local parent, we never want to sample it
|
|
2002
2032
|
// but we want to leave downstream sampling decisions up to the server
|
|
2003
|
-
if (
|
|
2004
|
-
spanKind === api.SpanKind.CLIENT &&
|
|
2005
|
-
spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD] &&
|
|
2006
|
-
(!parentSpan || _optionalChain([parentContext, 'optionalAccess', _3 => _3.isRemote]))
|
|
2007
|
-
) {
|
|
2033
|
+
if (spanKind === api.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || _optionalChain([parentContext, 'optionalAccess', _3 => _3.isRemote]))) {
|
|
2008
2034
|
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
2009
2035
|
}
|
|
2010
2036
|
|
|
@@ -2055,7 +2081,7 @@ class SentrySampler {
|
|
|
2055
2081
|
[core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate,
|
|
2056
2082
|
};
|
|
2057
2083
|
|
|
2058
|
-
const method = `${
|
|
2084
|
+
const method = `${maybeSpanHttpMethod}`.toUpperCase();
|
|
2059
2085
|
if (method === 'OPTIONS' || method === 'HEAD') {
|
|
2060
2086
|
DEBUG_BUILD && utils.logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
|
|
2061
2087
|
|
|
@@ -2144,7 +2170,9 @@ function getBaseTraceState(context, spanAttributes) {
|
|
|
2144
2170
|
let traceState = _optionalChain([parentContext, 'optionalAccess', _6 => _6.traceState]) || new core$1.TraceState();
|
|
2145
2171
|
|
|
2146
2172
|
// We always keep the URL on the trace state, so we can access it in the propagator
|
|
2147
|
-
|
|
2173
|
+
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `ATTR_HTTP_URL`, for now.
|
|
2174
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
2175
|
+
const url = spanAttributes[semanticConventions.SEMATTRS_HTTP_URL] || spanAttributes[semanticConventions.ATTR_URL_FULL];
|
|
2148
2176
|
if (url && typeof url === 'string') {
|
|
2149
2177
|
traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
|
|
2150
2178
|
}
|