@sentry/opentelemetry 8.0.0-beta.2 → 8.0.0-beta.4
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/cjs/index.js +33 -19
- package/cjs/index.js.map +1 -1
- package/esm/index.js +33 -19
- package/esm/index.js.map +1 -1
- package/package.json +5 -4
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/instrumentation.d.ts +7 -0
- package/types/instrumentation.d.ts.map +1 -0
- package/types/sampler.d.ts.map +1 -1
- package/types/setupEventContextTrace.d.ts.map +1 -1
- package/types/utils/parseSpanDescription.d.ts.map +1 -1
- package/types-ts3.8/index.d.ts +1 -1
- package/types-ts3.8/instrumentation.d.ts +7 -0
- package/types/custom/hub.d.ts +0 -7
- package/types/custom/hub.d.ts.map +0 -1
- package/types-ts3.8/custom/hub.d.ts +0 -7
package/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ const api = require('@opentelemetry/api');
|
|
|
10
10
|
const core = require('@sentry/core');
|
|
11
11
|
const core$1 = require('@opentelemetry/core');
|
|
12
12
|
const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
13
|
+
const instrumentation = require('@opentelemetry/instrumentation');
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Check if a given span has attributes.
|
|
@@ -288,7 +289,10 @@ function parseSpanDescription(span) {
|
|
|
288
289
|
const name = spanHasName(span) ? span.name : '<unknown>';
|
|
289
290
|
|
|
290
291
|
// if http.method exists, this is an http request span
|
|
291
|
-
|
|
292
|
+
//
|
|
293
|
+
// TODO: Referencing `http.request.method` is a temporary workaround until the semantic
|
|
294
|
+
// conventions export an attribute key for it.
|
|
295
|
+
const httpMethod = attributes['http.request.method'] || attributes[semanticConventions.SEMATTRS_HTTP_METHOD];
|
|
292
296
|
if (httpMethod) {
|
|
293
297
|
return descriptionForHttpMethod({ attributes, name, kind: getSpanKind(span) }, httpMethod);
|
|
294
298
|
}
|
|
@@ -1088,15 +1092,6 @@ function suppressTracing(callback) {
|
|
|
1088
1092
|
return api.context.with(ctx, callback);
|
|
1089
1093
|
}
|
|
1090
1094
|
|
|
1091
|
-
/**
|
|
1092
|
-
* Ensure the global hub is setup.
|
|
1093
|
-
*
|
|
1094
|
-
* @deprecated This will be removed in the next major version.
|
|
1095
|
-
*/
|
|
1096
|
-
function setupGlobalHub() {
|
|
1097
|
-
// noop
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
1095
|
/** Ensure the `trace` context is set on all events. */
|
|
1101
1096
|
function setupEventContextTrace(client) {
|
|
1102
1097
|
client.on('preprocessEvent', event => {
|
|
@@ -1119,12 +1114,13 @@ function setupEventContextTrace(client) {
|
|
|
1119
1114
|
...event.contexts,
|
|
1120
1115
|
};
|
|
1121
1116
|
|
|
1117
|
+
const rootSpan = core.getRootSpan(span);
|
|
1118
|
+
|
|
1122
1119
|
event.sdkProcessingMetadata = {
|
|
1123
|
-
dynamicSamplingContext: getDynamicSamplingContextFromSpan(
|
|
1120
|
+
dynamicSamplingContext: getDynamicSamplingContextFromSpan(rootSpan),
|
|
1124
1121
|
...event.sdkProcessingMetadata,
|
|
1125
1122
|
};
|
|
1126
1123
|
|
|
1127
|
-
const rootSpan = core.getRootSpan(span);
|
|
1128
1124
|
const transactionName = spanHasName(rootSpan) ? rootSpan.name : undefined;
|
|
1129
1125
|
if (transactionName && !event.transaction) {
|
|
1130
1126
|
event.transaction = transactionName;
|
|
@@ -1557,7 +1553,7 @@ function maybeSend(spans) {
|
|
|
1557
1553
|
transactionEvent.spans = spans;
|
|
1558
1554
|
|
|
1559
1555
|
const measurements = core.timedEventsToMeasurements(span.events);
|
|
1560
|
-
if (
|
|
1556
|
+
if (measurements) {
|
|
1561
1557
|
transactionEvent.measurements = measurements;
|
|
1562
1558
|
}
|
|
1563
1559
|
|
|
@@ -1695,6 +1691,7 @@ function createAndFinishSpanForOtelSpan(node, spans, remaining) {
|
|
|
1695
1691
|
op,
|
|
1696
1692
|
origin,
|
|
1697
1693
|
_metrics_summary: core.getMetricSummaryJsonForSpan(span ),
|
|
1694
|
+
measurements: core.timedEventsToMeasurements(span.events),
|
|
1698
1695
|
});
|
|
1699
1696
|
|
|
1700
1697
|
spans.push(spanJSON);
|
|
@@ -1899,11 +1896,18 @@ class SentrySampler {
|
|
|
1899
1896
|
|
|
1900
1897
|
const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
|
|
1901
1898
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1899
|
+
const mutableSamplingDecision = { decision: true };
|
|
1900
|
+
this._client.emit(
|
|
1901
|
+
'beforeSampling',
|
|
1902
|
+
{
|
|
1903
|
+
spanAttributes: spanAttributes,
|
|
1904
|
+
spanName: spanName,
|
|
1905
|
+
parentSampled: parentSampled,
|
|
1906
|
+
parentContext: parentContext,
|
|
1907
|
+
},
|
|
1908
|
+
mutableSamplingDecision,
|
|
1909
|
+
);
|
|
1910
|
+
if (!mutableSamplingDecision.decision) {
|
|
1907
1911
|
return { decision: sdkTraceBase.SamplingDecision.NOT_RECORD, traceState: traceState };
|
|
1908
1912
|
}
|
|
1909
1913
|
|
|
@@ -1981,11 +1985,22 @@ function getParentSampled(parentSpan, traceId, spanName) {
|
|
|
1981
1985
|
return undefined;
|
|
1982
1986
|
}
|
|
1983
1987
|
|
|
1988
|
+
/**
|
|
1989
|
+
* This method takes an OpenTelemetry instrumentation or
|
|
1990
|
+
* array of instrumentations and registers them with OpenTelemetry.
|
|
1991
|
+
*/
|
|
1992
|
+
function addOpenTelemetryInstrumentation(...instrumentations) {
|
|
1993
|
+
instrumentation.registerInstrumentations({
|
|
1994
|
+
instrumentations,
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1984
1998
|
exports.getClient = core.getClient;
|
|
1985
1999
|
exports.getCurrentHubShim = core.getCurrentHubShim;
|
|
1986
2000
|
exports.SentryPropagator = SentryPropagator;
|
|
1987
2001
|
exports.SentrySampler = SentrySampler;
|
|
1988
2002
|
exports.SentrySpanProcessor = SentrySpanProcessor;
|
|
2003
|
+
exports.addOpenTelemetryInstrumentation = addOpenTelemetryInstrumentation;
|
|
1989
2004
|
exports.continueTrace = continueTrace;
|
|
1990
2005
|
exports.getActiveSpan = getActiveSpan;
|
|
1991
2006
|
exports.getDynamicSamplingContextFromSpan = getDynamicSamplingContextFromSpan;
|
|
@@ -1996,7 +2011,6 @@ exports.isSentryRequestSpan = isSentryRequestSpan;
|
|
|
1996
2011
|
exports.openTelemetrySetupCheck = openTelemetrySetupCheck;
|
|
1997
2012
|
exports.setOpenTelemetryContextAsyncContextStrategy = setOpenTelemetryContextAsyncContextStrategy;
|
|
1998
2013
|
exports.setupEventContextTrace = setupEventContextTrace;
|
|
1999
|
-
exports.setupGlobalHub = setupGlobalHub;
|
|
2000
2014
|
exports.spanHasAttributes = spanHasAttributes;
|
|
2001
2015
|
exports.spanHasEvents = spanHasEvents;
|
|
2002
2016
|
exports.spanHasKind = spanHasKind;
|