@sentry/opentelemetry 8.0.0-alpha.1 → 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 (178) 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 -22
  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 +3 -5
  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 +6 -7
  14. package/types/index.d.ts.map +1 -1
  15. package/types/propagator.d.ts +26 -2
  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 -21
  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/mapStatus.d.ts +2 -2
  36. package/types/utils/mapStatus.d.ts.map +1 -1
  37. package/types/utils/setupCheck.d.ts +9 -0
  38. package/types/utils/setupCheck.d.ts.map +1 -0
  39. package/types/utils/spanData.d.ts +1 -14
  40. package/types/utils/spanData.d.ts.map +1 -1
  41. package/types-ts3.8/constants.d.ts +3 -5
  42. package/types-ts3.8/index.d.ts +6 -7
  43. package/types-ts3.8/propagator.d.ts +26 -2
  44. package/types-ts3.8/semanticAttributes.d.ts +2 -7
  45. package/types-ts3.8/trace.d.ts +14 -1
  46. package/types-ts3.8/types.d.ts +3 -4
  47. package/types-ts3.8/utils/captureExceptionForTimedEvent.d.ts +1 -2
  48. package/types-ts3.8/utils/contextData.d.ts +1 -21
  49. package/types-ts3.8/utils/getActiveSpan.d.ts +0 -5
  50. package/types-ts3.8/utils/mapStatus.d.ts +2 -2
  51. package/types-ts3.8/utils/setupCheck.d.ts +9 -0
  52. package/types-ts3.8/utils/spanData.d.ts +1 -14
  53. package/cjs/asyncContextStrategy.js +0 -114
  54. package/cjs/asyncContextStrategy.js.map +0 -1
  55. package/cjs/constants.js +0 -32
  56. package/cjs/constants.js.map +0 -1
  57. package/cjs/contextManager.js +0 -82
  58. package/cjs/contextManager.js.map +0 -1
  59. package/cjs/custom/client.js +0 -64
  60. package/cjs/custom/client.js.map +0 -1
  61. package/cjs/custom/getCurrentHub.js +0 -106
  62. package/cjs/custom/getCurrentHub.js.map +0 -1
  63. package/cjs/custom/hub.js +0 -13
  64. package/cjs/custom/hub.js.map +0 -1
  65. package/cjs/custom/hubextensions.js +0 -37
  66. package/cjs/custom/hubextensions.js.map +0 -1
  67. package/cjs/custom/transaction.js +0 -26
  68. package/cjs/custom/transaction.js.map +0 -1
  69. package/cjs/debug-build.js +0 -11
  70. package/cjs/debug-build.js.map +0 -1
  71. package/cjs/propagator.js +0 -159
  72. package/cjs/propagator.js.map +0 -1
  73. package/cjs/sampler.js +0 -186
  74. package/cjs/sampler.js.map +0 -1
  75. package/cjs/semanticAttributes.js +0 -12
  76. package/cjs/semanticAttributes.js.map +0 -1
  77. package/cjs/setupEventContextTrace.js +0 -40
  78. package/cjs/setupEventContextTrace.js.map +0 -1
  79. package/cjs/spanExporter.js +0 -314
  80. package/cjs/spanExporter.js.map +0 -1
  81. package/cjs/spanProcessor.js +0 -95
  82. package/cjs/spanProcessor.js.map +0 -1
  83. package/cjs/trace.js +0 -222
  84. package/cjs/trace.js.map +0 -1
  85. package/cjs/utils/addOriginToSpan.js +0 -11
  86. package/cjs/utils/addOriginToSpan.js.map +0 -1
  87. package/cjs/utils/captureExceptionForTimedEvent.js +0 -59
  88. package/cjs/utils/captureExceptionForTimedEvent.js.map +0 -1
  89. package/cjs/utils/contextData.js +0 -79
  90. package/cjs/utils/contextData.js.map +0 -1
  91. package/cjs/utils/convertOtelTimeToSeconds.js +0 -9
  92. package/cjs/utils/convertOtelTimeToSeconds.js.map +0 -1
  93. package/cjs/utils/dynamicSamplingContext.js +0 -64
  94. package/cjs/utils/dynamicSamplingContext.js.map +0 -1
  95. package/cjs/utils/getActiveSpan.js +0 -29
  96. package/cjs/utils/getActiveSpan.js.map +0 -1
  97. package/cjs/utils/getRequestSpanData.js +0 -48
  98. package/cjs/utils/getRequestSpanData.js.map +0 -1
  99. package/cjs/utils/getSpanKind.js +0 -21
  100. package/cjs/utils/getSpanKind.js.map +0 -1
  101. package/cjs/utils/groupSpansWithParents.js +0 -74
  102. package/cjs/utils/groupSpansWithParents.js.map +0 -1
  103. package/cjs/utils/isSentryRequest.js +0 -29
  104. package/cjs/utils/isSentryRequest.js.map +0 -1
  105. package/cjs/utils/mapStatus.js +0 -76
  106. package/cjs/utils/mapStatus.js.map +0 -1
  107. package/cjs/utils/parseSpanDescription.js +0 -158
  108. package/cjs/utils/parseSpanDescription.js.map +0 -1
  109. package/cjs/utils/spanData.js +0 -72
  110. package/cjs/utils/spanData.js.map +0 -1
  111. package/cjs/utils/spanTypes.js +0 -77
  112. package/cjs/utils/spanTypes.js.map +0 -1
  113. package/esm/asyncContextStrategy.js +0 -112
  114. package/esm/asyncContextStrategy.js.map +0 -1
  115. package/esm/constants.js +0 -22
  116. package/esm/constants.js.map +0 -1
  117. package/esm/contextManager.js +0 -77
  118. package/esm/contextManager.js.map +0 -1
  119. package/esm/custom/client.js +0 -59
  120. package/esm/custom/client.js.map +0 -1
  121. package/esm/custom/getCurrentHub.js +0 -101
  122. package/esm/custom/getCurrentHub.js.map +0 -1
  123. package/esm/custom/hub.js +0 -11
  124. package/esm/custom/hub.js.map +0 -1
  125. package/esm/custom/hubextensions.js +0 -35
  126. package/esm/custom/hubextensions.js.map +0 -1
  127. package/esm/custom/transaction.js +0 -24
  128. package/esm/custom/transaction.js.map +0 -1
  129. package/esm/debug-build.js +0 -9
  130. package/esm/debug-build.js.map +0 -1
  131. package/esm/propagator.js +0 -154
  132. package/esm/propagator.js.map +0 -1
  133. package/esm/sampler.js +0 -184
  134. package/esm/sampler.js.map +0 -1
  135. package/esm/semanticAttributes.js +0 -10
  136. package/esm/semanticAttributes.js.map +0 -1
  137. package/esm/setupEventContextTrace.js +0 -38
  138. package/esm/setupEventContextTrace.js.map +0 -1
  139. package/esm/spanExporter.js +0 -312
  140. package/esm/spanExporter.js.map +0 -1
  141. package/esm/spanProcessor.js +0 -93
  142. package/esm/spanProcessor.js.map +0 -1
  143. package/esm/trace.js +0 -217
  144. package/esm/trace.js.map +0 -1
  145. package/esm/utils/addOriginToSpan.js +0 -9
  146. package/esm/utils/addOriginToSpan.js.map +0 -1
  147. package/esm/utils/captureExceptionForTimedEvent.js +0 -57
  148. package/esm/utils/captureExceptionForTimedEvent.js.map +0 -1
  149. package/esm/utils/contextData.js +0 -70
  150. package/esm/utils/contextData.js.map +0 -1
  151. package/esm/utils/convertOtelTimeToSeconds.js +0 -7
  152. package/esm/utils/convertOtelTimeToSeconds.js.map +0 -1
  153. package/esm/utils/dynamicSamplingContext.js +0 -59
  154. package/esm/utils/dynamicSamplingContext.js.map +0 -1
  155. package/esm/utils/getActiveSpan.js +0 -26
  156. package/esm/utils/getActiveSpan.js.map +0 -1
  157. package/esm/utils/getRequestSpanData.js +0 -46
  158. package/esm/utils/getRequestSpanData.js.map +0 -1
  159. package/esm/utils/getSpanKind.js +0 -19
  160. package/esm/utils/getSpanKind.js.map +0 -1
  161. package/esm/utils/groupSpansWithParents.js +0 -72
  162. package/esm/utils/groupSpansWithParents.js.map +0 -1
  163. package/esm/utils/isSentryRequest.js +0 -27
  164. package/esm/utils/isSentryRequest.js.map +0 -1
  165. package/esm/utils/mapStatus.js +0 -74
  166. package/esm/utils/mapStatus.js.map +0 -1
  167. package/esm/utils/parseSpanDescription.js +0 -154
  168. package/esm/utils/parseSpanDescription.js.map +0 -1
  169. package/esm/utils/spanData.js +0 -63
  170. package/esm/utils/spanData.js.map +0 -1
  171. package/esm/utils/spanTypes.js +0 -70
  172. package/esm/utils/spanTypes.js.map +0 -1
  173. package/types/custom/hubextensions.d.ts +0 -5
  174. package/types/custom/hubextensions.d.ts.map +0 -1
  175. package/types/custom/transaction.d.ts +0 -8
  176. package/types/custom/transaction.d.ts.map +0 -1
  177. package/types-ts3.8/custom/hubextensions.d.ts +0 -5
  178. package/types-ts3.8/custom/transaction.d.ts +0 -8
package/cjs/trace.js DELETED
@@ -1,222 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const api = require('@opentelemetry/api');
4
- const core = require('@opentelemetry/core');
5
- const core$1 = require('@sentry/core');
6
- const utils = require('@sentry/utils');
7
- const constants = require('./constants.js');
8
- const contextData = require('./utils/contextData.js');
9
- const dynamicSamplingContext = require('./utils/dynamicSamplingContext.js');
10
- const getActiveSpan = require('./utils/getActiveSpan.js');
11
- const spanData = require('./utils/spanData.js');
12
-
13
- /**
14
- * Wraps a function with a transaction/span and finishes the span after the function is done.
15
- * The created span is the active span and will be used as parent by other spans created inside the function
16
- * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.
17
- *
18
- * If you want to create a span that is not set as active, use {@link startInactiveSpan}.
19
- *
20
- * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.
21
- */
22
- function startSpan(options, callback) {
23
- const tracer = getTracer();
24
-
25
- const { name } = options;
26
-
27
- const activeCtx = getContext(options.scope, options.forceTransaction);
28
- const shouldSkipSpan = options.onlyIfParent && !api.trace.getSpan(activeCtx);
29
- const ctx = shouldSkipSpan ? core.suppressTracing(activeCtx) : activeCtx;
30
-
31
- const spanContext = getSpanContext(options);
32
-
33
- return tracer.startActiveSpan(name, spanContext, ctx, span => {
34
- _applySentryAttributesToSpan(span, options);
35
-
36
- return core$1.handleCallbackErrors(
37
- () => callback(span),
38
- () => {
39
- span.setStatus({ code: api.SpanStatusCode.ERROR });
40
- },
41
- () => span.end(),
42
- );
43
- });
44
- }
45
-
46
- /**
47
- * Similar to `Sentry.startSpan`. Wraps a function with a span, but does not finish the span
48
- * after the function is done automatically. You'll have to call `span.end()` manually.
49
- *
50
- * The created span is the active span and will be used as parent by other spans created inside the function
51
- * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.
52
- *
53
- * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.
54
- */
55
- function startSpanManual(options, callback) {
56
- const tracer = getTracer();
57
-
58
- const { name } = options;
59
-
60
- const activeCtx = getContext(options.scope, options.forceTransaction);
61
- const shouldSkipSpan = options.onlyIfParent && !api.trace.getSpan(activeCtx);
62
- const ctx = shouldSkipSpan ? core.suppressTracing(activeCtx) : activeCtx;
63
-
64
- const spanContext = getSpanContext(options);
65
-
66
- return tracer.startActiveSpan(name, spanContext, ctx, span => {
67
- _applySentryAttributesToSpan(span, options);
68
-
69
- return core$1.handleCallbackErrors(
70
- () => callback(span),
71
- () => {
72
- span.setStatus({ code: api.SpanStatusCode.ERROR });
73
- },
74
- );
75
- });
76
- }
77
-
78
- /**
79
- * Creates a span. This span is not set as active, so will not get automatic instrumentation spans
80
- * as children or be able to be accessed via `Sentry.getSpan()`.
81
- *
82
- * If you want to create a span that is set as active, use {@link startSpan}.
83
- *
84
- * Note that if you have not enabled tracing extensions via `addTracingExtensions`
85
- * or you didn't set `tracesSampleRate` or `tracesSampler`, this function will not generate spans
86
- * and the `span` returned from the callback will be undefined.
87
- */
88
- function startInactiveSpan(options) {
89
- const tracer = getTracer();
90
-
91
- const { name } = options;
92
-
93
- const activeCtx = getContext(options.scope, options.forceTransaction);
94
- const shouldSkipSpan = options.onlyIfParent && !api.trace.getSpan(activeCtx);
95
- const ctx = shouldSkipSpan ? core.suppressTracing(activeCtx) : activeCtx;
96
-
97
- const spanContext = getSpanContext(options);
98
-
99
- const span = tracer.startSpan(name, spanContext, ctx);
100
-
101
- _applySentryAttributesToSpan(span, options);
102
-
103
- return span;
104
- }
105
-
106
- /**
107
- * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
108
- * passed `null` to start an entirely new span tree.
109
- *
110
- * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
111
- * spans started within the callback will not be attached to a parent span.
112
- * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.
113
- * @returns the value returned from the provided callback function.
114
- */
115
- function withActiveSpan(span, callback) {
116
- const newContextWithActiveSpan = span ? api.trace.setSpan(api.context.active(), span) : api.trace.deleteSpan(api.context.active());
117
- return api.context.with(newContextWithActiveSpan, () => callback(core$1.getCurrentScope()));
118
- }
119
-
120
- function getTracer() {
121
- const client = core$1.getClient();
122
- return (client && client.tracer) || api.trace.getTracer('@sentry/opentelemetry', core$1.SDK_VERSION);
123
- }
124
-
125
- function _applySentryAttributesToSpan(span, options) {
126
- // eslint-disable-next-line deprecation/deprecation
127
- const { origin, op, source, metadata } = options;
128
-
129
- if (origin) {
130
- span.setAttribute(core$1.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
131
- }
132
-
133
- if (op) {
134
- span.setAttribute(core$1.SEMANTIC_ATTRIBUTE_SENTRY_OP, op);
135
- }
136
-
137
- if (source) {
138
- span.setAttribute(core$1.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
139
- }
140
-
141
- if (metadata) {
142
- spanData.setSpanMetadata(span, metadata);
143
- }
144
- }
145
-
146
- function getSpanContext(options) {
147
- const { startTime, attributes, kind } = options;
148
-
149
- // OTEL expects timestamps in ms, not seconds
150
- const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;
151
-
152
- return {
153
- attributes,
154
- kind,
155
- startTime: fixedStartTime,
156
- };
157
- }
158
-
159
- function ensureTimestampInMilliseconds(timestamp) {
160
- const isMs = timestamp < 9999999999;
161
- return isMs ? timestamp * 1000 : timestamp;
162
- }
163
-
164
- function getContext(scope, forceTransaction) {
165
- const ctx = getContextForScope(scope);
166
-
167
- if (!forceTransaction) {
168
- return ctx;
169
- }
170
-
171
- // Else we need to "fix" the context to have no parent span
172
- const parentSpan = api.trace.getSpan(ctx);
173
-
174
- // If there is no parent span, all good, nothing to do!
175
- if (!parentSpan) {
176
- return ctx;
177
- }
178
-
179
- // Else, we need to do two things:
180
- // 1. Unset the parent span from the context, so we'll create a new root span
181
- // 2. Ensure the propagation context is correct, so we'll continue from the parent span
182
- const ctxWithoutSpan = api.trace.deleteSpan(ctx);
183
-
184
- const { spanId, traceId, traceFlags } = parentSpan.spanContext();
185
- // eslint-disable-next-line no-bitwise
186
- const sampled = Boolean(traceFlags & api.TraceFlags.SAMPLED);
187
-
188
- const rootSpan = getActiveSpan.getRootSpan(parentSpan);
189
- const dsc = dynamicSamplingContext.getDynamicSamplingContextFromSpan(rootSpan);
190
- const dscString = utils.dynamicSamplingContextToSentryBaggageHeader(dsc);
191
-
192
- const traceState = dscString ? new core.TraceState().set(constants.SENTRY_TRACE_STATE_DSC, dscString) : undefined;
193
-
194
- const spanContext = {
195
- traceId,
196
- spanId,
197
- isRemote: true,
198
- traceFlags: sampled ? api.TraceFlags.SAMPLED : api.TraceFlags.NONE,
199
- traceState,
200
- };
201
-
202
- const ctxWithSpanContext = api.trace.setSpanContext(ctxWithoutSpan, spanContext);
203
-
204
- return ctxWithSpanContext;
205
- }
206
-
207
- function getContextForScope(scope) {
208
- if (scope) {
209
- const ctx = contextData.getContextFromScope(scope);
210
- if (ctx) {
211
- return ctx;
212
- }
213
- }
214
-
215
- return api.context.active();
216
- }
217
-
218
- exports.startInactiveSpan = startInactiveSpan;
219
- exports.startSpan = startSpan;
220
- exports.startSpanManual = startSpanManual;
221
- exports.withActiveSpan = withActiveSpan;
222
- //# sourceMappingURL=trace.js.map
package/cjs/trace.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"trace.js","sources":["../../src/trace.ts"],"sourcesContent":["import type { Context, Span, SpanContext, SpanOptions, Tracer } from '@opentelemetry/api';\nimport { TraceFlags } from '@opentelemetry/api';\nimport { context } from '@opentelemetry/api';\nimport { SpanStatusCode, trace } from '@opentelemetry/api';\nimport { TraceState, suppressTracing } from '@opentelemetry/core';\nimport {\n SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getClient,\n getCurrentScope,\n handleCallbackErrors,\n} from '@sentry/core';\nimport type { Client, Scope } from '@sentry/types';\nimport { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/utils';\nimport { SENTRY_TRACE_STATE_DSC } from './constants';\n\nimport type { OpenTelemetryClient, OpenTelemetrySpanContext } from './types';\nimport { getContextFromScope } from './utils/contextData';\nimport { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext';\nimport { getRootSpan } from './utils/getActiveSpan';\nimport { setSpanMetadata } from './utils/spanData';\n\n/**\n * Wraps a function with a transaction/span and finishes the span after the function is done.\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.\n *\n * If you want to create a span that is not set as active, use {@link startInactiveSpan}.\n *\n * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, options);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n () => span.end(),\n );\n });\n}\n\n/**\n * Similar to `Sentry.startSpan`. Wraps a function with a span, but does not finish the span\n * after the function is done automatically. You'll have to call `span.end()` manually.\n *\n * The created span is the active span and will be used as parent by other spans created inside the function\n * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.\n *\n * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.\n */\nexport function startSpanManual<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n return tracer.startActiveSpan(name, spanContext, ctx, span => {\n _applySentryAttributesToSpan(span, options);\n\n return handleCallbackErrors(\n () => callback(span),\n () => {\n span.setStatus({ code: SpanStatusCode.ERROR });\n },\n );\n });\n}\n\n/**\n * @deprecated Use {@link startSpan} instead.\n */\nexport const startActiveSpan = startSpan;\n\n/**\n * Creates a span. This span is not set as active, so will not get automatic instrumentation spans\n * as children or be able to be accessed via `Sentry.getSpan()`.\n *\n * If you want to create a span that is set as active, use {@link startSpan}.\n *\n * Note that if you have not enabled tracing extensions via `addTracingExtensions`\n * or you didn't set `tracesSampleRate` or `tracesSampler`, this function will not generate spans\n * and the `span` returned from the callback will be undefined.\n */\nexport function startInactiveSpan(options: OpenTelemetrySpanContext): Span {\n const tracer = getTracer();\n\n const { name } = options;\n\n const activeCtx = getContext(options.scope, options.forceTransaction);\n const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);\n const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;\n\n const spanContext = getSpanContext(options);\n\n const span = tracer.startSpan(name, spanContext, ctx);\n\n _applySentryAttributesToSpan(span, options);\n\n return span;\n}\n\n/**\n * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be\n * passed `null` to start an entirely new span tree.\n *\n * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,\n * spans started within the callback will not be attached to a parent span.\n * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.\n * @returns the value returned from the provided callback function.\n */\nexport function withActiveSpan<T>(span: Span | null, callback: (scope: Scope) => T): T {\n const newContextWithActiveSpan = span ? trace.setSpan(context.active(), span) : trace.deleteSpan(context.active());\n return context.with(newContextWithActiveSpan, () => callback(getCurrentScope()));\n}\n\nfunction getTracer(): Tracer {\n const client = getClient<Client & OpenTelemetryClient>();\n return (client && client.tracer) || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);\n}\n\nfunction _applySentryAttributesToSpan(span: Span, options: OpenTelemetrySpanContext): void {\n // eslint-disable-next-line deprecation/deprecation\n const { origin, op, source, metadata } = options;\n\n if (origin) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);\n }\n\n if (op) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, op);\n }\n\n if (source) {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);\n }\n\n if (metadata) {\n setSpanMetadata(span, metadata);\n }\n}\n\nfunction getSpanContext(options: OpenTelemetrySpanContext): SpanOptions {\n const { startTime, attributes, kind } = options;\n\n // OTEL expects timestamps in ms, not seconds\n const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;\n\n return {\n attributes,\n kind,\n startTime: fixedStartTime,\n };\n}\n\nfunction ensureTimestampInMilliseconds(timestamp: number): number {\n const isMs = timestamp < 9999999999;\n return isMs ? timestamp * 1000 : timestamp;\n}\n\nfunction getContext(scope: Scope | undefined, forceTransaction: boolean | undefined): Context {\n const ctx = getContextForScope(scope);\n\n if (!forceTransaction) {\n return ctx;\n }\n\n // Else we need to \"fix\" the context to have no parent span\n const parentSpan = trace.getSpan(ctx);\n\n // If there is no parent span, all good, nothing to do!\n if (!parentSpan) {\n return ctx;\n }\n\n // Else, we need to do two things:\n // 1. Unset the parent span from the context, so we'll create a new root span\n // 2. Ensure the propagation context is correct, so we'll continue from the parent span\n const ctxWithoutSpan = trace.deleteSpan(ctx);\n\n const { spanId, traceId, traceFlags } = parentSpan.spanContext();\n // eslint-disable-next-line no-bitwise\n const sampled = Boolean(traceFlags & TraceFlags.SAMPLED);\n\n const rootSpan = getRootSpan(parentSpan);\n const dsc = getDynamicSamplingContextFromSpan(rootSpan);\n const dscString = dynamicSamplingContextToSentryBaggageHeader(dsc);\n\n const traceState = dscString ? new TraceState().set(SENTRY_TRACE_STATE_DSC, dscString) : undefined;\n\n const spanContext: SpanContext = {\n traceId,\n spanId,\n isRemote: true,\n traceFlags: sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n traceState,\n };\n\n const ctxWithSpanContext = trace.setSpanContext(ctxWithoutSpan, spanContext);\n\n return ctxWithSpanContext;\n}\n\nfunction getContextForScope(scope?: Scope): Context {\n if (scope) {\n const ctx = getContextFromScope(scope);\n if (ctx) {\n return ctx;\n }\n }\n\n return context.active();\n}\n"],"names":["trace","suppressTracing","handleCallbackErrors","SpanStatusCode","context","getCurrentScope","getClient","SDK_VERSION","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","setSpanMetadata","TraceFlags","getRootSpan","getDynamicSamplingContextFromSpan","dynamicSamplingContextToSentryBaggageHeader","TraceState","SENTRY_TRACE_STATE_DSC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;;;;;;;"}
@@ -1,11 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const core = require('@sentry/core');
4
-
5
- /** Adds an origin to an OTEL Span. */
6
- function addOriginToSpan(span, origin) {
7
- span.setAttribute(core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
8
- }
9
-
10
- exports.addOriginToSpan = addOriginToSpan;
11
- //# sourceMappingURL=addOriginToSpan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOriginToSpan.js","sources":["../../../src/utils/addOriginToSpan.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';\nimport type { SpanOrigin } from '@sentry/types';\n\n/** Adds an origin to an OTEL Span. */\nexport function addOriginToSpan(span: Span, origin: SpanOrigin): void {\n span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);\n}\n"],"names":["SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;AAIA;AACO,SAAS,eAAe,CAAC,IAAI,EAAQ,MAAM,EAAoB;AACtE,EAAE,IAAI,CAAC,YAAY,CAACA,qCAAgC,EAAE,MAAM,CAAC,CAAA;AAC7D;;;;"}
@@ -1,59 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const semanticConventions = require('@opentelemetry/semantic-conventions');
4
- const utils = require('@sentry/utils');
5
-
6
- /**
7
- * Maybe capture a Sentry exception for an OTEL timed event.
8
- * This will check if the event is exception-like and in that case capture it as an exception.
9
- */
10
- function maybeCaptureExceptionForTimedEvent(hub, event, otelSpan) {
11
- if (event.name !== 'exception') {
12
- return;
13
- }
14
-
15
- const attributes = event.attributes;
16
- if (!attributes) {
17
- return;
18
- }
19
-
20
- const message = attributes[semanticConventions.SemanticAttributes.EXCEPTION_MESSAGE];
21
-
22
- if (typeof message !== 'string') {
23
- return;
24
- }
25
-
26
- const syntheticError = new Error(message);
27
-
28
- const stack = attributes[semanticConventions.SemanticAttributes.EXCEPTION_STACKTRACE];
29
- if (utils.isString(stack)) {
30
- syntheticError.stack = stack;
31
- }
32
-
33
- const type = attributes[semanticConventions.SemanticAttributes.EXCEPTION_TYPE];
34
- if (utils.isString(type)) {
35
- syntheticError.name = type;
36
- }
37
-
38
- // eslint-disable-next-line deprecation/deprecation
39
- hub.captureException(syntheticError, {
40
- captureContext: otelSpan
41
- ? {
42
- contexts: {
43
- otel: {
44
- attributes: otelSpan.attributes,
45
- resource: otelSpan.resource.attributes,
46
- },
47
- trace: {
48
- trace_id: otelSpan.spanContext().traceId,
49
- span_id: otelSpan.spanContext().spanId,
50
- parent_span_id: otelSpan.parentSpanId,
51
- },
52
- },
53
- }
54
- : undefined,
55
- });
56
- }
57
-
58
- exports.maybeCaptureExceptionForTimedEvent = maybeCaptureExceptionForTimedEvent;
59
- //# sourceMappingURL=captureExceptionForTimedEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureExceptionForTimedEvent.js","sources":["../../../src/utils/captureExceptionForTimedEvent.ts"],"sourcesContent":["import type { Span as OtelSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport type { Hub } from '@sentry/types';\nimport { isString } from '@sentry/utils';\n\n/**\n * Maybe capture a Sentry exception for an OTEL timed event.\n * This will check if the event is exception-like and in that case capture it as an exception.\n */\nexport function maybeCaptureExceptionForTimedEvent(hub: Hub, event: TimedEvent, otelSpan?: OtelSpan): void {\n if (event.name !== 'exception') {\n return;\n }\n\n const attributes = event.attributes;\n if (!attributes) {\n return;\n }\n\n const message = attributes[SemanticAttributes.EXCEPTION_MESSAGE];\n\n if (typeof message !== 'string') {\n return;\n }\n\n const syntheticError = new Error(message);\n\n const stack = attributes[SemanticAttributes.EXCEPTION_STACKTRACE];\n if (isString(stack)) {\n syntheticError.stack = stack;\n }\n\n const type = attributes[SemanticAttributes.EXCEPTION_TYPE];\n if (isString(type)) {\n syntheticError.name = type;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n hub.captureException(syntheticError, {\n captureContext: otelSpan\n ? {\n contexts: {\n otel: {\n attributes: otelSpan.attributes,\n resource: otelSpan.resource.attributes,\n },\n trace: {\n trace_id: otelSpan.spanContext().traceId,\n span_id: otelSpan.spanContext().spanId,\n parent_span_id: otelSpan.parentSpanId,\n },\n },\n }\n : undefined,\n });\n}\n"],"names":["SemanticAttributes","isString"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACO,SAAS,kCAAkC,CAAC,GAAG,EAAO,KAAK,EAAc,QAAQ,EAAmB;AAC3G,EAAE,IAAI,KAAK,CAAC,IAAK,KAAI,WAAW,EAAE;AAClC,IAAI,OAAM;AACV,GAAE;AACF;AACA,EAAE,MAAM,UAAA,GAAa,KAAK,CAAC,UAAU,CAAA;AACrC,EAAE,IAAI,CAAC,UAAU,EAAE;AACnB,IAAI,OAAM;AACV,GAAE;AACF;AACA,EAAE,MAAM,UAAU,UAAU,CAACA,sCAAkB,CAAC,iBAAiB,CAAC,CAAA;AAClE;AACA,EAAE,IAAI,OAAO,OAAQ,KAAI,QAAQ,EAAE;AACnC,IAAI,OAAM;AACV,GAAE;AACF;AACA,EAAE,MAAM,cAAe,GAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;AAC3C;AACA,EAAE,MAAM,QAAQ,UAAU,CAACA,sCAAkB,CAAC,oBAAoB,CAAC,CAAA;AACnE,EAAE,IAAIC,cAAQ,CAAC,KAAK,CAAC,EAAE;AACvB,IAAI,cAAc,CAAC,KAAM,GAAE,KAAK,CAAA;AAChC,GAAE;AACF;AACA,EAAE,MAAM,OAAO,UAAU,CAACD,sCAAkB,CAAC,cAAc,CAAC,CAAA;AAC5D,EAAE,IAAIC,cAAQ,CAAC,IAAI,CAAC,EAAE;AACtB,IAAI,cAAc,CAAC,IAAK,GAAE,IAAI,CAAA;AAC9B,GAAE;AACF;AACA;AACA,EAAE,GAAG,CAAC,gBAAgB,CAAC,cAAc,EAAE;AACvC,IAAI,cAAc,EAAE,QAAA;AACpB,QAAQ;AACR,UAAU,QAAQ,EAAE;AACpB,YAAY,IAAI,EAAE;AAClB,cAAc,UAAU,EAAE,QAAQ,CAAC,UAAU;AAC7C,cAAc,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,UAAU;AACpD,aAAa;AACb,YAAY,KAAK,EAAE;AACnB,cAAc,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO;AACtD,cAAc,OAAO,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,MAAM;AACpD,cAAc,cAAc,EAAE,QAAQ,CAAC,YAAY;AACnD,aAAa;AACb,WAAW;AACX,SAAQ;AACR,QAAQ,SAAS;AACjB,GAAG,CAAC,CAAA;AACJ;;;;"}
@@ -1,79 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const constants = require('../constants.js');
4
-
5
- const SCOPE_CONTEXT_MAP = new WeakMap();
6
-
7
- /**
8
- * Try to get the Propagation Context from the given OTEL context.
9
- * This requires the SentryPropagator to be registered.
10
- */
11
- function getPropagationContextFromContext(context) {
12
- return context.getValue(constants.SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY) ;
13
- }
14
-
15
- /**
16
- * Set a Propagation Context on an OTEL context..
17
- * This will return a forked context with the Propagation Context set.
18
- */
19
- function setPropagationContextOnContext(context, propagationContext) {
20
- return context.setValue(constants.SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY, propagationContext);
21
- }
22
-
23
- /**
24
- * Try to get the Hub from the given OTEL context.
25
- * This requires a Context Manager that was wrapped with getWrappedContextManager.
26
- */
27
- function getHubFromContext(context) {
28
- return context.getValue(constants.SENTRY_HUB_CONTEXT_KEY) ;
29
- }
30
-
31
- /**
32
- * Set a Hub on an OTEL context..
33
- * This will return a forked context with the Propagation Context set.
34
- */
35
- function setHubOnContext(context, hub) {
36
- return context.setValue(constants.SENTRY_HUB_CONTEXT_KEY, hub);
37
- }
38
-
39
- /**
40
- * Try to get the current scopes from the given OTEL context.
41
- * This requires a Context Manager that was wrapped with getWrappedContextManager.
42
- */
43
- function getScopesFromContext(context) {
44
- return context.getValue(constants.SENTRY_SCOPES_CONTEXT_KEY) ;
45
- }
46
-
47
- /**
48
- * Set the current scopes on an OTEL context.
49
- * This will return a forked context with the Propagation Context set.
50
- */
51
- function setScopesOnContext(context, scopes) {
52
- return context.setValue(constants.SENTRY_SCOPES_CONTEXT_KEY, scopes);
53
- }
54
-
55
- /**
56
- * Set the context on the scope so we can later look it up.
57
- * We need this to get the context from the scope in the `trace` functions.
58
- */
59
- function setContextOnScope(scope, context) {
60
- SCOPE_CONTEXT_MAP.set(scope, context);
61
- }
62
-
63
- /**
64
- * Get the context related to a scope.
65
- * TODO v8: Use this for the `trace` functions.
66
- * */
67
- function getContextFromScope(scope) {
68
- return SCOPE_CONTEXT_MAP.get(scope);
69
- }
70
-
71
- exports.getContextFromScope = getContextFromScope;
72
- exports.getHubFromContext = getHubFromContext;
73
- exports.getPropagationContextFromContext = getPropagationContextFromContext;
74
- exports.getScopesFromContext = getScopesFromContext;
75
- exports.setContextOnScope = setContextOnScope;
76
- exports.setHubOnContext = setHubOnContext;
77
- exports.setPropagationContextOnContext = setPropagationContextOnContext;
78
- exports.setScopesOnContext = setScopesOnContext;
79
- //# sourceMappingURL=contextData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contextData.js","sources":["../../../src/utils/contextData.ts"],"sourcesContent":["import type { Context } from '@opentelemetry/api';\nimport type { Hub, PropagationContext, Scope } from '@sentry/types';\n\nimport {\n SENTRY_HUB_CONTEXT_KEY,\n SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY,\n SENTRY_SCOPES_CONTEXT_KEY,\n} from '../constants';\nimport type { CurrentScopes } from '../types';\n\nconst SCOPE_CONTEXT_MAP = new WeakMap<Scope, Context>();\n\n/**\n * Try to get the Propagation Context from the given OTEL context.\n * This requires the SentryPropagator to be registered.\n */\nexport function getPropagationContextFromContext(context: Context): PropagationContext | undefined {\n return context.getValue(SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY) as PropagationContext | undefined;\n}\n\n/**\n * Set a Propagation Context on an OTEL context..\n * This will return a forked context with the Propagation Context set.\n */\nexport function setPropagationContextOnContext(context: Context, propagationContext: PropagationContext): Context {\n return context.setValue(SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY, propagationContext);\n}\n\n/**\n * Try to get the Hub from the given OTEL context.\n * This requires a Context Manager that was wrapped with getWrappedContextManager.\n */\nexport function getHubFromContext(context: Context): Hub | undefined {\n return context.getValue(SENTRY_HUB_CONTEXT_KEY) as Hub | undefined;\n}\n\n/**\n * Set a Hub on an OTEL context..\n * This will return a forked context with the Propagation Context set.\n */\nexport function setHubOnContext(context: Context, hub: Hub): Context {\n return context.setValue(SENTRY_HUB_CONTEXT_KEY, hub);\n}\n\n/**\n * Try to get the current scopes from the given OTEL context.\n * This requires a Context Manager that was wrapped with getWrappedContextManager.\n */\nexport function getScopesFromContext(context: Context): CurrentScopes | undefined {\n return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) as CurrentScopes | undefined;\n}\n\n/**\n * Set the current scopes on an OTEL context.\n * This will return a forked context with the Propagation Context set.\n */\nexport function setScopesOnContext(context: Context, scopes: CurrentScopes): Context {\n return context.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);\n}\n\n/**\n * Set the context on the scope so we can later look it up.\n * We need this to get the context from the scope in the `trace` functions.\n */\nexport function setContextOnScope(scope: Scope, context: Context): void {\n SCOPE_CONTEXT_MAP.set(scope, context);\n}\n\n/**\n * Get the context related to a scope.\n * TODO v8: Use this for the `trace` functions.\n * */\nexport function getContextFromScope(scope: Scope): Context | undefined {\n return SCOPE_CONTEXT_MAP.get(scope);\n}\n"],"names":["SENTRY_PROPAGATION_CONTEXT_CONTEXT_KEY","SENTRY_HUB_CONTEXT_KEY","SENTRY_SCOPES_CONTEXT_KEY"],"mappings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,CAAC,CAAA;AACrC;;;;;;;;;;;"}
@@ -1,9 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- /** Convert an OTEL time to seconds */
4
- function convertOtelTimeToSeconds([seconds, nano]) {
5
- return seconds + nano / 1000000000;
6
- }
7
-
8
- exports.convertOtelTimeToSeconds = convertOtelTimeToSeconds;
9
- //# sourceMappingURL=convertOtelTimeToSeconds.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertOtelTimeToSeconds.js","sources":["../../../src/utils/convertOtelTimeToSeconds.ts"],"sourcesContent":["/** Convert an OTEL time to seconds */\nexport function convertOtelTimeToSeconds([seconds, nano]: [number, number]): number {\n return seconds + nano / 1_000_000_000;\n}\n"],"names":[],"mappings":";;AAAA;AACO,SAAS,wBAAwB,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,EAA4B;AACpF,EAAE,OAAO,OAAA,GAAU,IAAA,GAAO,UAAa,CAAA;AACvC;;;;"}
@@ -1,64 +0,0 @@
1
- var {
2
- _optionalChain
3
- } = require('@sentry/utils');
4
-
5
- Object.defineProperty(exports, '__esModule', { value: true });
6
-
7
- const api = require('@opentelemetry/api');
8
- const core = require('@sentry/core');
9
- const utils = require('@sentry/utils');
10
- const constants = require('../constants.js');
11
- const spanTypes = require('./spanTypes.js');
12
-
13
- /**
14
- * Creates a dynamic sampling context from a span (and client and scope)
15
- *
16
- * @param span the span from which a few values like the root span name and sample rate are extracted.
17
- *
18
- * @returns a dynamic sampling context
19
- */
20
- function getDynamicSamplingContextFromSpan(span) {
21
- const client = core.getClient();
22
- if (!client) {
23
- return {};
24
- }
25
-
26
- const traceState = span.spanContext().traceState;
27
- const traceStateDsc = _optionalChain([traceState, 'optionalAccess', _ => _.get, 'call', _2 => _2(constants.SENTRY_TRACE_STATE_DSC)]);
28
-
29
- // If the span has a DSC, we want it to take precedence
30
- const dscOnSpan = traceStateDsc ? utils.baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;
31
-
32
- if (dscOnSpan) {
33
- return dscOnSpan;
34
- }
35
-
36
- const dsc = core.getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
37
-
38
- const attributes = spanTypes.spanHasAttributes(span) ? span.attributes : {};
39
-
40
- const sampleRate = attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
41
- if (sampleRate != null) {
42
- dsc.sample_rate = `${sampleRate}`;
43
- }
44
-
45
- // We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII
46
- const source = attributes[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
47
- const name = spanTypes.spanHasName(span) ? span.name : '';
48
-
49
- if (source !== 'url' && name) {
50
- dsc.transaction = name;
51
- }
52
-
53
- // TODO: Once we aligned span types, use spanIsSampled() from core instead
54
- // eslint-disable-next-line no-bitwise
55
- const sampled = Boolean(span.spanContext().traceFlags & api.TraceFlags.SAMPLED);
56
- dsc.sampled = String(sampled);
57
-
58
- client.emit('createDsc', dsc);
59
-
60
- return dsc;
61
- }
62
-
63
- exports.getDynamicSamplingContextFromSpan = getDynamicSamplingContextFromSpan;
64
- //# sourceMappingURL=dynamicSamplingContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dynamicSamplingContext.js","sources":["../../../src/utils/dynamicSamplingContext.ts"],"sourcesContent":["import { TraceFlags } from '@opentelemetry/api';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n getClient,\n getDynamicSamplingContextFromClient,\n} from '@sentry/core';\nimport type { DynamicSamplingContext } from '@sentry/types';\nimport { baggageHeaderToDynamicSamplingContext } from '@sentry/utils';\nimport { SENTRY_TRACE_STATE_DSC } from '../constants';\nimport type { AbstractSpan } from '../types';\nimport { spanHasAttributes, spanHasName } from './spanTypes';\n\n/**\n * Creates a dynamic sampling context from a span (and client and scope)\n *\n * @param span the span from which a few values like the root span name and sample rate are extracted.\n *\n * @returns a dynamic sampling context\n */\nexport function getDynamicSamplingContextFromSpan(span: AbstractSpan): Readonly<Partial<DynamicSamplingContext>> {\n const client = getClient();\n if (!client) {\n return {};\n }\n\n const traceState = span.spanContext().traceState;\n const traceStateDsc = traceState?.get(SENTRY_TRACE_STATE_DSC);\n\n // If the span has a DSC, we want it to take precedence\n const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;\n\n if (dscOnSpan) {\n return dscOnSpan;\n }\n\n const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);\n\n const attributes = spanHasAttributes(span) ? span.attributes : {};\n\n const sampleRate = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];\n if (sampleRate != null) {\n dsc.sample_rate = `${sampleRate}`;\n }\n\n // We don't want to have a transaction name in the DSC if the source is \"url\" because URLs might contain PII\n const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];\n const name = spanHasName(span) ? span.name : '';\n\n if (source !== 'url' && name) {\n dsc.transaction = name;\n }\n\n // TODO: Once we aligned span types, use spanIsSampled() from core instead\n // eslint-disable-next-line no-bitwise\n const sampled = Boolean(span.spanContext().traceFlags & TraceFlags.SAMPLED);\n dsc.sampled = String(sampled);\n\n client.emit('createDsc', dsc);\n\n return dsc;\n}\n"],"names":["getClient","SENTRY_TRACE_STATE_DSC","baggageHeaderToDynamicSamplingContext","getDynamicSamplingContextFromClient","spanHasAttributes","SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","spanHasName","TraceFlags"],"mappings":";;;;;;;;;;;;AAaA,CAAA,CAAA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EA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AAA,CAAA;;EAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,WAAA,EAAA,CAAA,CAAA,CAAA,CAAA;;EAEA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,GAAA;AACA;;"}
@@ -1,29 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const api = require('@opentelemetry/api');
4
- const spanData = require('./spanData.js');
5
-
6
- /**
7
- * Returns the currently active span.
8
- */
9
- function getActiveSpan() {
10
- return api.trace.getActiveSpan();
11
- }
12
-
13
- /**
14
- * Get the root span for the given span.
15
- * The given span may be the root span itself.
16
- */
17
- function getRootSpan(span) {
18
- let parent = span;
19
-
20
- while (spanData.getSpanParent(parent)) {
21
- parent = spanData.getSpanParent(parent) ;
22
- }
23
-
24
- return parent;
25
- }
26
-
27
- exports.getActiveSpan = getActiveSpan;
28
- exports.getRootSpan = getRootSpan;
29
- //# sourceMappingURL=getActiveSpan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getActiveSpan.js","sources":["../../../src/utils/getActiveSpan.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport { trace } from '@opentelemetry/api';\n\nimport { getSpanParent } from './spanData';\n\n/**\n * Returns the currently active span.\n */\nexport function getActiveSpan(): Span | undefined {\n return trace.getActiveSpan();\n}\n\n/**\n * Get the root span for the given span.\n * The given span may be the root span itself.\n */\nexport function getRootSpan(span: Span): Span {\n let parent: Span = span;\n\n while (getSpanParent(parent)) {\n parent = getSpanParent(parent) as Span;\n }\n\n return parent;\n}\n"],"names":["trace","getSpanParent"],"mappings":";;;;;AAKA;AACA;AACA;AACO,SAAS,aAAa,GAAqB;AAClD,EAAE,OAAOA,SAAK,CAAC,aAAa,EAAE,CAAA;AAC9B,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,IAAI,EAAc;AAC9C,EAAE,IAAI,MAAM,GAAS,IAAI,CAAA;AACzB;AACA,EAAE,OAAOC,sBAAa,CAAC,MAAM,CAAC,EAAE;AAChC,IAAI,MAAO,GAAEA,sBAAa,CAAC,MAAM,CAAE,EAAA;AACnC,GAAE;AACF;AACA,EAAE,OAAO,MAAM,CAAA;AACf;;;;;"}
@@ -1,48 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const semanticConventions = require('@opentelemetry/semantic-conventions');
4
- const utils = require('@sentry/utils');
5
- const spanTypes = require('./spanTypes.js');
6
-
7
- /**
8
- * Get sanitizied request data from an OTEL span.
9
- */
10
- function getRequestSpanData(span) {
11
- // The base `Span` type has no `attributes`, so we need to guard here against that
12
- if (!spanTypes.spanHasAttributes(span)) {
13
- return {};
14
- }
15
-
16
- const data = {
17
- url: span.attributes[semanticConventions.SemanticAttributes.HTTP_URL] ,
18
- 'http.method': span.attributes[semanticConventions.SemanticAttributes.HTTP_METHOD] ,
19
- };
20
-
21
- // Default to GET if URL is set but method is not
22
- if (!data['http.method'] && data.url) {
23
- data['http.method'] = 'GET';
24
- }
25
-
26
- try {
27
- const urlStr = span.attributes[semanticConventions.SemanticAttributes.HTTP_URL];
28
- if (typeof urlStr === 'string') {
29
- const url = utils.parseUrl(urlStr);
30
-
31
- data.url = utils.getSanitizedUrlString(url);
32
-
33
- if (url.search) {
34
- data['http.query'] = url.search;
35
- }
36
- if (url.hash) {
37
- data['http.fragment'] = url.hash;
38
- }
39
- }
40
- } catch (e) {
41
- // ignore
42
- }
43
-
44
- return data;
45
- }
46
-
47
- exports.getRequestSpanData = getRequestSpanData;
48
- //# sourceMappingURL=getRequestSpanData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRequestSpanData.js","sources":["../../../src/utils/getRequestSpanData.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { ReadableSpan } from '@opentelemetry/sdk-trace-base';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport type { SanitizedRequestData } from '@sentry/types';\nimport { getSanitizedUrlString, parseUrl } from '@sentry/utils';\n\nimport { spanHasAttributes } from './spanTypes';\n\n/**\n * Get sanitizied request data from an OTEL span.\n */\nexport function getRequestSpanData(span: Span | ReadableSpan): Partial<SanitizedRequestData> {\n // The base `Span` type has no `attributes`, so we need to guard here against that\n if (!spanHasAttributes(span)) {\n return {};\n }\n\n const data: Partial<SanitizedRequestData> = {\n url: span.attributes[SemanticAttributes.HTTP_URL] as string | undefined,\n 'http.method': span.attributes[SemanticAttributes.HTTP_METHOD] as string | undefined,\n };\n\n // Default to GET if URL is set but method is not\n if (!data['http.method'] && data.url) {\n data['http.method'] = 'GET';\n }\n\n try {\n const urlStr = span.attributes[SemanticAttributes.HTTP_URL];\n if (typeof urlStr === 'string') {\n const url = parseUrl(urlStr);\n\n data.url = getSanitizedUrlString(url);\n\n if (url.search) {\n data['http.query'] = url.search;\n }\n if (url.hash) {\n data['http.fragment'] = url.hash;\n }\n }\n } catch {\n // ignore\n }\n\n return data;\n}\n"],"names":["spanHasAttributes","SemanticAttributes","parseUrl","getSanitizedUrlString"],"mappings":";;;;;;AAQA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,IAAI,EAAsD;AAC7F;AACA,EAAE,IAAI,CAACA,2BAAiB,CAAC,IAAI,CAAC,EAAE;AAChC,IAAI,OAAO,EAAE,CAAA;AACb,GAAE;AACF;AACA,EAAE,MAAM,IAAI,GAAkC;AAC9C,IAAI,GAAG,EAAE,IAAI,CAAC,UAAU,CAACC,sCAAkB,CAAC,QAAQ,CAAE;AACtD,IAAI,aAAa,EAAE,IAAI,CAAC,UAAU,CAACA,sCAAkB,CAAC,WAAW,CAAE;AACnE,GAAG,CAAA;AACH;AACA;AACA,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa,CAAA,IAAK,IAAI,CAAC,GAAG,EAAE;AACxC,IAAI,IAAI,CAAC,aAAa,CAAA,GAAI,KAAK,CAAA;AAC/B,GAAE;AACF;AACA,EAAE,IAAI;AACN,IAAI,MAAM,MAAO,GAAE,IAAI,CAAC,UAAU,CAACA,sCAAkB,CAAC,QAAQ,CAAC,CAAA;AAC/D,IAAI,IAAI,OAAO,MAAO,KAAI,QAAQ,EAAE;AACpC,MAAM,MAAM,GAAI,GAAEC,cAAQ,CAAC,MAAM,CAAC,CAAA;AAClC;AACA,MAAM,IAAI,CAAC,GAAA,GAAMC,2BAAqB,CAAC,GAAG,CAAC,CAAA;AAC3C;AACA,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE;AACtB,QAAQ,IAAI,CAAC,YAAY,IAAI,GAAG,CAAC,MAAM,CAAA;AACvC,OAAM;AACN,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE;AACpB,QAAQ,IAAI,CAAC,eAAe,IAAI,GAAG,CAAC,IAAI,CAAA;AACxC,OAAM;AACN,KAAI;AACJ,IAAI,OAAM,CAAA,EAAA;AACV;AACA,GAAE;AACF;AACA,EAAE,OAAO,IAAI,CAAA;AACb;;;;"}
@@ -1,21 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const api = require('@opentelemetry/api');
4
- const spanTypes = require('./spanTypes.js');
5
-
6
- /**
7
- * Get the span kind from a span.
8
- * For whatever reason, this is not public API on the generic "Span" type,
9
- * so we need to check if we actually have a `SDKTraceBaseSpan` where we can fetch this from.
10
- * Otherwise, we fall back to `SpanKind.INTERNAL`.
11
- */
12
- function getSpanKind(span) {
13
- if (spanTypes.spanHasKind(span)) {
14
- return span.kind;
15
- }
16
-
17
- return api.SpanKind.INTERNAL;
18
- }
19
-
20
- exports.getSpanKind = getSpanKind;
21
- //# sourceMappingURL=getSpanKind.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getSpanKind.js","sources":["../../../src/utils/getSpanKind.ts"],"sourcesContent":["import { SpanKind } from '@opentelemetry/api';\n\nimport type { AbstractSpan } from '../types';\nimport { spanHasKind } from './spanTypes';\n\n/**\n * Get the span kind from a span.\n * For whatever reason, this is not public API on the generic \"Span\" type,\n * so we need to check if we actually have a `SDKTraceBaseSpan` where we can fetch this from.\n * Otherwise, we fall back to `SpanKind.INTERNAL`.\n */\nexport function getSpanKind(span: AbstractSpan): SpanKind {\n if (spanHasKind(span)) {\n return span.kind;\n }\n\n return SpanKind.INTERNAL;\n}\n"],"names":["spanHasKind","SpanKind"],"mappings":";;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,IAAI,EAA0B;AAC1D,EAAE,IAAIA,qBAAW,CAAC,IAAI,CAAC,EAAE;AACzB,IAAI,OAAO,IAAI,CAAC,IAAI,CAAA;AACpB,GAAE;AACF;AACA,EAAE,OAAOC,YAAQ,CAAC,QAAQ,CAAA;AAC1B;;;;"}