@sentry/opentelemetry 8.12.0 → 8.14.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/{cjs → build/cjs}/index.js +49 -19
- package/build/cjs/index.js.map +1 -0
- package/{esm → build/esm}/index.js +49 -20
- package/build/esm/index.js.map +1 -0
- package/{types → build/types}/index.d.ts +1 -1
- package/{types → build/types}/index.d.ts.map +1 -1
- package/{types → build/types}/sampler.d.ts +11 -0
- package/build/types/sampler.d.ts.map +1 -0
- package/{types-ts3.8 → build/types-ts3.8}/index.d.ts +1 -1
- package/{types-ts3.8 → build/types-ts3.8}/sampler.d.ts +11 -0
- package/package.json +47 -26
- package/cjs/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/types/sampler.d.ts.map +0 -1
- /package/{esm → build/esm}/package.json +0 -0
- /package/{types → build/types}/asyncContextStrategy.d.ts +0 -0
- /package/{types → build/types}/asyncContextStrategy.d.ts.map +0 -0
- /package/{types → build/types}/constants.d.ts +0 -0
- /package/{types → build/types}/constants.d.ts.map +0 -0
- /package/{types → build/types}/contextManager.d.ts +0 -0
- /package/{types → build/types}/contextManager.d.ts.map +0 -0
- /package/{types → build/types}/custom/client.d.ts +0 -0
- /package/{types → build/types}/custom/client.d.ts.map +0 -0
- /package/{types → build/types}/debug-build.d.ts +0 -0
- /package/{types → build/types}/debug-build.d.ts.map +0 -0
- /package/{types → build/types}/instrumentation.d.ts +0 -0
- /package/{types → build/types}/instrumentation.d.ts.map +0 -0
- /package/{types → build/types}/propagator.d.ts +0 -0
- /package/{types → build/types}/propagator.d.ts.map +0 -0
- /package/{types → build/types}/semanticAttributes.d.ts +0 -0
- /package/{types → build/types}/semanticAttributes.d.ts.map +0 -0
- /package/{types → build/types}/setupEventContextTrace.d.ts +0 -0
- /package/{types → build/types}/setupEventContextTrace.d.ts.map +0 -0
- /package/{types → build/types}/spanExporter.d.ts +0 -0
- /package/{types → build/types}/spanExporter.d.ts.map +0 -0
- /package/{types → build/types}/spanProcessor.d.ts +0 -0
- /package/{types → build/types}/spanProcessor.d.ts.map +0 -0
- /package/{types → build/types}/trace.d.ts +0 -0
- /package/{types → build/types}/trace.d.ts.map +0 -0
- /package/{types → build/types}/types.d.ts +0 -0
- /package/{types → build/types}/types.d.ts.map +0 -0
- /package/{types → build/types}/utils/addOriginToSpan.d.ts +0 -0
- /package/{types → build/types}/utils/addOriginToSpan.d.ts.map +0 -0
- /package/{types → build/types}/utils/contextData.d.ts +0 -0
- /package/{types → build/types}/utils/contextData.d.ts.map +0 -0
- /package/{types → build/types}/utils/convertOtelTimeToSeconds.d.ts +0 -0
- /package/{types → build/types}/utils/convertOtelTimeToSeconds.d.ts.map +0 -0
- /package/{types → build/types}/utils/enhanceDscWithOpenTelemetryRootSpanName.d.ts +0 -0
- /package/{types → build/types}/utils/enhanceDscWithOpenTelemetryRootSpanName.d.ts.map +0 -0
- /package/{types → build/types}/utils/getActiveSpan.d.ts +0 -0
- /package/{types → build/types}/utils/getActiveSpan.d.ts.map +0 -0
- /package/{types → build/types}/utils/getRequestSpanData.d.ts +0 -0
- /package/{types → build/types}/utils/getRequestSpanData.d.ts.map +0 -0
- /package/{types → build/types}/utils/getSamplingDecision.d.ts +0 -0
- /package/{types → build/types}/utils/getSamplingDecision.d.ts.map +0 -0
- /package/{types → build/types}/utils/getSpanKind.d.ts +0 -0
- /package/{types → build/types}/utils/getSpanKind.d.ts.map +0 -0
- /package/{types → build/types}/utils/groupSpansWithParents.d.ts +0 -0
- /package/{types → build/types}/utils/groupSpansWithParents.d.ts.map +0 -0
- /package/{types → build/types}/utils/isSentryRequest.d.ts +0 -0
- /package/{types → build/types}/utils/isSentryRequest.d.ts.map +0 -0
- /package/{types → build/types}/utils/mapStatus.d.ts +0 -0
- /package/{types → build/types}/utils/mapStatus.d.ts.map +0 -0
- /package/{types → build/types}/utils/parseSpanDescription.d.ts +0 -0
- /package/{types → build/types}/utils/parseSpanDescription.d.ts.map +0 -0
- /package/{types → build/types}/utils/setupCheck.d.ts +0 -0
- /package/{types → build/types}/utils/setupCheck.d.ts.map +0 -0
- /package/{types → build/types}/utils/spanTypes.d.ts +0 -0
- /package/{types → build/types}/utils/spanTypes.d.ts.map +0 -0
- /package/{types → build/types}/utils/suppressTracing.d.ts +0 -0
- /package/{types → build/types}/utils/suppressTracing.d.ts.map +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/asyncContextStrategy.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/constants.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/contextManager.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/custom/client.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/debug-build.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/instrumentation.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/propagator.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/semanticAttributes.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/setupEventContextTrace.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/spanExporter.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/spanProcessor.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/trace.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/types.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/addOriginToSpan.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/contextData.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/convertOtelTimeToSeconds.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/enhanceDscWithOpenTelemetryRootSpanName.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/getActiveSpan.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/getRequestSpanData.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/getSamplingDecision.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/getSpanKind.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/groupSpansWithParents.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/isSentryRequest.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/mapStatus.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/parseSpanDescription.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/setupCheck.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/spanTypes.d.ts +0 -0
- /package/{types-ts3.8 → build/types-ts3.8}/utils/suppressTracing.d.ts +0 -0
|
@@ -1917,16 +1917,8 @@ class SentrySampler {
|
|
|
1917
1917
|
const parentSpan = api.trace.getSpan(context);
|
|
1918
1918
|
const parentContext = _optionalChain([parentSpan, 'optionalAccess', _ => _.spanContext, 'call', _2 => _2()]);
|
|
1919
1919
|
|
|
1920
|
-
let traceState = _optionalChain([parentContext, 'optionalAccess', _3 => _3.traceState]) || new core$1.TraceState();
|
|
1921
|
-
|
|
1922
|
-
// We always keep the URL on the trace state, so we can access it in the propagator
|
|
1923
|
-
const url = spanAttributes[semanticConventions.SEMATTRS_HTTP_URL];
|
|
1924
|
-
if (url && typeof url === 'string') {
|
|
1925
|
-
traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
1920
|
if (!core.hasTracingEnabled(options)) {
|
|
1929
|
-
return { decision:
|
|
1921
|
+
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
1930
1922
|
}
|
|
1931
1923
|
|
|
1932
1924
|
// If we have a http.client span that has no local parent, we never want to sample it
|
|
@@ -1934,9 +1926,9 @@ class SentrySampler {
|
|
|
1934
1926
|
if (
|
|
1935
1927
|
spanKind === api.SpanKind.CLIENT &&
|
|
1936
1928
|
spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD] &&
|
|
1937
|
-
(!parentSpan || _optionalChain([parentContext, 'optionalAccess',
|
|
1929
|
+
(!parentSpan || _optionalChain([parentContext, 'optionalAccess', _3 => _3.isRemote]))
|
|
1938
1930
|
) {
|
|
1939
|
-
return { decision:
|
|
1931
|
+
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
1940
1932
|
}
|
|
1941
1933
|
|
|
1942
1934
|
const parentSampled = parentSpan ? getParentSampled(parentSpan, traceId, spanName) : undefined;
|
|
@@ -1953,7 +1945,7 @@ class SentrySampler {
|
|
|
1953
1945
|
mutableSamplingDecision,
|
|
1954
1946
|
);
|
|
1955
1947
|
if (!mutableSamplingDecision.decision) {
|
|
1956
|
-
return { decision:
|
|
1948
|
+
return wrapSamplingDecision({ decision: undefined, context, spanAttributes });
|
|
1957
1949
|
}
|
|
1958
1950
|
|
|
1959
1951
|
const [sampled, sampleRate] = core.sampleSpan(options, {
|
|
@@ -1973,25 +1965,22 @@ class SentrySampler {
|
|
|
1973
1965
|
const method = `${spanAttributes[semanticConventions.SEMATTRS_HTTP_METHOD]}`.toUpperCase();
|
|
1974
1966
|
if (method === 'OPTIONS' || method === 'HEAD') {
|
|
1975
1967
|
DEBUG_BUILD && utils.logger.log(`[Tracing] Not sampling span because HTTP method is '${method}' for ${spanName}`);
|
|
1968
|
+
|
|
1976
1969
|
return {
|
|
1977
|
-
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
1970
|
+
...wrapSamplingDecision({ decision: sdkTraceBase.SamplingDecision.NOT_RECORD, context, spanAttributes }),
|
|
1978
1971
|
attributes,
|
|
1979
|
-
traceState: traceState.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, '1'),
|
|
1980
1972
|
};
|
|
1981
1973
|
}
|
|
1982
1974
|
|
|
1983
1975
|
if (!sampled) {
|
|
1984
1976
|
return {
|
|
1985
|
-
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
1977
|
+
...wrapSamplingDecision({ decision: sdkTraceBase.SamplingDecision.NOT_RECORD, context, spanAttributes }),
|
|
1986
1978
|
attributes,
|
|
1987
|
-
traceState: traceState.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, '1'),
|
|
1988
1979
|
};
|
|
1989
1980
|
}
|
|
1990
|
-
|
|
1991
1981
|
return {
|
|
1992
|
-
decision: sdkTraceBase.SamplingDecision.RECORD_AND_SAMPLED,
|
|
1982
|
+
...wrapSamplingDecision({ decision: sdkTraceBase.SamplingDecision.RECORD_AND_SAMPLED, context, spanAttributes }),
|
|
1993
1983
|
attributes,
|
|
1994
|
-
traceState,
|
|
1995
1984
|
};
|
|
1996
1985
|
}
|
|
1997
1986
|
|
|
@@ -2030,6 +2019,46 @@ function getParentSampled(parentSpan, traceId, spanName) {
|
|
|
2030
2019
|
return undefined;
|
|
2031
2020
|
}
|
|
2032
2021
|
|
|
2022
|
+
/**
|
|
2023
|
+
* Wrap a sampling decision with data that Sentry needs to work properly with it.
|
|
2024
|
+
* If you pass `decision: undefined`, it will be treated as `NOT_RECORDING`, but in contrast to passing `NOT_RECORDING`
|
|
2025
|
+
* it will not propagate this decision to downstream Sentry SDKs.
|
|
2026
|
+
*/
|
|
2027
|
+
function wrapSamplingDecision({
|
|
2028
|
+
decision,
|
|
2029
|
+
context,
|
|
2030
|
+
spanAttributes,
|
|
2031
|
+
}) {
|
|
2032
|
+
const traceState = getBaseTraceState(context, spanAttributes);
|
|
2033
|
+
|
|
2034
|
+
// If the decision is undefined, we treat it as NOT_RECORDING, but we don't propagate this decision to downstream SDKs
|
|
2035
|
+
// Which is done by not setting `SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING` traceState
|
|
2036
|
+
if (decision == undefined) {
|
|
2037
|
+
return { decision: sdkTraceBase.SamplingDecision.NOT_RECORD, traceState };
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
if (decision === sdkTraceBase.SamplingDecision.NOT_RECORD) {
|
|
2041
|
+
return { decision, traceState: traceState.set(SENTRY_TRACE_STATE_SAMPLED_NOT_RECORDING, '1') };
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
return { decision, traceState };
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
function getBaseTraceState(context, spanAttributes) {
|
|
2048
|
+
const parentSpan = api.trace.getSpan(context);
|
|
2049
|
+
const parentContext = _optionalChain([parentSpan, 'optionalAccess', _4 => _4.spanContext, 'call', _5 => _5()]);
|
|
2050
|
+
|
|
2051
|
+
let traceState = _optionalChain([parentContext, 'optionalAccess', _6 => _6.traceState]) || new core$1.TraceState();
|
|
2052
|
+
|
|
2053
|
+
// We always keep the URL on the trace state, so we can access it in the propagator
|
|
2054
|
+
const url = spanAttributes[semanticConventions.SEMATTRS_HTTP_URL];
|
|
2055
|
+
if (url && typeof url === 'string') {
|
|
2056
|
+
traceState = traceState.set(SENTRY_TRACE_STATE_URL, url);
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
return traceState;
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2033
2062
|
/**
|
|
2034
2063
|
* This method takes an OpenTelemetry instrumentation or
|
|
2035
2064
|
* array of instrumentations and registers them with OpenTelemetry.
|
|
@@ -2070,4 +2099,5 @@ exports.suppressTracing = suppressTracing;
|
|
|
2070
2099
|
exports.withActiveSpan = withActiveSpan;
|
|
2071
2100
|
exports.wrapClientClass = wrapClientClass;
|
|
2072
2101
|
exports.wrapContextManagerClass = wrapContextManagerClass;
|
|
2102
|
+
exports.wrapSamplingDecision = wrapSamplingDecision;
|
|
2073
2103
|
//# sourceMappingURL=index.js.map
|