@sentry/opentelemetry 8.25.0 → 8.27.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/README.md +2 -2
- package/build/cjs/index.js +35 -3
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +36 -4
- package/build/esm/index.js.map +1 -1
- package/build/types/asyncContextStrategy.d.ts.map +1 -1
- package/build/types/utils/getTraceData.d.ts +7 -0
- package/build/types/utils/getTraceData.d.ts.map +1 -0
- package/build/types/utils/parseSpanDescription.d.ts.map +1 -1
- package/build/types-ts3.8/utils/getTraceData.d.ts +7 -0
- package/package.json +4 -4
package/build/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { SEMATTRS_HTTP_URL, SEMATTRS_HTTP_METHOD, SEMATTRS_DB_SYSTEM, SEMATTRS_R
|
|
|
3
3
|
import { parseUrl, getSanitizedUrlString, addNonEnumerableProperty, stripUrlQueryAndFragment, dynamicSamplingContextToSentryBaggageHeader, baggageHeaderToDynamicSamplingContext, LRUMap, logger, parseBaggageHeader, SENTRY_BAGGAGE_KEY_PREFIX, generateSentryTraceHeader, propagationContextFromHeaders, stringMatchesSomePattern, dropUndefinedKeys } from '@sentry/utils';
|
|
4
4
|
import * as api from '@opentelemetry/api';
|
|
5
5
|
import { trace, SpanKind, createContextKey, TraceFlags, propagation, INVALID_TRACEID, context, SpanStatusCode, INVALID_SPANID, ROOT_CONTEXT, isSpanContextValid } from '@opentelemetry/api';
|
|
6
|
-
import { SDK_VERSION, isSentryRequestUrl, getClient, SEMANTIC_ATTRIBUTE_SENTRY_OP, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getDynamicSamplingContextFromSpan, getRootSpan, getCurrentScope, getIsolationScope, hasTracingEnabled, getDynamicSamplingContextFromClient, handleCallbackErrors, continueTrace as continueTrace$1, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, spanTimeInputToSeconds, getCapturedScopesOnSpan, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,
|
|
6
|
+
import { SDK_VERSION, isSentryRequestUrl, getClient, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, getDynamicSamplingContextFromSpan, getRootSpan, getCurrentScope, getIsolationScope, hasTracingEnabled, getDynamicSamplingContextFromClient, handleCallbackErrors, continueTrace as continueTrace$1, setAsyncContextStrategy, getDefaultCurrentScope, getDefaultIsolationScope, SPAN_STATUS_OK, SPAN_STATUS_ERROR, getSpanStatusFromHttpCode, timedEventsToMeasurements, captureEvent, spanTimeInputToSeconds, getCapturedScopesOnSpan, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, getStatusMessage, getMetricSummaryJsonForSpan, addChildSpanToSpan, setCapturedScopesOnSpan, logSpanStart, logSpanEnd, sampleSpan } from '@sentry/core';
|
|
7
7
|
export { getClient, getCurrentHubShim, getDynamicSamplingContextFromSpan } from '@sentry/core';
|
|
8
8
|
import { TraceState, W3CBaggagePropagator, isTracingSuppressed, suppressTracing as suppressTracing$1 } from '@opentelemetry/core';
|
|
9
9
|
import { SamplingDecision } from '@opentelemetry/sdk-trace-base';
|
|
@@ -399,10 +399,22 @@ function descriptionForHttpMethod(
|
|
|
399
399
|
data['http.fragment'] = fragment;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
+
// If the span kind is neither client nor server, we use the original name
|
|
403
|
+
// this infers that somebody manually started this span, in which case we don't want to overwrite the name
|
|
404
|
+
const isClientOrServerKind = kind === SpanKind.CLIENT || kind === SpanKind.SERVER;
|
|
405
|
+
|
|
406
|
+
// If the span is an auto-span (=it comes from one of our instrumentations),
|
|
407
|
+
// we always want to infer the name
|
|
408
|
+
// this is necessary because some of the auto-instrumentation we use uses kind=INTERNAL
|
|
409
|
+
const origin = attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] || 'manual';
|
|
410
|
+
const isManualSpan = !`${origin}`.startsWith('auto');
|
|
411
|
+
|
|
412
|
+
const useInferredDescription = isClientOrServerKind || !isManualSpan;
|
|
413
|
+
|
|
402
414
|
return {
|
|
403
415
|
op: opParts.join('.'),
|
|
404
|
-
description,
|
|
405
|
-
source,
|
|
416
|
+
description: useInferredDescription ? description : name,
|
|
417
|
+
source: useInferredDescription ? source : 'custom',
|
|
406
418
|
data,
|
|
407
419
|
};
|
|
408
420
|
}
|
|
@@ -1183,6 +1195,25 @@ function setupEventContextTrace(client) {
|
|
|
1183
1195
|
});
|
|
1184
1196
|
}
|
|
1185
1197
|
|
|
1198
|
+
/**
|
|
1199
|
+
* Otel-specific implementation of `getTraceData`.
|
|
1200
|
+
* @see `@sentry/core` version of `getTraceData` for more information
|
|
1201
|
+
*/
|
|
1202
|
+
function getTraceData() {
|
|
1203
|
+
const headersObject = {};
|
|
1204
|
+
|
|
1205
|
+
api.propagation.inject(api.context.active(), headersObject);
|
|
1206
|
+
|
|
1207
|
+
if (!headersObject['sentry-trace']) {
|
|
1208
|
+
return {};
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
return dropUndefinedKeys({
|
|
1212
|
+
'sentry-trace': headersObject['sentry-trace'],
|
|
1213
|
+
baggage: headersObject.baggage,
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1186
1217
|
/**
|
|
1187
1218
|
* Sets the async context strategy to use follow the OTEL context under the hood.
|
|
1188
1219
|
* We handle forking a hub inside of our custom OTEL Context Manager (./otelContextManager.ts)
|
|
@@ -1271,10 +1302,11 @@ function setOpenTelemetryContextAsyncContextStrategy() {
|
|
|
1271
1302
|
startSpanManual,
|
|
1272
1303
|
startInactiveSpan,
|
|
1273
1304
|
getActiveSpan,
|
|
1305
|
+
suppressTracing,
|
|
1306
|
+
getTraceData,
|
|
1274
1307
|
// The types here don't fully align, because our own `Span` type is narrower
|
|
1275
1308
|
// than the OTEL one - but this is OK for here, as we now we'll only have OTEL spans passed around
|
|
1276
1309
|
withActiveSpan: withActiveSpan ,
|
|
1277
|
-
suppressTracing: suppressTracing,
|
|
1278
1310
|
});
|
|
1279
1311
|
}
|
|
1280
1312
|
|