@sentry/opentelemetry 8.0.0-alpha.2 → 8.0.0-alpha.3

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.
Files changed (176) hide show
  1. package/README.md +2 -1
  2. package/cjs/index.js +2120 -55
  3. package/cjs/index.js.map +1 -1
  4. package/esm/index.js +2091 -23
  5. package/esm/index.js.map +1 -1
  6. package/esm/package.json +1 -0
  7. package/package.json +18 -5
  8. package/types/asyncContextStrategy.d.ts.map +1 -1
  9. package/types/constants.d.ts +2 -3
  10. package/types/constants.d.ts.map +1 -1
  11. package/types/contextManager.d.ts.map +1 -1
  12. package/types/custom/getCurrentHub.d.ts.map +1 -1
  13. package/types/index.d.ts +4 -6
  14. package/types/index.d.ts.map +1 -1
  15. package/types/propagator.d.ts +16 -1
  16. package/types/propagator.d.ts.map +1 -1
  17. package/types/sampler.d.ts.map +1 -1
  18. package/types/semanticAttributes.d.ts +2 -7
  19. package/types/semanticAttributes.d.ts.map +1 -1
  20. package/types/setupEventContextTrace.d.ts.map +1 -1
  21. package/types/spanExporter.d.ts.map +1 -1
  22. package/types/spanProcessor.d.ts.map +1 -1
  23. package/types/trace.d.ts +14 -1
  24. package/types/trace.d.ts.map +1 -1
  25. package/types/types.d.ts +3 -4
  26. package/types/types.d.ts.map +1 -1
  27. package/types/utils/captureExceptionForTimedEvent.d.ts +1 -2
  28. package/types/utils/captureExceptionForTimedEvent.d.ts.map +1 -1
  29. package/types/utils/contextData.d.ts +1 -11
  30. package/types/utils/contextData.d.ts.map +1 -1
  31. package/types/utils/dynamicSamplingContext.d.ts.map +1 -1
  32. package/types/utils/getActiveSpan.d.ts +0 -5
  33. package/types/utils/getActiveSpan.d.ts.map +1 -1
  34. package/types/utils/groupSpansWithParents.d.ts.map +1 -1
  35. package/types/utils/spanData.d.ts +1 -14
  36. package/types/utils/spanData.d.ts.map +1 -1
  37. package/types-ts3.8/constants.d.ts +2 -3
  38. package/types-ts3.8/index.d.ts +4 -6
  39. package/types-ts3.8/propagator.d.ts +16 -1
  40. package/types-ts3.8/semanticAttributes.d.ts +2 -7
  41. package/types-ts3.8/trace.d.ts +14 -1
  42. package/types-ts3.8/types.d.ts +3 -4
  43. package/types-ts3.8/utils/captureExceptionForTimedEvent.d.ts +1 -2
  44. package/types-ts3.8/utils/contextData.d.ts +1 -11
  45. package/types-ts3.8/utils/getActiveSpan.d.ts +0 -5
  46. package/types-ts3.8/utils/spanData.d.ts +1 -14
  47. package/cjs/asyncContextStrategy.js +0 -114
  48. package/cjs/asyncContextStrategy.js.map +0 -1
  49. package/cjs/constants.js +0 -30
  50. package/cjs/constants.js.map +0 -1
  51. package/cjs/contextManager.js +0 -87
  52. package/cjs/contextManager.js.map +0 -1
  53. package/cjs/custom/client.js +0 -64
  54. package/cjs/custom/client.js.map +0 -1
  55. package/cjs/custom/getCurrentHub.js +0 -106
  56. package/cjs/custom/getCurrentHub.js.map +0 -1
  57. package/cjs/custom/hub.js +0 -13
  58. package/cjs/custom/hub.js.map +0 -1
  59. package/cjs/custom/hubextensions.js +0 -37
  60. package/cjs/custom/hubextensions.js.map +0 -1
  61. package/cjs/custom/transaction.js +0 -26
  62. package/cjs/custom/transaction.js.map +0 -1
  63. package/cjs/debug-build.js +0 -11
  64. package/cjs/debug-build.js.map +0 -1
  65. package/cjs/propagator.js +0 -217
  66. package/cjs/propagator.js.map +0 -1
  67. package/cjs/sampler.js +0 -188
  68. package/cjs/sampler.js.map +0 -1
  69. package/cjs/semanticAttributes.js +0 -12
  70. package/cjs/semanticAttributes.js.map +0 -1
  71. package/cjs/setupEventContextTrace.js +0 -40
  72. package/cjs/setupEventContextTrace.js.map +0 -1
  73. package/cjs/spanExporter.js +0 -307
  74. package/cjs/spanExporter.js.map +0 -1
  75. package/cjs/spanProcessor.js +0 -98
  76. package/cjs/spanProcessor.js.map +0 -1
  77. package/cjs/trace.js +0 -222
  78. package/cjs/trace.js.map +0 -1
  79. package/cjs/utils/addOriginToSpan.js +0 -11
  80. package/cjs/utils/addOriginToSpan.js.map +0 -1
  81. package/cjs/utils/captureExceptionForTimedEvent.js +0 -59
  82. package/cjs/utils/captureExceptionForTimedEvent.js.map +0 -1
  83. package/cjs/utils/contextData.js +0 -61
  84. package/cjs/utils/contextData.js.map +0 -1
  85. package/cjs/utils/convertOtelTimeToSeconds.js +0 -9
  86. package/cjs/utils/convertOtelTimeToSeconds.js.map +0 -1
  87. package/cjs/utils/dynamicSamplingContext.js +0 -64
  88. package/cjs/utils/dynamicSamplingContext.js.map +0 -1
  89. package/cjs/utils/getActiveSpan.js +0 -29
  90. package/cjs/utils/getActiveSpan.js.map +0 -1
  91. package/cjs/utils/getRequestSpanData.js +0 -48
  92. package/cjs/utils/getRequestSpanData.js.map +0 -1
  93. package/cjs/utils/getSpanKind.js +0 -21
  94. package/cjs/utils/getSpanKind.js.map +0 -1
  95. package/cjs/utils/groupSpansWithParents.js +0 -74
  96. package/cjs/utils/groupSpansWithParents.js.map +0 -1
  97. package/cjs/utils/isSentryRequest.js +0 -29
  98. package/cjs/utils/isSentryRequest.js.map +0 -1
  99. package/cjs/utils/mapStatus.js +0 -77
  100. package/cjs/utils/mapStatus.js.map +0 -1
  101. package/cjs/utils/parseSpanDescription.js +0 -158
  102. package/cjs/utils/parseSpanDescription.js.map +0 -1
  103. package/cjs/utils/setupCheck.js +0 -17
  104. package/cjs/utils/setupCheck.js.map +0 -1
  105. package/cjs/utils/spanData.js +0 -72
  106. package/cjs/utils/spanData.js.map +0 -1
  107. package/cjs/utils/spanTypes.js +0 -77
  108. package/cjs/utils/spanTypes.js.map +0 -1
  109. package/esm/asyncContextStrategy.js +0 -112
  110. package/esm/asyncContextStrategy.js.map +0 -1
  111. package/esm/constants.js +0 -20
  112. package/esm/constants.js.map +0 -1
  113. package/esm/contextManager.js +0 -82
  114. package/esm/contextManager.js.map +0 -1
  115. package/esm/custom/client.js +0 -59
  116. package/esm/custom/client.js.map +0 -1
  117. package/esm/custom/getCurrentHub.js +0 -101
  118. package/esm/custom/getCurrentHub.js.map +0 -1
  119. package/esm/custom/hub.js +0 -11
  120. package/esm/custom/hub.js.map +0 -1
  121. package/esm/custom/hubextensions.js +0 -35
  122. package/esm/custom/hubextensions.js.map +0 -1
  123. package/esm/custom/transaction.js +0 -24
  124. package/esm/custom/transaction.js.map +0 -1
  125. package/esm/debug-build.js +0 -9
  126. package/esm/debug-build.js.map +0 -1
  127. package/esm/propagator.js +0 -210
  128. package/esm/propagator.js.map +0 -1
  129. package/esm/sampler.js +0 -186
  130. package/esm/sampler.js.map +0 -1
  131. package/esm/semanticAttributes.js +0 -10
  132. package/esm/semanticAttributes.js.map +0 -1
  133. package/esm/setupEventContextTrace.js +0 -38
  134. package/esm/setupEventContextTrace.js.map +0 -1
  135. package/esm/spanExporter.js +0 -305
  136. package/esm/spanExporter.js.map +0 -1
  137. package/esm/spanProcessor.js +0 -96
  138. package/esm/spanProcessor.js.map +0 -1
  139. package/esm/trace.js +0 -217
  140. package/esm/trace.js.map +0 -1
  141. package/esm/utils/addOriginToSpan.js +0 -9
  142. package/esm/utils/addOriginToSpan.js.map +0 -1
  143. package/esm/utils/captureExceptionForTimedEvent.js +0 -57
  144. package/esm/utils/captureExceptionForTimedEvent.js.map +0 -1
  145. package/esm/utils/contextData.js +0 -54
  146. package/esm/utils/contextData.js.map +0 -1
  147. package/esm/utils/convertOtelTimeToSeconds.js +0 -7
  148. package/esm/utils/convertOtelTimeToSeconds.js.map +0 -1
  149. package/esm/utils/dynamicSamplingContext.js +0 -59
  150. package/esm/utils/dynamicSamplingContext.js.map +0 -1
  151. package/esm/utils/getActiveSpan.js +0 -26
  152. package/esm/utils/getActiveSpan.js.map +0 -1
  153. package/esm/utils/getRequestSpanData.js +0 -46
  154. package/esm/utils/getRequestSpanData.js.map +0 -1
  155. package/esm/utils/getSpanKind.js +0 -19
  156. package/esm/utils/getSpanKind.js.map +0 -1
  157. package/esm/utils/groupSpansWithParents.js +0 -72
  158. package/esm/utils/groupSpansWithParents.js.map +0 -1
  159. package/esm/utils/isSentryRequest.js +0 -27
  160. package/esm/utils/isSentryRequest.js.map +0 -1
  161. package/esm/utils/mapStatus.js +0 -75
  162. package/esm/utils/mapStatus.js.map +0 -1
  163. package/esm/utils/parseSpanDescription.js +0 -154
  164. package/esm/utils/parseSpanDescription.js.map +0 -1
  165. package/esm/utils/setupCheck.js +0 -14
  166. package/esm/utils/setupCheck.js.map +0 -1
  167. package/esm/utils/spanData.js +0 -63
  168. package/esm/utils/spanData.js.map +0 -1
  169. package/esm/utils/spanTypes.js +0 -70
  170. package/esm/utils/spanTypes.js.map +0 -1
  171. package/types/custom/hubextensions.d.ts +0 -5
  172. package/types/custom/hubextensions.d.ts.map +0 -1
  173. package/types/custom/transaction.d.ts +0 -8
  174. package/types/custom/transaction.d.ts.map +0 -1
  175. package/types-ts3.8/custom/hubextensions.d.ts +0 -5
  176. package/types-ts3.8/custom/transaction.d.ts +0 -8
package/esm/sampler.js DELETED
@@ -1,186 +0,0 @@
1
- import { trace, isSpanContextValid, TraceFlags } from '@opentelemetry/api';
2
- import { SamplingDecision } from '@opentelemetry/sdk-trace-base';
3
- import { hasTracingEnabled, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE } from '@sentry/core';
4
- import { logger, isNaN } from '@sentry/utils';
5
- import { DEBUG_BUILD } from './debug-build.js';
6
- import { getPropagationContextFromSpanContext } from './propagator.js';
7
- import { InternalSentrySemanticAttributes } from './semanticAttributes.js';
8
- import { setIsSetup } from './utils/setupCheck.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
- setIsSetup('SentrySampler');
18
- }
19
-
20
- /** @inheritDoc */
21
- shouldSample(
22
- context,
23
- traceId,
24
- spanName,
25
- _spanKind,
26
- spanAttributes,
27
- _links,
28
- ) {
29
- const options = this._client.getOptions();
30
-
31
- if (!hasTracingEnabled(options)) {
32
- return { decision: SamplingDecision.NOT_RECORD };
33
- }
34
-
35
- const parentContext = trace.getSpanContext(context);
36
-
37
- let parentSampled = undefined;
38
-
39
- // Only inherit sample rate if `traceId` is the same
40
- // Note for testing: `isSpanContextValid()` checks the format of the traceId/spanId, so we need to pass valid ones
41
- if (parentContext && isSpanContextValid(parentContext) && parentContext.traceId === traceId) {
42
- if (parentContext.isRemote) {
43
- parentSampled = getParentRemoteSampled(parentContext);
44
- DEBUG_BUILD &&
45
- logger.log(`[Tracing] Inheriting remote parent's sampled decision for ${spanName}: ${parentSampled}`);
46
- } else {
47
- parentSampled = Boolean(parentContext.traceFlags & TraceFlags.SAMPLED);
48
- DEBUG_BUILD && logger.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);
49
- }
50
- }
51
-
52
- const sampleRate = getSampleRate(options, {
53
- name: spanName,
54
- attributes: spanAttributes,
55
- transactionContext: {
56
- name: spanName,
57
- parentSampled,
58
- },
59
- parentSampled,
60
- });
61
-
62
- const attributes = {
63
- [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: Number(sampleRate),
64
- };
65
-
66
- if (typeof parentSampled === 'boolean') {
67
- attributes[InternalSentrySemanticAttributes.PARENT_SAMPLED] = parentSampled;
68
- }
69
-
70
- // Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
71
- // only valid values are booleans or numbers between 0 and 1.)
72
- if (!isValidSampleRate(sampleRate)) {
73
- DEBUG_BUILD && logger.warn('[Tracing] Discarding span because of invalid sample rate.');
74
-
75
- return {
76
- decision: SamplingDecision.NOT_RECORD,
77
- attributes,
78
- };
79
- }
80
-
81
- // if the function returned 0 (or false), or if `tracesSampleRate` is 0, it's a sign the transaction should be dropped
82
- if (!sampleRate) {
83
- DEBUG_BUILD &&
84
- logger.log(
85
- `[Tracing] Discarding span because ${
86
- typeof options.tracesSampler === 'function'
87
- ? 'tracesSampler returned 0 or false'
88
- : 'a negative sampling decision was inherited or tracesSampleRate is set to 0'
89
- }`,
90
- );
91
-
92
- return {
93
- decision: SamplingDecision.NOT_RECORD,
94
- attributes,
95
- };
96
- }
97
-
98
- // Now we roll the dice. Math.random is inclusive of 0, but not of 1, so strict < is safe here. In case sampleRate is
99
- // a boolean, the < comparison will cause it to be automatically cast to 1 if it's true and 0 if it's false.
100
- const isSampled = Math.random() < (sampleRate );
101
-
102
- // if we're not going to keep it, we're done
103
- if (!isSampled) {
104
- DEBUG_BUILD &&
105
- logger.log(
106
- `[Tracing] Discarding span because it's not included in the random sample (sampling rate = ${Number(
107
- sampleRate,
108
- )})`,
109
- );
110
-
111
- return {
112
- decision: SamplingDecision.NOT_RECORD,
113
- attributes,
114
- };
115
- }
116
-
117
- return {
118
- decision: SamplingDecision.RECORD_AND_SAMPLED,
119
- attributes,
120
- };
121
- }
122
-
123
- /** Returns the sampler name or short description with the configuration. */
124
- toString() {
125
- return 'SentrySampler';
126
- }
127
- }
128
-
129
- function getSampleRate(
130
- options,
131
- samplingContext,
132
- ) {
133
- if (typeof options.tracesSampler === 'function') {
134
- return options.tracesSampler(samplingContext);
135
- }
136
-
137
- if (samplingContext.parentSampled !== undefined) {
138
- return samplingContext.parentSampled;
139
- }
140
-
141
- if (typeof options.tracesSampleRate !== 'undefined') {
142
- return options.tracesSampleRate;
143
- }
144
-
145
- // When `enableTracing === true`, we use a sample rate of 100%
146
- if (options.enableTracing) {
147
- return 1;
148
- }
149
-
150
- return 0;
151
- }
152
-
153
- /**
154
- * Checks the given sample rate to make sure it is valid type and value (a boolean, or a number between 0 and 1).
155
- */
156
- function isValidSampleRate(rate) {
157
- // we need to check NaN explicitly because it's of type 'number' and therefore wouldn't get caught by this typecheck
158
- if (isNaN(rate) || !(typeof rate === 'number' || typeof rate === 'boolean')) {
159
- DEBUG_BUILD &&
160
- logger.warn(
161
- `[Tracing] Given sample rate is invalid. Sample rate must be a boolean or a number between 0 and 1. Got ${JSON.stringify(
162
- rate,
163
- )} of type ${JSON.stringify(typeof rate)}.`,
164
- );
165
- return false;
166
- }
167
-
168
- // in case sampleRate is a boolean, it will get automatically cast to 1 if it's true and 0 if it's false
169
- if (rate < 0 || rate > 1) {
170
- DEBUG_BUILD &&
171
- logger.warn(`[Tracing] Given sample rate is invalid. Sample rate must be between 0 and 1. Got ${rate}.`);
172
- return false;
173
- }
174
- return true;
175
- }
176
-
177
- function getParentRemoteSampled(spanContext) {
178
- const traceId = spanContext.traceId;
179
- const traceparentData = getPropagationContextFromSpanContext(spanContext);
180
-
181
- // Only inherit sampled if `traceId` is the same
182
- return traceparentData && traceId === traceparentData.traceId ? traceparentData.sampled : undefined;
183
- }
184
-
185
- export { SentrySampler };
186
- //# sourceMappingURL=sampler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sampler.js","sources":["../../src/sampler.ts"],"sourcesContent":["/* eslint-disable no-bitwise */\nimport type { Attributes, Context, SpanContext } from '@opentelemetry/api';\nimport { TraceFlags, isSpanContextValid, trace } from '@opentelemetry/api';\nimport type { Sampler, SamplingResult } from '@opentelemetry/sdk-trace-base';\nimport { SamplingDecision } from '@opentelemetry/sdk-trace-base';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, hasTracingEnabled } from '@sentry/core';\nimport type { Client, ClientOptions, SamplingContext } from '@sentry/types';\nimport { isNaN, logger } from '@sentry/utils';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport { getPropagationContextFromSpanContext } from './propagator';\nimport { InternalSentrySemanticAttributes } from './semanticAttributes';\nimport { setIsSetup } from './utils/setupCheck';\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 setIsSetup('SentrySampler');\n }\n\n /** @inheritDoc */\n public shouldSample(\n context: Context,\n traceId: string,\n spanName: string,\n _spanKind: unknown,\n spanAttributes: 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);\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 && logger.log(`[Tracing] Inheriting parent's sampled decision for ${spanName}: ${parentSampled}`);\n }\n }\n\n const sampleRate = getSampleRate(options, {\n name: spanName,\n attributes: spanAttributes,\n transactionContext: {\n name: spanName,\n parentSampled,\n },\n parentSampled,\n });\n\n const attributes: Attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_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 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): boolean | undefined {\n const traceId = spanContext.traceId;\n const traceparentData = getPropagationContextFromSpanContext(spanContext);\n\n // Only inherit sampled if `traceId` is the same\n return traceparentData && traceId === traceparentData.traceId ? traceparentData.sampled : undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;AAcA;AACA;AACA;AACO,MAAM,eAAiC;;AAG9C,GAAS,WAAW,CAAC,MAAM,EAAU;AACrC,IAAI,IAAI,CAAC,OAAQ,GAAE,MAAM,CAAA;AACzB,IAAI,UAAU,CAAC,eAAe,CAAC,CAAA;AAC/B,GAAE;AACF;AACA;AACA,GAAS,YAAY;AACrB,IAAI,OAAO;AACX,IAAI,OAAO;AACX,IAAI,QAAQ;AACZ,IAAI,SAAS;AACb,IAAI,cAAc;AAClB,IAAI,MAAM;AACV,IAAoB;AACpB,IAAI,MAAM,UAAU,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;AAC7C;AACA,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE;AACrC,MAAM,OAAO,EAAE,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAA;AACtD,KAAI;AACJ;AACA,IAAI,MAAM,gBAAgB,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;AACvD;AACA,IAAI,IAAI,aAAa,GAAwB,SAAS,CAAA;AACtD;AACA;AACA;AACA,IAAI,IAAI,aAAc,IAAG,kBAAkB,CAAC,aAAa,CAAE,IAAG,aAAa,CAAC,OAAQ,KAAI,OAAO,EAAE;AACjG,MAAM,IAAI,aAAa,CAAC,QAAQ,EAAE;AAClC,QAAQ,aAAc,GAAE,sBAAsB,CAAC,aAAa,CAAC,CAAA;AAC7D,QAAQ,WAAY;AACpB,UAAU,MAAM,CAAC,GAAG,CAAC,CAAC,0DAA0D,EAAE,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC,CAAA,CAAA,CAAA;AACA,OAAA,MAAA;AACA,QAAA,aAAA,GAAA,OAAA,CAAA,aAAA,CAAA,UAAA,GAAA,UAAA,CAAA,OAAA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A,IAAA,KAAA,QAAA,IAAA,OAAA,IAAA,KAAA,SAAA,CAAA,EAAA;AACA,IAAA,WAAA;AACA,MAAA,MAAA,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,WAAA;AACA,MAAA,MAAA,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;AACA,EAAA,MAAA,OAAA,GAAA,WAAA,CAAA,OAAA,CAAA;AACA,EAAA,MAAA,eAAA,GAAA,oCAAA,CAAA,WAAA,CAAA,CAAA;AACA;AACA;AACA,EAAA,OAAA,eAAA,IAAA,OAAA,KAAA,eAAA,CAAA,OAAA,GAAA,eAAA,CAAA,OAAA,GAAA,SAAA,CAAA;AACA;;;;"}
@@ -1,10 +0,0 @@
1
- /**
2
- * These are internal and are not supposed to be used/depended on by external parties.
3
- * No guarantees apply to these attributes, and the may change/disappear at any time.
4
- */
5
- const InternalSentrySemanticAttributes = {
6
- PARENT_SAMPLED: 'sentry.parentSampled',
7
- } ;
8
-
9
- export { InternalSentrySemanticAttributes };
10
- //# sourceMappingURL=semanticAttributes.js.map
@@ -1 +0,0 @@
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 PARENT_SAMPLED: 'sentry.parentSampled',\n} as const;\n"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACO,MAAM,mCAAmC;AAChD,EAAE,cAAc,EAAE,sBAAsB;AACxC,CAAE;;;;"}
@@ -1,38 +0,0 @@
1
- import { dropUndefinedKeys } from '@sentry/utils';
2
- import { getActiveSpan, getRootSpan } from './utils/getActiveSpan.js';
3
- import { spanHasParentId, spanHasName } from './utils/spanTypes.js';
4
-
5
- /** Ensure the `trace` context is set on all events. */
6
- function setupEventContextTrace(client) {
7
- client.addEventProcessor(event => {
8
- const span = getActiveSpan();
9
- // For transaction events, this is handled separately
10
- // Because the active span may not be the span that is actually the transaction event
11
- if (!span || event.type === 'transaction') {
12
- return event;
13
- }
14
-
15
- const spanContext = span.spanContext();
16
-
17
- // If event has already set `trace` context, use that one.
18
- event.contexts = {
19
- trace: dropUndefinedKeys({
20
- trace_id: spanContext.traceId,
21
- span_id: spanContext.spanId,
22
- parent_span_id: spanHasParentId(span) ? span.parentSpanId : undefined,
23
- }),
24
- ...event.contexts,
25
- };
26
-
27
- const rootSpan = getRootSpan(span);
28
- const transactionName = spanHasName(rootSpan) ? rootSpan.name : undefined;
29
- if (transactionName && !event.transaction) {
30
- event.transaction = transactionName;
31
- }
32
-
33
- return event;
34
- });
35
- }
36
-
37
- export { setupEventContextTrace };
38
- //# sourceMappingURL=setupEventContextTrace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setupEventContextTrace.js","sources":["../../src/setupEventContextTrace.ts"],"sourcesContent":["import type { Client } from '@sentry/types';\nimport { dropUndefinedKeys } from '@sentry/utils';\n\nimport { getActiveSpan, getRootSpan } from './utils/getActiveSpan';\nimport { spanHasName, spanHasParentId } from './utils/spanTypes';\n\n/** Ensure the `trace` context is set on all events. */\nexport function setupEventContextTrace(client: Client): void {\n client.addEventProcessor(event => {\n const span = getActiveSpan();\n // For transaction events, this is handled separately\n // Because the active span may not be the span that is actually the transaction event\n if (!span || event.type === 'transaction') {\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: dropUndefinedKeys({\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 const rootSpan = getRootSpan(span);\n const transactionName = spanHasName(rootSpan) ? rootSpan.name : undefined;\n if (transactionName && !event.transaction) {\n event.transaction = transactionName;\n }\n\n return event;\n });\n}\n"],"names":[],"mappings":";;;;AAMA;AACO,SAAS,sBAAsB,CAAC,MAAM,EAAgB;AAC7D,EAAE,MAAM,CAAC,iBAAiB,CAAC,SAAS;AACpC,IAAI,MAAM,IAAA,GAAO,aAAa,EAAE,CAAA;AAChC;AACA;AACA,IAAI,IAAI,CAAC,IAAK,IAAG,KAAK,CAAC,IAAA,KAAS,aAAa,EAAE;AAC/C,MAAM,OAAO,KAAK,CAAA;AAClB,KAAI;AACJ;AACA,IAAI,MAAM,WAAY,GAAE,IAAI,CAAC,WAAW,EAAE,CAAA;AAC1C;AACA;AACA,IAAI,KAAK,CAAC,QAAA,GAAW;AACrB,MAAM,KAAK,EAAE,iBAAiB,CAAC;AAC/B,QAAQ,QAAQ,EAAE,WAAW,CAAC,OAAO;AACrC,QAAQ,OAAO,EAAE,WAAW,CAAC,MAAM;AACnC,QAAQ,cAAc,EAAE,eAAe,CAAC,IAAI,CAAE,GAAE,IAAI,CAAC,YAAa,GAAE,SAAS;AAC7E,OAAO,CAAC;AACR,MAAM,GAAG,KAAK,CAAC,QAAQ;AACvB,KAAK,CAAA;AACL;AACA,IAAI,MAAM,QAAS,GAAE,WAAW,CAAC,IAAI,CAAC,CAAA;AACtC,IAAI,MAAM,eAAA,GAAkB,WAAW,CAAC,QAAQ,CAAE,GAAE,QAAQ,CAAC,IAAK,GAAE,SAAS,CAAA;AAC7E,IAAI,IAAI,eAAgB,IAAG,CAAC,KAAK,CAAC,WAAW,EAAE;AAC/C,MAAM,KAAK,CAAC,WAAY,GAAE,eAAe,CAAA;AACzC,KAAI;AACJ;AACA,IAAI,OAAO,KAAK,CAAA;AAChB,GAAG,CAAC,CAAA;AACJ;;;;"}
@@ -1,305 +0,0 @@
1
- import { SpanKind } from '@opentelemetry/api';
2
- import { ExportResultCode } from '@opentelemetry/core';
3
- import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
4
- import { getCurrentHub, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
5
- import { logger, dropUndefinedKeys, addNonEnumerableProperty } from '@sentry/utils';
6
- import { startTransaction } from './custom/transaction.js';
7
- import { DEBUG_BUILD } from './debug-build.js';
8
- import { InternalSentrySemanticAttributes } from './semanticAttributes.js';
9
- import { convertOtelTimeToSeconds } from './utils/convertOtelTimeToSeconds.js';
10
- import { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext.js';
11
- import { getRequestSpanData } from './utils/getRequestSpanData.js';
12
- import { groupSpansWithParents } from './utils/groupSpansWithParents.js';
13
- import { mapStatus } from './utils/mapStatus.js';
14
- import { parseSpanDescription } from './utils/parseSpanDescription.js';
15
- import { getSpanHub, getSpanMetadata, getSpanScopes } from './utils/spanData.js';
16
-
17
- /**
18
- * A Sentry-specific exporter that converts OpenTelemetry Spans to Sentry Spans & Transactions.
19
- */
20
- class SentrySpanExporter {
21
-
22
- constructor() {
23
- this._stopped = false;
24
- this._finishedSpans = [];
25
- }
26
-
27
- /** @inheritDoc */
28
- export(spans, resultCallback) {
29
- if (this._stopped) {
30
- return resultCallback({
31
- code: ExportResultCode.FAILED,
32
- error: new Error('Exporter has been stopped'),
33
- });
34
- }
35
-
36
- const openSpanCount = this._finishedSpans.length;
37
- const newSpanCount = spans.length;
38
-
39
- this._finishedSpans.push(...spans);
40
-
41
- const remainingSpans = maybeSend(this._finishedSpans);
42
-
43
- const remainingOpenSpanCount = remainingSpans.length;
44
- const sentSpanCount = openSpanCount + newSpanCount - remainingOpenSpanCount;
45
-
46
- DEBUG_BUILD &&
47
- logger.log(`SpanExporter exported ${sentSpanCount} spans, ${remainingOpenSpanCount} unsent spans remaining`);
48
-
49
- this._finishedSpans = remainingSpans.filter(span => {
50
- const shouldDrop = shouldCleanupSpan(span, 5 * 60);
51
- DEBUG_BUILD &&
52
- shouldDrop &&
53
- logger.log(
54
- `SpanExporter dropping span ${span.name} (${
55
- span.spanContext().spanId
56
- }) because it is pending for more than 5 minutes.`,
57
- );
58
- return !shouldDrop;
59
- });
60
-
61
- resultCallback({ code: ExportResultCode.SUCCESS });
62
- }
63
-
64
- /** @inheritDoc */
65
- shutdown() {
66
- const forceFlush = this.forceFlush();
67
- this._stopped = true;
68
- this._finishedSpans = [];
69
- return forceFlush;
70
- }
71
-
72
- /** @inheritDoc */
73
- forceFlush() {
74
- return new Promise(resolve => {
75
- this.export(this._finishedSpans, () => resolve());
76
- });
77
- }
78
- }
79
-
80
- /**
81
- * Send the given spans, but only if they are part of a finished transaction.
82
- *
83
- * Returns the unsent spans.
84
- * Spans remain unsent when their parent span is not yet finished.
85
- * This will happen regularly, as child spans are generally finished before their parents.
86
- * But it _could_ also happen because, for whatever reason, a parent span was lost.
87
- * In this case, we'll eventually need to clean this up.
88
- */
89
- function maybeSend(spans) {
90
- const grouped = groupSpansWithParents(spans);
91
- const remaining = new Set(grouped);
92
-
93
- const rootNodes = getCompletedRootNodes(grouped);
94
-
95
- rootNodes.forEach(root => {
96
- remaining.delete(root);
97
- const span = root.span;
98
- const transaction = createTransactionForOtelSpan(span);
99
-
100
- root.children.forEach(child => {
101
- createAndFinishSpanForOtelSpan(child, transaction, remaining);
102
- });
103
-
104
- transaction.end(span.endTime);
105
- });
106
-
107
- return Array.from(remaining)
108
- .map(node => node.span)
109
- .filter((span) => !!span);
110
- }
111
-
112
- function getCompletedRootNodes(nodes) {
113
- return nodes.filter((node) => !!node.span && !node.parentNode);
114
- }
115
-
116
- function shouldCleanupSpan(span, maxStartTimeOffsetSeconds) {
117
- const cutoff = Date.now() / 1000 - maxStartTimeOffsetSeconds;
118
- return convertOtelTimeToSeconds(span.startTime) < cutoff;
119
- }
120
-
121
- function parseSpan(span) {
122
- const attributes = span.attributes;
123
-
124
- const origin = attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] ;
125
- const op = attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] ;
126
- const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] ;
127
-
128
- return { origin, op, source };
129
- }
130
-
131
- function createTransactionForOtelSpan(span) {
132
- // eslint-disable-next-line deprecation/deprecation
133
- const hub = getSpanHub(span) || getCurrentHub();
134
- const spanContext = span.spanContext();
135
- const spanId = spanContext.spanId;
136
- const traceId = spanContext.traceId;
137
- const parentSpanId = span.parentSpanId;
138
-
139
- const parentSampled = span.attributes[InternalSentrySemanticAttributes.PARENT_SAMPLED] ;
140
-
141
- const { op, description, data, origin, source } = getSpanData(span);
142
- const metadata = getSpanMetadata(span);
143
- const capturedSpanScopes = getSpanScopes(span);
144
-
145
- const sampleRate = span.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] ;
146
-
147
- const attributes = {
148
- [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,
149
- [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate,
150
- ...data,
151
- ...removeSentryAttributes(span.attributes),
152
- };
153
-
154
- const dynamicSamplingContext = getDynamicSamplingContextFromSpan(span);
155
-
156
- const transaction = startTransaction(hub, {
157
- spanId,
158
- traceId,
159
- parentSpanId,
160
- parentSampled,
161
- name: description,
162
- op,
163
- startTimestamp: convertOtelTimeToSeconds(span.startTime),
164
- metadata: {
165
- ...dropUndefinedKeys({
166
- dynamicSamplingContext,
167
- sampleRate,
168
- }),
169
- ...metadata,
170
- },
171
- attributes,
172
- origin,
173
- sampled: true,
174
- });
175
-
176
- transaction.setStatus(mapStatus(span));
177
-
178
- // We currently don't want to write this to the scope because it would mutate it.
179
- // In the future we will likely have some sort of transaction payload factory where we can pass this context in directly
180
- // eslint-disable-next-line deprecation/deprecation
181
- transaction.setContext('otel', {
182
- attributes: removeSentryAttributes(span.attributes),
183
- resource: span.resource.attributes,
184
- });
185
-
186
- if (capturedSpanScopes) {
187
- setCapturedScopesOnTransaction(transaction, capturedSpanScopes.scope, capturedSpanScopes.isolationScope);
188
- }
189
-
190
- return transaction;
191
- }
192
-
193
- function createAndFinishSpanForOtelSpan(node, sentryParentSpan, remaining) {
194
- remaining.delete(node);
195
- const span = node.span;
196
-
197
- const shouldDrop = !span;
198
-
199
- // If this span should be dropped, we still want to create spans for the children of this
200
- if (shouldDrop) {
201
- node.children.forEach(child => {
202
- createAndFinishSpanForOtelSpan(child, sentryParentSpan, remaining);
203
- });
204
- return;
205
- }
206
-
207
- const spanId = span.spanContext().spanId;
208
- const { attributes } = span;
209
-
210
- const { op, description, data, origin } = getSpanData(span);
211
- const allData = { ...removeSentryAttributes(attributes), ...data };
212
-
213
- // eslint-disable-next-line deprecation/deprecation
214
- const sentrySpan = sentryParentSpan.startChild({
215
- name: description,
216
- op,
217
- data: allData,
218
- startTimestamp: convertOtelTimeToSeconds(span.startTime),
219
- spanId,
220
- origin,
221
- }) ;
222
- sentrySpan.setStatus(mapStatus(span));
223
-
224
- node.children.forEach(child => {
225
- createAndFinishSpanForOtelSpan(child, sentrySpan, remaining);
226
- });
227
-
228
- sentrySpan.end(convertOtelTimeToSeconds(span.endTime));
229
- }
230
-
231
- function getSpanData(span)
232
-
233
- {
234
- const { op: definedOp, source: definedSource, origin } = parseSpan(span);
235
- const { op: inferredOp, description, source: inferredSource, data: inferredData } = parseSpanDescription(span);
236
-
237
- const op = definedOp || inferredOp;
238
- const source = definedSource || inferredSource;
239
-
240
- const data = { ...inferredData, ...getData(span) };
241
-
242
- return {
243
- op,
244
- description,
245
- source,
246
- origin,
247
- data,
248
- };
249
- }
250
-
251
- /**
252
- * Remove custom `sentry.` attribtues we do not need to send.
253
- * These are more carrier attributes we use inside of the SDK, we do not need to send them to the API.
254
- */
255
- function removeSentryAttributes(data) {
256
- const cleanedData = { ...data };
257
-
258
- /* eslint-disable @typescript-eslint/no-dynamic-delete */
259
- delete cleanedData[InternalSentrySemanticAttributes.PARENT_SAMPLED];
260
- delete cleanedData[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
261
- /* eslint-enable @typescript-eslint/no-dynamic-delete */
262
-
263
- return cleanedData;
264
- }
265
-
266
- function getData(span) {
267
- const attributes = span.attributes;
268
- const data = {
269
- 'otel.kind': SpanKind[span.kind],
270
- };
271
-
272
- if (attributes[SemanticAttributes.HTTP_STATUS_CODE]) {
273
- const statusCode = attributes[SemanticAttributes.HTTP_STATUS_CODE] ;
274
- data['http.response.status_code'] = statusCode;
275
- }
276
-
277
- const requestData = getRequestSpanData(span);
278
-
279
- if (requestData.url) {
280
- data.url = requestData.url;
281
- }
282
-
283
- if (requestData['http.query']) {
284
- data['http.query'] = requestData['http.query'].slice(1);
285
- }
286
- if (requestData['http.fragment']) {
287
- data['http.fragment'] = requestData['http.fragment'].slice(1);
288
- }
289
-
290
- return data;
291
- }
292
-
293
- const SCOPE_ON_START_SPAN_FIELD = '_sentryScope';
294
- const ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';
295
-
296
- /** Sets the scope and isolation scope to be used for when the transaction is finished. */
297
- function setCapturedScopesOnTransaction(span, scope, isolationScope) {
298
- if (span) {
299
- addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);
300
- addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);
301
- }
302
- }
303
-
304
- export { SentrySpanExporter };
305
- //# sourceMappingURL=spanExporter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanExporter.js","sources":["../../src/spanExporter.ts"],"sourcesContent":["import { 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 type { SentrySpan, Transaction } from '@sentry/core';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getCurrentHub,\n} from '@sentry/core';\nimport type { Scope, SpanOrigin, TransactionSource } from '@sentry/types';\nimport { addNonEnumerableProperty, dropUndefinedKeys, logger } from '@sentry/utils';\nimport { startTransaction } from './custom/transaction';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport { InternalSentrySemanticAttributes } from './semanticAttributes';\nimport { convertOtelTimeToSeconds } from './utils/convertOtelTimeToSeconds';\nimport { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';\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, getSpanScopes } 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 const forceFlush = this.forceFlush();\n this._stopped = true;\n this._finishedSpans = [];\n return forceFlush;\n }\n\n /** @inheritDoc */\n public forceFlush(): Promise<void> {\n return new Promise(resolve => {\n this.export(this._finishedSpans, () => resolve());\n });\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 transaction.end(span.endTime);\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[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] as SpanOrigin | undefined;\n const op = attributes[SEMANTIC_ATTRIBUTE_SENTRY_OP] as string | undefined;\n const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE] as TransactionSource | undefined;\n\n return { origin, op, source };\n}\n\nfunction createTransactionForOtelSpan(span: ReadableSpan): Transaction {\n // eslint-disable-next-line deprecation/deprecation\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\n const { op, description, data, origin, source } = getSpanData(span);\n const metadata = getSpanMetadata(span);\n const capturedSpanScopes = getSpanScopes(span);\n\n const sampleRate = span.attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE] as number | undefined;\n\n const attributes = {\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: source,\n [SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE]: sampleRate,\n ...data,\n ...removeSentryAttributes(span.attributes),\n };\n\n const dynamicSamplingContext = getDynamicSamplingContextFromSpan(span);\n\n const transaction = startTransaction(hub, {\n spanId,\n traceId,\n parentSpanId,\n parentSampled,\n name: description,\n op,\n startTimestamp: convertOtelTimeToSeconds(span.startTime),\n metadata: {\n ...dropUndefinedKeys({\n dynamicSamplingContext,\n sampleRate,\n }),\n ...metadata,\n },\n attributes,\n origin,\n sampled: true,\n });\n\n transaction.setStatus(mapStatus(span));\n\n // We currently don't want to write this to the scope because it would mutate it.\n // In the future we will likely have some sort of transaction payload factory where we can pass this context in directly\n // eslint-disable-next-line deprecation/deprecation\n transaction.setContext('otel', {\n attributes: removeSentryAttributes(span.attributes),\n resource: span.resource.attributes,\n });\n\n if (capturedSpanScopes) {\n setCapturedScopesOnTransaction(transaction, capturedSpanScopes.scope, capturedSpanScopes.isolationScope);\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, data, origin } = getSpanData(span);\n const allData = { ...removeSentryAttributes(attributes), ...data };\n\n // eslint-disable-next-line deprecation/deprecation\n const sentrySpan = sentryParentSpan.startChild({\n name: description,\n op,\n data: allData,\n startTimestamp: convertOtelTimeToSeconds(span.startTime),\n spanId,\n origin,\n }) as SentrySpan;\n sentrySpan.setStatus(mapStatus(span));\n\n node.children.forEach(child => {\n createAndFinishSpanForOtelSpan(child, sentrySpan, remaining);\n });\n\n sentrySpan.end(convertOtelTimeToSeconds(span.endTime));\n}\n\nfunction getSpanData(span: ReadableSpan): {\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 data = { ...inferredData, ...getData(span) };\n\n return {\n op,\n description,\n source,\n origin,\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[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];\n /* eslint-enable @typescript-eslint/no-dynamic-delete */\n\n return cleanedData;\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\nconst SCOPE_ON_START_SPAN_FIELD = '_sentryScope';\nconst ISOLATION_SCOPE_ON_START_SPAN_FIELD = '_sentryIsolationScope';\n\n/** Sets the scope and isolation scope to be used for when the transaction is finished. */\nfunction setCapturedScopesOnTransaction(span: Transaction, scope: Scope, isolationScope: Scope): void {\n if (span) {\n addNonEnumerableProperty(span, ISOLATION_SCOPE_ON_START_SPAN_FIELD, isolationScope);\n addNonEnumerableProperty(span, SCOPE_ON_START_SPAN_FIELD, scope);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA8BA;AACA;AACA;AACO,MAAM,oBAA2C;;AAIxD,GAAS,WAAW,GAAG;AACvB,IAAI,IAAI,CAAC,QAAS,GAAE,KAAK,CAAA;AACzB,IAAI,IAAI,CAAC,cAAe,GAAE,EAAE,CAAA;AAC5B,GAAE;AACF;AACA;A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