@sentry/opentelemetry 8.29.0 → 8.30.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 +47 -25
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +48 -26
- package/build/esm/index.js.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;
|
|
@@ -446,11 +458,13 @@ function getSanitizedUrl(
|
|
|
446
458
|
|
|
447
459
|
{
|
|
448
460
|
// This is the relative path of the URL, e.g. /sub
|
|
461
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
449
462
|
const httpTarget = attributes[semanticConventions.SEMATTRS_HTTP_TARGET];
|
|
450
463
|
// This is the full URL, including host & query params etc., e.g. https://example.com/sub?foo=bar
|
|
451
|
-
|
|
464
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
465
|
+
const httpUrl = attributes[semanticConventions.SEMATTRS_HTTP_URL] || attributes[semanticConventions.ATTR_URL_FULL];
|
|
452
466
|
// This is the normalized route name - may not always be available!
|
|
453
|
-
const httpRoute = attributes[semanticConventions.
|
|
467
|
+
const httpRoute = attributes[semanticConventions.ATTR_HTTP_ROUTE];
|
|
454
468
|
|
|
455
469
|
const parsedUrl = typeof httpUrl === 'string' ? utils.parseUrl(httpUrl) : undefined;
|
|
456
470
|
const url = parsedUrl ? utils.getSanitizedUrlString(parsedUrl) : undefined;
|
|
@@ -866,13 +880,16 @@ function getExistingBaggage(carrier) {
|
|
|
866
880
|
* 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
881
|
*/
|
|
868
882
|
function getCurrentURL(span) {
|
|
869
|
-
const
|
|
883
|
+
const spanData = core.spanToJSON(span).data;
|
|
884
|
+
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_URL`, for now.
|
|
885
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
886
|
+
const urlAttribute = _optionalChain$6([spanData, 'optionalAccess', _11 => _11[semanticConventions.SEMATTRS_HTTP_URL]]) || _optionalChain$6([spanData, 'optionalAccess', _12 => _12[semanticConventions.ATTR_URL_FULL]]);
|
|
870
887
|
if (urlAttribute) {
|
|
871
888
|
return urlAttribute;
|
|
872
889
|
}
|
|
873
890
|
|
|
874
891
|
// Also look at the traceState, which we may set in the sampler even for unsampled spans
|
|
875
|
-
const urlTraceState = _optionalChain$6([span, 'access',
|
|
892
|
+
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
893
|
if (urlTraceState) {
|
|
877
894
|
return urlTraceState;
|
|
878
895
|
}
|
|
@@ -1522,7 +1539,9 @@ function mapStatus(span) {
|
|
|
1522
1539
|
function inferStatusFromAttributes(attributes) {
|
|
1523
1540
|
// If the span status is UNSET, we try to infer it from HTTP or GRPC status codes.
|
|
1524
1541
|
|
|
1525
|
-
|
|
1542
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1543
|
+
const httpCodeAttribute = attributes[semanticConventions.ATTR_HTTP_RESPONSE_STATUS_CODE] || attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
|
|
1544
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1526
1545
|
const grpcCodeAttribute = attributes[semanticConventions.SEMATTRS_RPC_GRPC_STATUS_CODE];
|
|
1527
1546
|
|
|
1528
1547
|
const numberHttpCode =
|
|
@@ -1864,9 +1883,10 @@ function getData(span) {
|
|
|
1864
1883
|
data['otel.kind'] = api.SpanKind[span.kind];
|
|
1865
1884
|
}
|
|
1866
1885
|
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1886
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
1887
|
+
const maybeHttpStatusCodeAttribute = attributes[semanticConventions.SEMATTRS_HTTP_STATUS_CODE];
|
|
1888
|
+
if (maybeHttpStatusCodeAttribute) {
|
|
1889
|
+
data[semanticConventions.ATTR_HTTP_RESPONSE_STATUS_CODE] = maybeHttpStatusCodeAttribute ;
|
|
1870
1890
|
}
|
|
1871
1891
|
|
|
1872
1892
|
const requestData = getRequestSpanData(span);
|
|
@@ -1998,13 +2018,13 @@ class SentrySampler {
|
|
|
1998
2018
|
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
1999
2019
|
}
|
|
2000
2020
|
|
|
2021
|
+
// `ATTR_HTTP_REQUEST_METHOD` is the new attribute, but we still support the old one, `SEMATTRS_HTTP_METHOD`, for now.
|
|
2022
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
2023
|
+
const maybeSpanHttpMethod = spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD] || spanAttributes[semanticConventions.ATTR_HTTP_REQUEST_METHOD];
|
|
2024
|
+
|
|
2001
2025
|
// If we have a http.client span that has no local parent, we never want to sample it
|
|
2002
2026
|
// 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
|
-
) {
|
|
2027
|
+
if (spanKind === api.SpanKind.CLIENT && maybeSpanHttpMethod && (!parentSpan || _optionalChain([parentContext, 'optionalAccess', _3 => _3.isRemote]))) {
|
|
2008
2028
|
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
2009
2029
|
}
|
|
2010
2030
|
|
|
@@ -2055,7 +2075,7 @@ class SentrySampler {
|
|
|
2055
2075
|
[core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate,
|
|
2056
2076
|
};
|
|
2057
2077
|
|
|
2058
|
-
const method = `${
|
|
2078
|
+
const method = `${maybeSpanHttpMethod}`.toUpperCase();
|
|
2059
2079
|
if (method === 'OPTIONS' || method === 'HEAD') {
|
|
2060
2080
|
DEBUG_BUILD && utils.logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
|
|
2061
2081
|
|
|
@@ -2144,7 +2164,9 @@ function getBaseTraceState(context, spanAttributes) {
|
|
|
2144
2164
|
let traceState = _optionalChain([parentContext, 'optionalAccess', _6 => _6.traceState]) || new core$1.TraceState();
|
|
2145
2165
|
|
|
2146
2166
|
// We always keep the URL on the trace state, so we can access it in the propagator
|
|
2147
|
-
|
|
2167
|
+
// `ATTR_URL_FULL` is the new attribute, but we still support the old one, `ATTR_HTTP_URL`, for now.
|
|
2168
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
2169
|
+
const url = spanAttributes[semanticConventions.SEMATTRS_HTTP_URL] || spanAttributes[semanticConventions.ATTR_URL_FULL];
|
|
2148
2170
|
if (url && typeof url === 'string') {
|
|
2149
2171
|
traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
|
|
2150
2172
|
}
|