@sentry/opentelemetry 7.74.2-alpha.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/LICENSE +14 -0
- package/README.md +98 -0
- package/cjs/asyncContextStrategy.js +46 -0
- package/cjs/asyncContextStrategy.js.map +1 -0
- package/cjs/constants.js +18 -0
- package/cjs/constants.js.map +1 -0
- package/cjs/contextManager.js +59 -0
- package/cjs/contextManager.js.map +1 -0
- package/cjs/custom/client.js +81 -0
- package/cjs/custom/client.js.map +1 -0
- package/cjs/custom/hub.js +165 -0
- package/cjs/custom/hub.js.map +1 -0
- package/cjs/custom/hubextensions.js +34 -0
- package/cjs/custom/hubextensions.js.map +1 -0
- package/cjs/custom/scope.js +181 -0
- package/cjs/custom/scope.js.map +1 -0
- package/cjs/custom/transaction.js +52 -0
- package/cjs/custom/transaction.js.map +1 -0
- package/cjs/index.js +63 -0
- package/cjs/index.js.map +1 -0
- package/cjs/propagator.js +132 -0
- package/cjs/propagator.js.map +1 -0
- package/cjs/sampler.js +185 -0
- package/cjs/sampler.js.map +1 -0
- package/cjs/semanticAttributes.js +21 -0
- package/cjs/semanticAttributes.js.map +1 -0
- package/cjs/setupEventContextTrace.js +35 -0
- package/cjs/setupEventContextTrace.js.map +1 -0
- package/cjs/spanExporter.js +302 -0
- package/cjs/spanExporter.js.map +1 -0
- package/cjs/spanProcessor.js +88 -0
- package/cjs/spanProcessor.js.map +1 -0
- package/cjs/trace.js +107 -0
- package/cjs/trace.js.map +1 -0
- package/cjs/utils/addOriginToSpan.js +11 -0
- package/cjs/utils/addOriginToSpan.js.map +1 -0
- package/cjs/utils/captureExceptionForTimedEvent.js +58 -0
- package/cjs/utils/captureExceptionForTimedEvent.js.map +1 -0
- package/cjs/utils/contextData.js +41 -0
- package/cjs/utils/contextData.js.map +1 -0
- package/cjs/utils/convertOtelTimeToSeconds.js +9 -0
- package/cjs/utils/convertOtelTimeToSeconds.js.map +1 -0
- package/cjs/utils/getActiveSpan.js +29 -0
- package/cjs/utils/getActiveSpan.js.map +1 -0
- package/cjs/utils/getRequestSpanData.js +48 -0
- package/cjs/utils/getRequestSpanData.js.map +1 -0
- package/cjs/utils/getSpanKind.js +21 -0
- package/cjs/utils/getSpanKind.js.map +1 -0
- package/cjs/utils/groupSpansWithParents.js +74 -0
- package/cjs/utils/groupSpansWithParents.js.map +1 -0
- package/cjs/utils/isSentryRequest.js +29 -0
- package/cjs/utils/isSentryRequest.js.map +1 -0
- package/cjs/utils/mapStatus.js +76 -0
- package/cjs/utils/mapStatus.js.map +1 -0
- package/cjs/utils/parseSpanDescription.js +158 -0
- package/cjs/utils/parseSpanDescription.js.map +1 -0
- package/cjs/utils/spanData.js +59 -0
- package/cjs/utils/spanData.js.map +1 -0
- package/cjs/utils/spanTypes.js +77 -0
- package/cjs/utils/spanTypes.js.map +1 -0
- package/esm/asyncContextStrategy.js +41 -0
- package/esm/asyncContextStrategy.js.map +1 -0
- package/esm/constants.js +13 -0
- package/esm/constants.js.map +1 -0
- package/esm/contextManager.js +57 -0
- package/esm/contextManager.js.map +1 -0
- package/esm/custom/client.js +76 -0
- package/esm/custom/client.js.map +1 -0
- package/esm/custom/hub.js +159 -0
- package/esm/custom/hub.js.map +1 -0
- package/esm/custom/hubextensions.js +32 -0
- package/esm/custom/hubextensions.js.map +1 -0
- package/esm/custom/scope.js +179 -0
- package/esm/custom/scope.js.map +1 -0
- package/esm/custom/transaction.js +49 -0
- package/esm/custom/transaction.js.map +1 -0
- package/esm/index.js +32 -0
- package/esm/index.js.map +1 -0
- package/esm/propagator.js +127 -0
- package/esm/propagator.js.map +1 -0
- package/esm/sampler.js +183 -0
- package/esm/sampler.js.map +1 -0
- package/esm/semanticAttributes.js +19 -0
- package/esm/semanticAttributes.js.map +1 -0
- package/esm/setupEventContextTrace.js +33 -0
- package/esm/setupEventContextTrace.js.map +1 -0
- package/esm/spanExporter.js +300 -0
- package/esm/spanExporter.js.map +1 -0
- package/esm/spanProcessor.js +86 -0
- package/esm/spanProcessor.js.map +1 -0
- package/esm/trace.js +104 -0
- package/esm/trace.js.map +1 -0
- package/esm/utils/addOriginToSpan.js +9 -0
- package/esm/utils/addOriginToSpan.js.map +1 -0
- package/esm/utils/captureExceptionForTimedEvent.js +56 -0
- package/esm/utils/captureExceptionForTimedEvent.js.map +1 -0
- package/esm/utils/contextData.js +36 -0
- package/esm/utils/contextData.js.map +1 -0
- package/esm/utils/convertOtelTimeToSeconds.js +7 -0
- package/esm/utils/convertOtelTimeToSeconds.js.map +1 -0
- package/esm/utils/getActiveSpan.js +26 -0
- package/esm/utils/getActiveSpan.js.map +1 -0
- package/esm/utils/getRequestSpanData.js +46 -0
- package/esm/utils/getRequestSpanData.js.map +1 -0
- package/esm/utils/getSpanKind.js +19 -0
- package/esm/utils/getSpanKind.js.map +1 -0
- package/esm/utils/groupSpansWithParents.js +72 -0
- package/esm/utils/groupSpansWithParents.js.map +1 -0
- package/esm/utils/isSentryRequest.js +27 -0
- package/esm/utils/isSentryRequest.js.map +1 -0
- package/esm/utils/mapStatus.js +74 -0
- package/esm/utils/mapStatus.js.map +1 -0
- package/esm/utils/parseSpanDescription.js +154 -0
- package/esm/utils/parseSpanDescription.js.map +1 -0
- package/esm/utils/spanData.js +50 -0
- package/esm/utils/spanData.js.map +1 -0
- package/esm/utils/spanTypes.js +70 -0
- package/esm/utils/spanTypes.js.map +1 -0
- package/package.json +45 -0
- package/types/asyncContextStrategy.d.ts +6 -0
- package/types/asyncContextStrategy.d.ts.map +1 -0
- package/types/constants.d.ts +7 -0
- package/types/constants.d.ts.map +1 -0
- package/types/contextManager.d.ts +11 -0
- package/types/contextManager.d.ts.map +1 -0
- package/types/custom/client.d.ts +12 -0
- package/types/custom/client.d.ts.map +1 -0
- package/types/custom/hub.d.ts +40 -0
- package/types/custom/hub.d.ts.map +1 -0
- package/types/custom/hubextensions.d.ts +5 -0
- package/types/custom/hubextensions.d.ts.map +1 -0
- package/types/custom/scope.d.ts +34 -0
- package/types/custom/scope.d.ts.map +1 -0
- package/types/custom/transaction.d.ts +17 -0
- package/types/custom/transaction.d.ts.map +1 -0
- package/types/index.d.ts +31 -0
- package/types/index.d.ts.map +1 -0
- package/types/propagator.d.ts +20 -0
- package/types/propagator.d.ts.map +1 -0
- package/types/sampler.d.ts +15 -0
- package/types/sampler.d.ts.map +1 -0
- package/types/semanticAttributes.d.ts +17 -0
- package/types/semanticAttributes.d.ts.map +1 -0
- package/types/setupEventContextTrace.d.ts +4 -0
- package/types/setupEventContextTrace.d.ts.map +1 -0
- package/types/spanExporter.d.ts +17 -0
- package/types/spanExporter.d.ts.map +1 -0
- package/types/spanProcessor.d.ts +22 -0
- package/types/spanProcessor.d.ts.map +1 -0
- package/types/trace.d.ts +28 -0
- package/types/trace.d.ts.map +1 -0
- package/types/types.d.ts +26 -0
- package/types/types.d.ts.map +1 -0
- package/types/utils/addOriginToSpan.d.ts +5 -0
- package/types/utils/addOriginToSpan.d.ts.map +1 -0
- package/types/utils/captureExceptionForTimedEvent.d.ts +8 -0
- package/types/utils/captureExceptionForTimedEvent.d.ts.map +1 -0
- package/types/utils/contextData.d.ts +23 -0
- package/types/utils/contextData.d.ts.map +1 -0
- package/types/utils/convertOtelTimeToSeconds.d.ts +3 -0
- package/types/utils/convertOtelTimeToSeconds.d.ts.map +1 -0
- package/types/utils/getActiveSpan.d.ts +11 -0
- package/types/utils/getActiveSpan.d.ts.map +1 -0
- package/types/utils/getRequestSpanData.d.ts +8 -0
- package/types/utils/getRequestSpanData.d.ts.map +1 -0
- package/types/utils/getSpanKind.d.ts +10 -0
- package/types/utils/getSpanKind.d.ts.map +1 -0
- package/types/utils/groupSpansWithParents.d.ts +13 -0
- package/types/utils/groupSpansWithParents.d.ts.map +1 -0
- package/types/utils/isSentryRequest.d.ts +8 -0
- package/types/utils/isSentryRequest.d.ts.map +1 -0
- package/types/utils/mapStatus.d.ts +7 -0
- package/types/utils/mapStatus.d.ts.map +1 -0
- package/types/utils/parseSpanDescription.d.ts +32 -0
- package/types/utils/parseSpanDescription.d.ts.map +1 -0
- package/types/utils/spanData.d.ts +20 -0
- package/types/utils/spanData.d.ts.map +1 -0
- package/types/utils/spanTypes.d.ts +52 -0
- package/types/utils/spanTypes.d.ts.map +1 -0
- package/types-ts3.8/asyncContextStrategy.d.ts +6 -0
- package/types-ts3.8/constants.d.ts +7 -0
- package/types-ts3.8/contextManager.d.ts +11 -0
- package/types-ts3.8/custom/client.d.ts +12 -0
- package/types-ts3.8/custom/hub.d.ts +40 -0
- package/types-ts3.8/custom/hubextensions.d.ts +5 -0
- package/types-ts3.8/custom/scope.d.ts +34 -0
- package/types-ts3.8/custom/transaction.d.ts +17 -0
- package/types-ts3.8/index.d.ts +31 -0
- package/types-ts3.8/propagator.d.ts +20 -0
- package/types-ts3.8/sampler.d.ts +15 -0
- package/types-ts3.8/semanticAttributes.d.ts +17 -0
- package/types-ts3.8/setupEventContextTrace.d.ts +4 -0
- package/types-ts3.8/spanExporter.d.ts +17 -0
- package/types-ts3.8/spanProcessor.d.ts +22 -0
- package/types-ts3.8/trace.d.ts +28 -0
- package/types-ts3.8/types.d.ts +26 -0
- package/types-ts3.8/utils/addOriginToSpan.d.ts +5 -0
- package/types-ts3.8/utils/captureExceptionForTimedEvent.d.ts +8 -0
- package/types-ts3.8/utils/contextData.d.ts +23 -0
- package/types-ts3.8/utils/convertOtelTimeToSeconds.d.ts +6 -0
- package/types-ts3.8/utils/getActiveSpan.d.ts +11 -0
- package/types-ts3.8/utils/getRequestSpanData.d.ts +8 -0
- package/types-ts3.8/utils/getSpanKind.d.ts +10 -0
- package/types-ts3.8/utils/groupSpansWithParents.d.ts +13 -0
- package/types-ts3.8/utils/isSentryRequest.d.ts +8 -0
- package/types-ts3.8/utils/mapStatus.d.ts +7 -0
- package/types-ts3.8/utils/parseSpanDescription.d.ts +32 -0
- package/types-ts3.8/utils/spanData.d.ts +20 -0
- package/types-ts3.8/utils/spanTypes.d.ts +52 -0
package/cjs/sampler.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
const api = require('@opentelemetry/api');
|
|
4
|
+
const sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
5
|
+
const core = require('@sentry/core');
|
|
6
|
+
const utils = require('@sentry/utils');
|
|
7
|
+
const semanticAttributes = require('./semanticAttributes.js');
|
|
8
|
+
const contextData = require('./utils/contextData.js');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A custom OTEL sampler that uses Sentry sampling rates to make it's decision
|
|
12
|
+
*/
|
|
13
|
+
class SentrySampler {
|
|
14
|
+
|
|
15
|
+
constructor(client) {
|
|
16
|
+
this._client = client;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @inheritDoc */
|
|
20
|
+
shouldSample(
|
|
21
|
+
context,
|
|
22
|
+
traceId,
|
|
23
|
+
spanName,
|
|
24
|
+
_spanKind,
|
|
25
|
+
_attributes,
|
|
26
|
+
_links,
|
|
27
|
+
) {
|
|
28
|
+
const options = this._client.getOptions();
|
|
29
|
+
|
|
30
|
+
if (!core.hasTracingEnabled(options)) {
|
|
31
|
+
return { decision: sdkTraceBase.SamplingDecision.NOT_RECORD };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const parentContext = api.trace.getSpanContext(context);
|
|
35
|
+
|
|
36
|
+
let parentSampled = undefined;
|
|
37
|
+
|
|
38
|
+
// Only inherit sample rate if `traceId` is the same
|
|
39
|
+
// Note for testing: `isSpanContextValid()` checks the format of the traceId/spanId, so we need to pass valid ones
|
|
40
|
+
if (parentContext && api.isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
|
|
41
|
+
if (parentContext.isRemote) {
|
|
42
|
+
parentSampled = getParentRemoteSampled(parentContext, context);
|
|
43
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
44
|
+
utils.logger.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);
|
|
45
|
+
} else {
|
|
46
|
+
parentSampled = Boolean(parentContext.traceFlags & api.TraceFlags.SAMPLED);
|
|
47
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
48
|
+
utils.logger.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sampleRate = getSampleRate(options, {
|
|
53
|
+
transactionContext: {
|
|
54
|
+
name: spanName,
|
|
55
|
+
parentSampled,
|
|
56
|
+
},
|
|
57
|
+
parentSampled,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const attributes = {
|
|
61
|
+
[semanticAttributes.InternalSentrySemanticAttributes.SAMPLE_RATE]: Number(sampleRate),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if (typeof parentSampled === 'boolean') {
|
|
65
|
+
attributes[semanticAttributes.InternalSentrySemanticAttributes.PARENT_SAMPLED] = parentSampled;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
|
|
69
|
+
// only valid values are booleans or numbers between 0 and 1.)
|
|
70
|
+
if (!isValidSampleRate(sampleRate)) {
|
|
71
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.warn('[Tracing] Discarding span because of invalid sample rate.');
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
75
|
+
attributes,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped
|
|
80
|
+
if (!sampleRate) {
|
|
81
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
82
|
+
utils.logger.log(
|
|
83
|
+
`[Tracing] Discarding span because ${
|
|
84
|
+
typeof options.tracesSampler === 'function'
|
|
85
|
+
? 'tracesSampler returned 0 or false'
|
|
86
|
+
: 'a negative sampling decision was inherited or tracesSampleRate is set to 0'
|
|
87
|
+
}`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
92
|
+
attributes,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is
|
|
97
|
+
// a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.
|
|
98
|
+
const isSampled = Math.random() < (sampleRate );
|
|
99
|
+
|
|
100
|
+
// if we're not going to keep it, we're done
|
|
101
|
+
if (!isSampled) {
|
|
102
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
103
|
+
utils.logger.log(
|
|
104
|
+
`[Tracing] Discarding span because it's not included in the random sample (sampling rate = ${Number(
|
|
105
|
+
sampleRate,
|
|
106
|
+
)})`,
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
decision: sdkTraceBase.SamplingDecision.NOT_RECORD,
|
|
111
|
+
attributes,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
decision: sdkTraceBase.SamplingDecision.RECORD_AND_SAMPLED,
|
|
117
|
+
attributes,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Returns the sampler name or short description with the configuration. */
|
|
122
|
+
toString() {
|
|
123
|
+
return 'SentrySampler';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function getSampleRate(
|
|
128
|
+
options,
|
|
129
|
+
samplingContext,
|
|
130
|
+
) {
|
|
131
|
+
if (typeof options.tracesSampler === 'function') {
|
|
132
|
+
return options.tracesSampler(samplingContext);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (samplingContext.parentSampled !== undefined) {
|
|
136
|
+
return samplingContext.parentSampled;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (typeof options.tracesSampleRate !== 'undefined') {
|
|
140
|
+
return options.tracesSampleRate;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// When `enableTracing === true`, we use a sample rate of 100%
|
|
144
|
+
if (options.enableTracing) {
|
|
145
|
+
return 1;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
|
|
153
|
+
*/
|
|
154
|
+
function isValidSampleRate(rate) {
|
|
155
|
+
// we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
157
|
+
if (utils.isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {
|
|
158
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
159
|
+
utils.logger.warn(
|
|
160
|
+
`[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
|
|
161
|
+
rate,
|
|
162
|
+
)} of type ${JSON.stringify(typeof rate)}.`,
|
|
163
|
+
);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
|
|
168
|
+
if (rate < 0 || rate > 1) {
|
|
169
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
170
|
+
utils.logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`);
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getParentRemoteSampled(spanContext, context) {
|
|
177
|
+
const traceId = spanContext.traceId;
|
|
178
|
+
const traceparentData = contextData.getPropagationContextFromContext(context);
|
|
179
|
+
|
|
180
|
+
// Only inherit sample rate if `traceId` is the same
|
|
181
|
+
return traceparentData && traceId === traceparentData.traceId ? traceparentData.sampled : undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
exports.SentrySampler = SentrySampler;
|
|
185
|
+
//# sourceMappingURL=sampler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sampler.js","sources":["../../src/sampler.ts"],"sourcesContent":["/* eslint-disable no-bitwise */\nimport type { Attributes, Context, SpanContext } from '@opentelemetry/api';\nimport { isSpanContextValid, trace, TraceFlags } from '@opentelemetry/api';\nimport type { Sampler, SamplingResult } from '@opentelemetry/sdk-trace-base';\nimport { SamplingDecision } from '@opentelemetry/sdk-trace-base';\nimport { hasTracingEnabled } from '@sentry/core';\nimport type { Client, ClientOptions, SamplingContext } from '@sentry/types';\nimport { isNaN, logger } from '@sentry/utils';\n\nimport { InternalSentrySemanticAttributes } from './semanticAttributes';\nimport { getPropagationContextFromContext } from './utils/contextData';\n\n/**\n * A custom OTEL sampler that uses Sentry sampling rates to make it's decision\n */\nexport class SentrySampler implements Sampler {\n private _client: Client;\n\n public constructor(client: Client) {\n this._client = client;\n }\n\n /** @inheritDoc */\n public shouldSample(\n context: Context,\n traceId: string,\n spanName: string,\n _spanKind: unknown,\n _attributes: unknown,\n _links: unknown,\n ): SamplingResult {\n const options = this._client.getOptions();\n\n if (!hasTracingEnabled(options)) {\n return { decision: SamplingDecision.NOT_RECORD };\n }\n\n const parentContext = trace.getSpanContext(context);\n\n let parentSampled: boolean | undefined = undefined;\n\n // Only inherit sample rate if `traceId` is the same\n // Note for testing: `isSpanContextValid()` checks the format of the traceId/spanId, so we need to pass valid ones\n if (parentContext && isSpanContextValid(parentContext) && parentContext.traceId === traceId) {\n if (parentContext.isRemote) {\n parentSampled = getParentRemoteSampled(parentContext, context);\n __DEBUG_BUILD__ &&\n logger.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);\n } else {\n parentSampled = Boolean(parentContext.traceFlags & TraceFlags.SAMPLED);\n __DEBUG_BUILD__ &&\n logger.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);\n }\n }\n\n const sampleRate = getSampleRate(options, {\n transactionContext: {\n name: spanName,\n parentSampled,\n },\n parentSampled,\n });\n\n const attributes: Attributes = {\n [InternalSentrySemanticAttributes.SAMPLE_RATE]: Number(sampleRate),\n };\n\n if (typeof parentSampled === 'boolean') {\n attributes[InternalSentrySemanticAttributes.PARENT_SAMPLED] = parentSampled;\n }\n\n // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The\n // only valid values are booleans or numbers between 0 and 1.)\n if (!isValidSampleRate(sampleRate)) {\n __DEBUG_BUILD__ && logger.warn('[Tracing] Discarding span because of invalid sample rate.');\n\n return {\n decision: SamplingDecision.NOT_RECORD,\n attributes,\n };\n }\n\n // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped\n if (!sampleRate) {\n __DEBUG_BUILD__ &&\n logger.log(\n `[Tracing] Discarding span because ${\n typeof options.tracesSampler === 'function'\n ? 'tracesSampler returned 0 or false'\n : 'a negative sampling decision was inherited or tracesSampleRate is set to 0'\n }`,\n );\n\n return {\n decision: SamplingDecision.NOT_RECORD,\n attributes,\n };\n }\n\n // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is\n // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.\n const isSampled = Math.random() < (sampleRate as number | boolean);\n\n // if we're not going to keep it, we're done\n if (!isSampled) {\n __DEBUG_BUILD__ &&\n logger.log(\n `[Tracing] Discarding span because it's not included in the random sample (sampling rate = ${Number(\n sampleRate,\n )})`,\n );\n\n return {\n decision: SamplingDecision.NOT_RECORD,\n attributes,\n };\n }\n\n return {\n decision: SamplingDecision.RECORD_AND_SAMPLED,\n attributes,\n };\n }\n\n /** Returns the sampler name or short description with the configuration. */\n public toString(): string {\n return 'SentrySampler';\n }\n}\n\nfunction getSampleRate(\n options: Pick<ClientOptions, 'tracesSampleRate' | 'tracesSampler' | 'enableTracing'>,\n samplingContext: SamplingContext,\n): number | boolean {\n if (typeof options.tracesSampler === 'function') {\n return options.tracesSampler(samplingContext);\n }\n\n if (samplingContext.parentSampled !== undefined) {\n return samplingContext.parentSampled;\n }\n\n if (typeof options.tracesSampleRate !== 'undefined') {\n return options.tracesSampleRate;\n }\n\n // When `enableTracing === true`, we use a sample rate of 100%\n if (options.enableTracing) {\n return 1;\n }\n\n return 0;\n}\n\n/**\n * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).\n */\nfunction isValidSampleRate(rate: unknown): boolean {\n // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {\n __DEBUG_BUILD__ &&\n logger.warn(\n `[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(\n rate,\n )} of type ${JSON.stringify(typeof rate)}.`,\n );\n return false;\n }\n\n // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false\n if (rate < 0 || rate > 1) {\n __DEBUG_BUILD__ &&\n logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`);\n return false;\n }\n return true;\n}\n\nfunction getParentRemoteSampled(spanContext: SpanContext, context: Context): boolean | undefined {\n const traceId = spanContext.traceId;\n const traceparentData = getPropagationContextFromContext(context);\n\n // Only inherit sample rate if `traceId` is the same\n return traceparentData && traceId === traceparentData.traceId ? traceparentData.sampled : undefined;\n}\n"],"names":["hasTracingEnabled","SamplingDecision","trace","isSpanContextValid","logger","TraceFlags","InternalSentrySemanticAttributes","isNaN","getPropagationContextFromContext"],"mappings":";;;;;;;;;AAYA;AACA;AACA;AACA,MAAA,aAAA,EAAA;;AAGA,GAAA,WAAA,CAAA,MAAA,EAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,MAAA,CAAA;AACA,GAAA;AACA;AACA;AACA,GAAA,YAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,QAAA;AACA,IAAA,SAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA;AACA,IAAA,MAAA,OAAA,GAAA,IAAA,CAAA,OAAA,CAAA,UAAA,EAAA,CAAA;AACA;AACA,IAAA,IAAA,CAAAA,sBAAA,CAAA,OAAA,CAAA,EAAA;AACA,MAAA,OAAA,EAAA,QAAA,EAAAC,6BAAA,CAAA,UAAA,EAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,MAAA,aAAA,GAAAC,SAAA,CAAA,cAAA,CAAA,OAAA,CAAA,CAAA;AACA;AACA,IAAA,IAAA,aAAA,GAAA,SAAA,CAAA;AACA;AACA;AACA;AACA,IAAA,IAAA,aAAA,IAAAC,sBAAA,CAAA,aAAA,CAAA,IAAA,aAAA,CAAA,OAAA,KAAA,OAAA,EAAA;AACA,MAAA,IAAA,aAAA,CAAA,QAAA,EAAA;AACA,QAAA,aAAA,GAAA,sBAAA,CAAA,aAAA,EAAA,OAAA,CAAA,CAAA;AACA,QAAA,CAAA,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;AACA,UAAAC,YAAA,CAAA,GAAA,CAAA,CAAA,0DAAA,EAAA,QAAA,CAAA,EAAA,EAAA,aAAA,CAAA,CAAA,CAAA,CAAA;AACA,OAAA,MAAA;AACA,QAAA,aAAA,GAAA,OAAA,CAAA,aAAA,CAAA,UAAA,GAAAC,cAAA,CAAA,OAAA,CAAA,CAAA;AACA,QAAA,CAAA,OAAA,gBAAA,KAAA,WAAA,IAAA,gB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A,CAAA,IAAA,EAAA,OAAA,IAAA,KAAA,QAAA,IAAA,OAAA,IAAA,KAAA,SAAA,CAAA,EAAA;AACA,IAAA,CAAA,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;AACA,MAAAH,YAAA,CAAA,IAAA;AACA,QAAA,CAAA,uGAAA,EAAA,IAAA,CAAA,SAAA;AACA,UAAA,IAAA;AACA,SAAA,CAAA,SAAA,EAAA,IAAA,CAAA,SAAA,CAAA,OAAA,IAAA,CAAA,CAAA,CAAA,CAAA;AACA,OAAA,CAAA;AACA,IAAA,OAAA,KAAA,CAAA;AACA,GAAA;AACA;AACA;AACA,EAAA,IAAA,IAAA,GAAA,CAAA,IAAA,IAAA,GAAA,CAAA,EAAA;AACA,IAAA,CAAA,OAAA,gBAAA,KAAA,WAAA,IAAA,gBAAA;AACA,MAAAA,YAAA,CAAA,IAAA,CAAA,CAAA,iFAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACA,IAAA,OAAA,KAAA,CAAA;AACA,GAAA;AACA,EAAA,OAAA,IAAA,CAAA;AACA,CAAA;AACA;AACA,SAAA,sBAAA,CAAA,WAAA,EAAA,OAAA,EAAA;AACA,EAAA,MAAA,OAAA,GAAA,WAAA,CAAA,OAAA,CAAA;AACA,EAAA,MAAA,eAAA,GAAAI,4CAAA,CAAA,OAAA,CAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,eAAA,IAAA,OAAA,KAAA,eAAA,CAAA,OAAA,GAAA,eAAA,CAAA,OAAA,GAAA,SAAA,CAAA;AACA;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* These are internal and are not supposed to be used/depended on by external parties.
|
|
5
|
+
* No guarantees apply to these attributes, and the may change/disappear at any time.
|
|
6
|
+
*/
|
|
7
|
+
const InternalSentrySemanticAttributes = {
|
|
8
|
+
ORIGIN: 'sentry.origin',
|
|
9
|
+
OP: 'sentry.op',
|
|
10
|
+
SOURCE: 'sentry.source',
|
|
11
|
+
SAMPLE_RATE: 'sentry.sample_rate',
|
|
12
|
+
PARENT_SAMPLED: 'sentry.parentSampled',
|
|
13
|
+
BREADCRUMB_TYPE: 'sentry.breadcrumb.type',
|
|
14
|
+
BREADCRUMB_LEVEL: 'sentry.breadcrumb.level',
|
|
15
|
+
BREADCRUMB_EVENT_ID: 'sentry.breadcrumb.event_id',
|
|
16
|
+
BREADCRUMB_CATEGORY: 'sentry.breadcrumb.category',
|
|
17
|
+
BREADCRUMB_DATA: 'sentry.breadcrumb.data',
|
|
18
|
+
} ;
|
|
19
|
+
|
|
20
|
+
exports.InternalSentrySemanticAttributes = InternalSentrySemanticAttributes;
|
|
21
|
+
//# sourceMappingURL=semanticAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticAttributes.js","sources":["../../src/semanticAttributes.ts"],"sourcesContent":["/**\n * These are internal and are not supposed to be used/depended on by external parties.\n * No guarantees apply to these attributes, and the may change/disappear at any time.\n */\nexport const InternalSentrySemanticAttributes = {\n ORIGIN: 'sentry.origin',\n OP: 'sentry.op',\n SOURCE: 'sentry.source',\n SAMPLE_RATE: 'sentry.sample_rate',\n PARENT_SAMPLED: 'sentry.parentSampled',\n BREADCRUMB_TYPE: 'sentry.breadcrumb.type',\n BREADCRUMB_LEVEL: 'sentry.breadcrumb.level',\n BREADCRUMB_EVENT_ID: 'sentry.breadcrumb.event_id',\n BREADCRUMB_CATEGORY: 'sentry.breadcrumb.category',\n BREADCRUMB_DATA: 'sentry.breadcrumb.data',\n} as const;\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA,MAAA,gCAAA,GAAA;AACA,EAAA,MAAA,EAAA,eAAA;AACA,EAAA,EAAA,EAAA,WAAA;AACA,EAAA,MAAA,EAAA,eAAA;AACA,EAAA,WAAA,EAAA,oBAAA;AACA,EAAA,cAAA,EAAA,sBAAA;AACA,EAAA,eAAA,EAAA,wBAAA;AACA,EAAA,gBAAA,EAAA,yBAAA;AACA,EAAA,mBAAA,EAAA,4BAAA;AACA,EAAA,mBAAA,EAAA,4BAAA;AACA,EAAA,eAAA,EAAA,wBAAA;AACA,CAAA;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
const getActiveSpan = require('./utils/getActiveSpan.js');
|
|
4
|
+
const spanTypes = require('./utils/spanTypes.js');
|
|
5
|
+
|
|
6
|
+
/** Ensure the `trace` context is set on all events. */
|
|
7
|
+
function setupEventContextTrace(client) {
|
|
8
|
+
if (!client.addEventProcessor) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
client.addEventProcessor(event => {
|
|
13
|
+
const span = getActiveSpan.getActiveSpan();
|
|
14
|
+
if (!span) {
|
|
15
|
+
return event;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const spanContext = span.spanContext();
|
|
19
|
+
|
|
20
|
+
// If event has already set `trace` context, use that one.
|
|
21
|
+
event.contexts = {
|
|
22
|
+
trace: {
|
|
23
|
+
trace_id: spanContext.traceId,
|
|
24
|
+
span_id: spanContext.spanId,
|
|
25
|
+
parent_span_id: spanTypes.spanHasParentId(span) ? span.parentSpanId : undefined,
|
|
26
|
+
},
|
|
27
|
+
...event.contexts,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return event;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.setupEventContextTrace = setupEventContextTrace;
|
|
35
|
+
//# sourceMappingURL=setupEventContextTrace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupEventContextTrace.js","sources":["../../src/setupEventContextTrace.ts"],"sourcesContent":["import type { Client } from '@sentry/types';\n\nimport { getActiveSpan } from './utils/getActiveSpan';\nimport { spanHasParentId } from './utils/spanTypes';\n\n/** Ensure the `trace` context is set on all events. */\nexport function setupEventContextTrace(client: Client): void {\n if (!client.addEventProcessor) {\n return;\n }\n\n client.addEventProcessor(event => {\n const span = getActiveSpan();\n if (!span) {\n return event;\n }\n\n const spanContext = span.spanContext();\n\n // If event has already set `trace` context, use that one.\n event.contexts = {\n trace: {\n trace_id: spanContext.traceId,\n span_id: spanContext.spanId,\n parent_span_id: spanHasParentId(span) ? span.parentSpanId : undefined,\n },\n ...event.contexts,\n };\n\n return event;\n });\n}\n"],"names":["getActiveSpan","spanHasParentId"],"mappings":";;;;;AAKA;AACA,SAAA,sBAAA,CAAA,MAAA,EAAA;AACA,EAAA,IAAA,CAAA,MAAA,CAAA,iBAAA,EAAA;AACA,IAAA,OAAA;AACA,GAAA;AACA;AACA,EAAA,MAAA,CAAA,iBAAA,CAAA,KAAA,IAAA;AACA,IAAA,MAAA,IAAA,GAAAA,2BAAA,EAAA,CAAA;AACA,IAAA,IAAA,CAAA,IAAA,EAAA;AACA,MAAA,OAAA,KAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,MAAA,WAAA,GAAA,IAAA,CAAA,WAAA,EAAA,CAAA;AACA;AACA;AACA,IAAA,KAAA,CAAA,QAAA,GAAA;AACA,MAAA,KAAA,EAAA;AACA,QAAA,QAAA,EAAA,WAAA,CAAA,OAAA;AACA,QAAA,OAAA,EAAA,WAAA,CAAA,MAAA;AACA,QAAA,cAAA,EAAAC,yBAAA,CAAA,IAAA,CAAA,GAAA,IAAA,CAAA,YAAA,GAAA,SAAA;AACA,OAAA;AACA,MAAA,GAAA,KAAA,CAAA,QAAA;AACA,KAAA,CAAA;AACA;AACA,IAAA,OAAA,KAAA,CAAA;AACA,GAAA,CAAA,CAAA;AACA;;;;"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
const api = require('@opentelemetry/api');
|
|
4
|
+
const core = require('@opentelemetry/core');
|
|
5
|
+
const semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
6
|
+
const core$1 = require('@sentry/core');
|
|
7
|
+
const utils = require('@sentry/utils');
|
|
8
|
+
const hub = require('./custom/hub.js');
|
|
9
|
+
const scope = require('./custom/scope.js');
|
|
10
|
+
const transaction = require('./custom/transaction.js');
|
|
11
|
+
const semanticAttributes = require('./semanticAttributes.js');
|
|
12
|
+
const convertOtelTimeToSeconds = require('./utils/convertOtelTimeToSeconds.js');
|
|
13
|
+
const getRequestSpanData = require('./utils/getRequestSpanData.js');
|
|
14
|
+
const groupSpansWithParents = require('./utils/groupSpansWithParents.js');
|
|
15
|
+
const mapStatus = require('./utils/mapStatus.js');
|
|
16
|
+
const parseSpanDescription = require('./utils/parseSpanDescription.js');
|
|
17
|
+
const spanData = require('./utils/spanData.js');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
|
|
21
|
+
*/
|
|
22
|
+
class SentrySpanExporter {
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
this._stopped = false;
|
|
26
|
+
this._finishedSpans = [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** @inheritDoc */
|
|
30
|
+
export(spans, resultCallback) {
|
|
31
|
+
if (this._stopped) {
|
|
32
|
+
return resultCallback({
|
|
33
|
+
code: core.ExportResultCode.FAILED,
|
|
34
|
+
error: new Error('Exporter has been stopped'),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const openSpanCount = this._finishedSpans.length;
|
|
39
|
+
const newSpanCount = spans.length;
|
|
40
|
+
|
|
41
|
+
this._finishedSpans.push(...spans);
|
|
42
|
+
|
|
43
|
+
const remainingSpans = maybeSend(this._finishedSpans);
|
|
44
|
+
|
|
45
|
+
const remainingOpenSpanCount = remainingSpans.length;
|
|
46
|
+
const sentSpanCount = openSpanCount + newSpanCount - remainingOpenSpanCount;
|
|
47
|
+
|
|
48
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
49
|
+
utils.logger.log(`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} unsent spans remaining`);
|
|
50
|
+
|
|
51
|
+
this._finishedSpans = remainingSpans.filter(span => {
|
|
52
|
+
const shouldDrop = shouldCleanupSpan(span, 5 * 60);
|
|
53
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
54
|
+
shouldDrop &&
|
|
55
|
+
utils.logger.log(
|
|
56
|
+
`SpanExporter dropping span ${span.name} (${
|
|
57
|
+
span.spanContext().spanId
|
|
58
|
+
}) because it is pending for more than 5 minutes.`,
|
|
59
|
+
);
|
|
60
|
+
return !shouldDrop;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
resultCallback({ code: core.ExportResultCode.SUCCESS });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** @inheritDoc */
|
|
67
|
+
shutdown() {
|
|
68
|
+
this._stopped = true;
|
|
69
|
+
this._finishedSpans = [];
|
|
70
|
+
return this.forceFlush();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** @inheritDoc */
|
|
74
|
+
async forceFlush() {
|
|
75
|
+
await core$1.flush();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Send the given spans, but only if they are part of a finished transaction.
|
|
81
|
+
*
|
|
82
|
+
* Returns the unsent spans.
|
|
83
|
+
* Spans remain unsent when their parent span is not yet finished.
|
|
84
|
+
* This will happen regularly, as child spans are generally finished before their parents.
|
|
85
|
+
* But it _could_ also happen because, for whatever reason, a parent span was lost.
|
|
86
|
+
* In this case, we'll eventually need to clean this up.
|
|
87
|
+
*/
|
|
88
|
+
function maybeSend(spans) {
|
|
89
|
+
const grouped = groupSpansWithParents.groupSpansWithParents(spans);
|
|
90
|
+
const remaining = new Set(grouped);
|
|
91
|
+
|
|
92
|
+
const rootNodes = getCompletedRootNodes(grouped);
|
|
93
|
+
|
|
94
|
+
rootNodes.forEach(root => {
|
|
95
|
+
remaining.delete(root);
|
|
96
|
+
const span = root.span;
|
|
97
|
+
const transaction = createTransactionForOtelSpan(span);
|
|
98
|
+
|
|
99
|
+
root.children.forEach(child => {
|
|
100
|
+
createAndFinishSpanForOtelSpan(child, transaction, remaining);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// Now finish the transaction, which will send it together with all the spans
|
|
104
|
+
// We make sure to use the current span as the activeSpan for this transaction
|
|
105
|
+
const scope$1 = spanData.getSpanScope(span);
|
|
106
|
+
const forkedScope = scope.OpenTelemetryScope.clone(scope$1 ) ;
|
|
107
|
+
forkedScope.activeSpan = span ;
|
|
108
|
+
|
|
109
|
+
transaction.finishWithScope(convertOtelTimeToSeconds.convertOtelTimeToSeconds(span.endTime), forkedScope);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return Array.from(remaining)
|
|
113
|
+
.map(node => node.span)
|
|
114
|
+
.filter((span) => !!span);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function getCompletedRootNodes(nodes) {
|
|
118
|
+
return nodes.filter((node) => !!node.span && !node.parentNode);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function shouldCleanupSpan(span, maxStartTimeOffsetSeconds) {
|
|
122
|
+
const cutoff = Date.now() / 1000 - maxStartTimeOffsetSeconds;
|
|
123
|
+
return convertOtelTimeToSeconds.convertOtelTimeToSeconds(span.startTime) < cutoff;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function parseSpan(span) {
|
|
127
|
+
const attributes = span.attributes;
|
|
128
|
+
|
|
129
|
+
const origin = attributes[semanticAttributes.InternalSentrySemanticAttributes.ORIGIN] ;
|
|
130
|
+
const op = attributes[semanticAttributes.InternalSentrySemanticAttributes.OP] ;
|
|
131
|
+
const source = attributes[semanticAttributes.InternalSentrySemanticAttributes.SOURCE] ;
|
|
132
|
+
|
|
133
|
+
return { origin, op, source };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function createTransactionForOtelSpan(span) {
|
|
137
|
+
const scope = spanData.getSpanScope(span);
|
|
138
|
+
const hub$1 = spanData.getSpanHub(span) || hub.getCurrentHub();
|
|
139
|
+
const spanContext = span.spanContext();
|
|
140
|
+
const spanId = spanContext.spanId;
|
|
141
|
+
const traceId = spanContext.traceId;
|
|
142
|
+
const parentSpanId = span.parentSpanId;
|
|
143
|
+
|
|
144
|
+
const parentSampled = span.attributes[semanticAttributes.InternalSentrySemanticAttributes.PARENT_SAMPLED] ;
|
|
145
|
+
const dynamicSamplingContext = scope
|
|
146
|
+
? scope.getPropagationContext().dsc
|
|
147
|
+
: undefined;
|
|
148
|
+
|
|
149
|
+
const { op, description, tags, data, origin, source } = getSpanData(span);
|
|
150
|
+
const metadata = spanData.getSpanMetadata(span);
|
|
151
|
+
|
|
152
|
+
const transaction$1 = transaction.startTransaction(hub$1, {
|
|
153
|
+
spanId,
|
|
154
|
+
traceId,
|
|
155
|
+
parentSpanId,
|
|
156
|
+
parentSampled,
|
|
157
|
+
name: description,
|
|
158
|
+
op,
|
|
159
|
+
instrumenter: 'otel',
|
|
160
|
+
status: mapStatus.mapStatus(span),
|
|
161
|
+
startTimestamp: convertOtelTimeToSeconds.convertOtelTimeToSeconds(span.startTime),
|
|
162
|
+
metadata: {
|
|
163
|
+
dynamicSamplingContext,
|
|
164
|
+
source,
|
|
165
|
+
sampleRate: span.attributes[semanticAttributes.InternalSentrySemanticAttributes.SAMPLE_RATE] ,
|
|
166
|
+
...metadata,
|
|
167
|
+
},
|
|
168
|
+
data: removeSentryAttributes(data),
|
|
169
|
+
origin,
|
|
170
|
+
tags,
|
|
171
|
+
sampled: true,
|
|
172
|
+
}) ;
|
|
173
|
+
|
|
174
|
+
transaction$1.setContext('otel', {
|
|
175
|
+
attributes: removeSentryAttributes(span.attributes),
|
|
176
|
+
resource: span.resource.attributes,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return transaction$1;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function createAndFinishSpanForOtelSpan(node, sentryParentSpan, remaining) {
|
|
183
|
+
remaining.delete(node);
|
|
184
|
+
const span = node.span;
|
|
185
|
+
|
|
186
|
+
const shouldDrop = !span;
|
|
187
|
+
|
|
188
|
+
// If this span should be dropped, we still want to create spans for the children of this
|
|
189
|
+
if (shouldDrop) {
|
|
190
|
+
node.children.forEach(child => {
|
|
191
|
+
createAndFinishSpanForOtelSpan(child, sentryParentSpan, remaining);
|
|
192
|
+
});
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const spanId = span.spanContext().spanId;
|
|
197
|
+
const { attributes } = span;
|
|
198
|
+
|
|
199
|
+
const { op, description, tags, data, origin } = getSpanData(span);
|
|
200
|
+
const allData = { ...removeSentryAttributes(attributes), ...data };
|
|
201
|
+
|
|
202
|
+
const sentrySpan = sentryParentSpan.startChild({
|
|
203
|
+
description,
|
|
204
|
+
op,
|
|
205
|
+
data: allData,
|
|
206
|
+
status: mapStatus.mapStatus(span),
|
|
207
|
+
instrumenter: 'otel',
|
|
208
|
+
startTimestamp: convertOtelTimeToSeconds.convertOtelTimeToSeconds(span.startTime),
|
|
209
|
+
spanId,
|
|
210
|
+
origin,
|
|
211
|
+
tags,
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
node.children.forEach(child => {
|
|
215
|
+
createAndFinishSpanForOtelSpan(child, sentrySpan, remaining);
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
sentrySpan.finish(convertOtelTimeToSeconds.convertOtelTimeToSeconds(span.endTime));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function getSpanData(span)
|
|
222
|
+
|
|
223
|
+
{
|
|
224
|
+
const { op: definedOp, source: definedSource, origin } = parseSpan(span);
|
|
225
|
+
const { op: inferredOp, description, source: inferredSource, data: inferredData } = parseSpanDescription.parseSpanDescription(span);
|
|
226
|
+
|
|
227
|
+
const op = definedOp || inferredOp;
|
|
228
|
+
const source = definedSource || inferredSource;
|
|
229
|
+
|
|
230
|
+
const tags = getTags(span);
|
|
231
|
+
const data = { ...inferredData, ...getData(span) };
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
op,
|
|
235
|
+
description,
|
|
236
|
+
source,
|
|
237
|
+
origin,
|
|
238
|
+
tags,
|
|
239
|
+
data,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Remove custom `sentry.` attribtues we do not need to send.
|
|
245
|
+
* These are more carrier attributes we use inside of the SDK, we do not need to send them to the API.
|
|
246
|
+
*/
|
|
247
|
+
function removeSentryAttributes(data) {
|
|
248
|
+
const cleanedData = { ...data };
|
|
249
|
+
|
|
250
|
+
/* eslint-disable @typescript-eslint/no-dynamic-delete */
|
|
251
|
+
delete cleanedData[semanticAttributes.InternalSentrySemanticAttributes.PARENT_SAMPLED];
|
|
252
|
+
delete cleanedData[semanticAttributes.InternalSentrySemanticAttributes.ORIGIN];
|
|
253
|
+
delete cleanedData[semanticAttributes.InternalSentrySemanticAttributes.OP];
|
|
254
|
+
delete cleanedData[semanticAttributes.InternalSentrySemanticAttributes.SOURCE];
|
|
255
|
+
delete cleanedData[semanticAttributes.InternalSentrySemanticAttributes.SAMPLE_RATE];
|
|
256
|
+
/* eslint-enable @typescript-eslint/no-dynamic-delete */
|
|
257
|
+
|
|
258
|
+
return cleanedData;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function getTags(span) {
|
|
262
|
+
const attributes = span.attributes;
|
|
263
|
+
const tags = {};
|
|
264
|
+
|
|
265
|
+
if (attributes[semanticConventions.SemanticAttributes.HTTP_STATUS_CODE]) {
|
|
266
|
+
const statusCode = attributes[semanticConventions.SemanticAttributes.HTTP_STATUS_CODE] ;
|
|
267
|
+
|
|
268
|
+
tags['http.status_code'] = statusCode;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return tags;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getData(span) {
|
|
275
|
+
const attributes = span.attributes;
|
|
276
|
+
const data = {
|
|
277
|
+
'otel.kind': api.SpanKind[span.kind],
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
if (attributes[semanticConventions.SemanticAttributes.HTTP_STATUS_CODE]) {
|
|
281
|
+
const statusCode = attributes[semanticConventions.SemanticAttributes.HTTP_STATUS_CODE] ;
|
|
282
|
+
data['http.response.status_code'] = statusCode;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const requestData = getRequestSpanData.getRequestSpanData(span);
|
|
286
|
+
|
|
287
|
+
if (requestData.url) {
|
|
288
|
+
data.url = requestData.url;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (requestData['http.query']) {
|
|
292
|
+
data['http.query'] = requestData['http.query'].slice(1);
|
|
293
|
+
}
|
|
294
|
+
if (requestData['http.fragment']) {
|
|
295
|
+
data['http.fragment'] = requestData['http.fragment'].slice(1);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return data;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
exports.SentrySpanExporter = SentrySpanExporter;
|
|
302
|
+
//# sourceMappingURL=spanExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spanExporter.js","sources":["../../src/spanExporter.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { SpanKind } from '@opentelemetry/api';\nimport type { ExportResult } from '@opentelemetry/core';\nimport { ExportResultCode } from '@opentelemetry/core';\nimport type { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport { flush } from '@sentry/core';\nimport type { DynamicSamplingContext, Span as SentrySpan, SpanOrigin, TransactionSource } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport { getCurrentHub } from './custom/hub';\nimport { OpenTelemetryScope } from './custom/scope';\nimport type { OpenTelemetryTransaction } from './custom/transaction';\nimport { startTransaction } from './custom/transaction';\nimport { InternalSentrySemanticAttributes } from './semanticAttributes';\nimport { convertOtelTimeToSeconds } from './utils/convertOtelTimeToSeconds';\nimport { getRequestSpanData } from './utils/getRequestSpanData';\nimport type { SpanNode } from './utils/groupSpansWithParents';\nimport { groupSpansWithParents } from './utils/groupSpansWithParents';\nimport { mapStatus } from './utils/mapStatus';\nimport { parseSpanDescription } from './utils/parseSpanDescription';\nimport { getSpanHub, getSpanMetadata, getSpanScope } from './utils/spanData';\n\ntype SpanNodeCompleted = SpanNode & { span: ReadableSpan };\n\n/**\n * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.\n */\nexport class SentrySpanExporter implements SpanExporter {\n private _finishedSpans: ReadableSpan[];\n private _stopped: boolean;\n\n public constructor() {\n this._stopped = false;\n this._finishedSpans = [];\n }\n\n /** @inheritDoc */\n public export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void {\n if (this._stopped) {\n return resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been stopped'),\n });\n }\n\n const openSpanCount = this._finishedSpans.length;\n const newSpanCount = spans.length;\n\n this._finishedSpans.push(...spans);\n\n const remainingSpans = maybeSend(this._finishedSpans);\n\n const remainingOpenSpanCount = remainingSpans.length;\n const sentSpanCount = openSpanCount + newSpanCount - remainingOpenSpanCount;\n\n __DEBUG_BUILD__ &&\n logger.log(`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} unsent spans remaining`);\n\n this._finishedSpans = remainingSpans.filter(span => {\n const shouldDrop = shouldCleanupSpan(span, 5 * 60);\n __DEBUG_BUILD__ &&\n shouldDrop &&\n logger.log(\n `SpanExporter dropping span ${span.name} (${\n span.spanContext().spanId\n }) because it is pending for more than 5 minutes.`,\n );\n return !shouldDrop;\n });\n\n resultCallback({ code: ExportResultCode.SUCCESS });\n }\n\n /** @inheritDoc */\n public shutdown(): Promise<void> {\n this._stopped = true;\n this._finishedSpans = [];\n return this.forceFlush();\n }\n\n /** @inheritDoc */\n public async forceFlush(): Promise<void> {\n await flush();\n }\n}\n\n/**\n * Send the given spans, but only if they are part of a finished transaction.\n *\n * Returns the unsent spans.\n * Spans remain unsent when their parent span is not yet finished.\n * This will happen regularly, as child spans are generally finished before their parents.\n * But it _could_ also happen because, for whatever reason, a parent span was lost.\n * In this case, we'll eventually need to clean this up.\n */\nfunction maybeSend(spans: ReadableSpan[]): ReadableSpan[] {\n const grouped = groupSpansWithParents(spans);\n const remaining = new Set(grouped);\n\n const rootNodes = getCompletedRootNodes(grouped);\n\n rootNodes.forEach(root => {\n remaining.delete(root);\n const span = root.span;\n const transaction = createTransactionForOtelSpan(span);\n\n root.children.forEach(child => {\n createAndFinishSpanForOtelSpan(child, transaction, remaining);\n });\n\n // Now finish the transaction, which will send it together with all the spans\n // We make sure to use the current span as the activeSpan for this transaction\n const scope = getSpanScope(span);\n const forkedScope = OpenTelemetryScope.clone(scope as OpenTelemetryScope | undefined) as OpenTelemetryScope;\n forkedScope.activeSpan = span as unknown as Span;\n\n transaction.finishWithScope(convertOtelTimeToSeconds(span.endTime), forkedScope);\n });\n\n return Array.from(remaining)\n .map(node => node.span)\n .filter((span): span is ReadableSpan => !!span);\n}\n\nfunction getCompletedRootNodes(nodes: SpanNode[]): SpanNodeCompleted[] {\n return nodes.filter((node): node is SpanNodeCompleted => !!node.span && !node.parentNode);\n}\n\nfunction shouldCleanupSpan(span: ReadableSpan, maxStartTimeOffsetSeconds: number): boolean {\n const cutoff = Date.now() / 1000 - maxStartTimeOffsetSeconds;\n return convertOtelTimeToSeconds(span.startTime) < cutoff;\n}\n\nfunction parseSpan(span: ReadableSpan): { op?: string; origin?: SpanOrigin; source?: TransactionSource } {\n const attributes = span.attributes;\n\n const origin = attributes[InternalSentrySemanticAttributes.ORIGIN] as SpanOrigin | undefined;\n const op = attributes[InternalSentrySemanticAttributes.OP] as string | undefined;\n const source = attributes[InternalSentrySemanticAttributes.SOURCE] as TransactionSource | undefined;\n\n return { origin, op, source };\n}\n\nfunction createTransactionForOtelSpan(span: ReadableSpan): OpenTelemetryTransaction {\n const scope = getSpanScope(span);\n const hub = getSpanHub(span) || getCurrentHub();\n const spanContext = span.spanContext();\n const spanId = spanContext.spanId;\n const traceId = spanContext.traceId;\n const parentSpanId = span.parentSpanId;\n\n const parentSampled = span.attributes[InternalSentrySemanticAttributes.PARENT_SAMPLED] as boolean | undefined;\n const dynamicSamplingContext: DynamicSamplingContext | undefined = scope\n ? scope.getPropagationContext().dsc\n : undefined;\n\n const { op, description, tags, data, origin, source } = getSpanData(span);\n const metadata = getSpanMetadata(span);\n\n const transaction = startTransaction(hub, {\n spanId,\n traceId,\n parentSpanId,\n parentSampled,\n name: description,\n op,\n instrumenter: 'otel',\n status: mapStatus(span),\n startTimestamp: convertOtelTimeToSeconds(span.startTime),\n metadata: {\n dynamicSamplingContext,\n source,\n sampleRate: span.attributes[InternalSentrySemanticAttributes.SAMPLE_RATE] as number | undefined,\n ...metadata,\n },\n data: removeSentryAttributes(data),\n origin,\n tags,\n sampled: true,\n }) as OpenTelemetryTransaction;\n\n transaction.setContext('otel', {\n attributes: removeSentryAttributes(span.attributes),\n resource: span.resource.attributes,\n });\n\n return transaction;\n}\n\nfunction createAndFinishSpanForOtelSpan(node: SpanNode, sentryParentSpan: SentrySpan, remaining: Set<SpanNode>): void {\n remaining.delete(node);\n const span = node.span;\n\n const shouldDrop = !span;\n\n // If this span should be dropped, we still want to create spans for the children of this\n if (shouldDrop) {\n node.children.forEach(child => {\n createAndFinishSpanForOtelSpan(child, sentryParentSpan, remaining);\n });\n return;\n }\n\n const spanId = span.spanContext().spanId;\n const { attributes } = span;\n\n const { op, description, tags, data, origin } = getSpanData(span);\n const allData = { ...removeSentryAttributes(attributes), ...data };\n\n const sentrySpan = sentryParentSpan.startChild({\n description,\n op,\n data: allData,\n status: mapStatus(span),\n instrumenter: 'otel',\n startTimestamp: convertOtelTimeToSeconds(span.startTime),\n spanId,\n origin,\n tags,\n });\n\n node.children.forEach(child => {\n createAndFinishSpanForOtelSpan(child, sentrySpan, remaining);\n });\n\n sentrySpan.finish(convertOtelTimeToSeconds(span.endTime));\n}\n\nfunction getSpanData(span: ReadableSpan): {\n tags: Record<string, string>;\n data: Record<string, unknown>;\n op?: string;\n description: string;\n source?: TransactionSource;\n origin?: SpanOrigin;\n} {\n const { op: definedOp, source: definedSource, origin } = parseSpan(span);\n const { op: inferredOp, description, source: inferredSource, data: inferredData } = parseSpanDescription(span);\n\n const op = definedOp || inferredOp;\n const source = definedSource || inferredSource;\n\n const tags = getTags(span);\n const data = { ...inferredData, ...getData(span) };\n\n return {\n op,\n description,\n source,\n origin,\n tags,\n data,\n };\n}\n\n/**\n * Remove custom `sentry.` attribtues we do not need to send.\n * These are more carrier attributes we use inside of the SDK, we do not need to send them to the API.\n */\nfunction removeSentryAttributes(data: Record<string, unknown>): Record<string, unknown> {\n const cleanedData = { ...data };\n\n /* eslint-disable @typescript-eslint/no-dynamic-delete */\n delete cleanedData[InternalSentrySemanticAttributes.PARENT_SAMPLED];\n delete cleanedData[InternalSentrySemanticAttributes.ORIGIN];\n delete cleanedData[InternalSentrySemanticAttributes.OP];\n delete cleanedData[InternalSentrySemanticAttributes.SOURCE];\n delete cleanedData[InternalSentrySemanticAttributes.SAMPLE_RATE];\n /* eslint-enable @typescript-eslint/no-dynamic-delete */\n\n return cleanedData;\n}\n\nfunction getTags(span: ReadableSpan): Record<string, string> {\n const attributes = span.attributes;\n const tags: Record<string, string> = {};\n\n if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) {\n const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string;\n\n tags['http.status_code'] = statusCode;\n }\n\n return tags;\n}\n\nfunction getData(span: ReadableSpan): Record<string, unknown> {\n const attributes = span.attributes;\n const data: Record<string, unknown> = {\n 'otel.kind': SpanKind[span.kind],\n };\n\n if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) {\n const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] as string;\n data['http.response.status_code'] = statusCode;\n }\n\n const requestData = getRequestSpanData(span);\n\n if (requestData.url) {\n data.url = requestData.url;\n }\n\n if (requestData['http.query']) {\n data['http.query'] = requestData['http.query'].slice(1);\n }\n if (requestData['http.fragment']) {\n data['http.fragment'] = requestData['http.fragment'].slice(1);\n }\n\n return data;\n}\n"],"names":["ExportResultCode","logger","flush","groupSpansWithParents","scope","getSpanScope","OpenTelemetryScope","convertOtelTimeToSeconds","InternalSentrySemanticAttributes","hub","getSpanHub","getCurrentHub","getSpanMetadata","transaction","startTransaction","mapStatus","parseSpanDescription","SemanticAttributes","SpanKind","getRequestSpanData"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA;AACA;AACA;AACA,MAAA,kBAAA,EAAA;;AAIA,GAAA,WAAA,GAAA;AACA,IAAA,IAAA,CAAA,QAAA,GAAA,KAAA,CAAA;AACA,IAAA,IAAA,CAAA,cAAA,GAAA,EAAA,CAAA;AACA,GAAA;AACA;AACA;AACA,GAAA,MAAA,CAAA,KAAA,EAAA,cAAA,EAAA;AACA,IAAA,IAAA,IAAA,CAAA,QAAA,EAAA;AACA,MAAA,OAAA,cAAA,CAAA;AACA,QAAA,IAAA,EAAAA,qBAAA,CAAA,MAAA;AACA,QAAA,KAAA,EAAA,IAAA,KAAA,CAAA,2BAAA,CAAA;AACA,OAAA,CAAA,CAAA;AACA,KAAA;AACA;AACA,IAAA,MAAA,aAAA,GAAA,IAAA,CAAA,cAAA,CAAA,MAAA,CAAA;AACA,IAAA,MAAA,YAAA,GAAA,KAAA,CAAA,MAAA,CAAA;AACA;AACA,IAAA,IAAA,CAAA,cAAA,CAAA,IAAA,CAAA,GAAA,KAAA,CAAA,CAAA;AACA;AACA,IAAA,MAAA,cAAA,GAAA,SAAA,CAAA,IAAA,CAAA,cAAA,CAAA,CAAA;AACA;AACA,IAAA,MAAA,sBAAA,GAAA,cAAA,CAAA,MAAA,CAAA;AACA,IAAA,MAAA,aAA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