@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
@@ -1,96 +0,0 @@
1
- import { trace, ROOT_CONTEXT } from '@opentelemetry/api';
2
- import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
3
- import { getCurrentHub } from '@sentry/core';
4
- import { logger } from '@sentry/utils';
5
- import { DEBUG_BUILD } from './debug-build.js';
6
- import { SentrySpanExporter } from './spanExporter.js';
7
- import { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForTimedEvent.js';
8
- import { getHubFromContext } from './utils/contextData.js';
9
- import { setIsSetup } from './utils/setupCheck.js';
10
- import { setSpanParent, setSpanHub, setSpanScopes, getSpanHub } from './utils/spanData.js';
11
-
12
- function onSpanStart(span, parentContext) {
13
- // This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK
14
- const parentSpan = trace.getSpan(parentContext);
15
- const hub = getHubFromContext(parentContext);
16
-
17
- // We need access to the parent span in order to be able to move up the span tree for breadcrumbs
18
- if (parentSpan) {
19
- setSpanParent(span, parentSpan);
20
- }
21
-
22
- // The root context does not have a hub stored, so we check for this specifically
23
- // We do this instead of just falling back to `getCurrentHub` to avoid attaching the wrong hub
24
- let actualHub = hub;
25
- if (parentContext === ROOT_CONTEXT) {
26
- // eslint-disable-next-line deprecation/deprecation
27
- actualHub = getCurrentHub();
28
- }
29
-
30
- // We need the scope at time of span creation in order to apply it to the event when the span is finished
31
- if (actualHub) {
32
- // eslint-disable-next-line deprecation/deprecation
33
- const scope = actualHub.getScope();
34
- // eslint-disable-next-line deprecation/deprecation
35
- const isolationScope = actualHub.getIsolationScope();
36
- setSpanHub(span, actualHub);
37
- setSpanScopes(span, { scope, isolationScope });
38
- }
39
- }
40
-
41
- function onSpanEnd(span) {
42
- // Capture exceptions as events
43
- // eslint-disable-next-line deprecation/deprecation
44
- const hub = getSpanHub(span) || getCurrentHub();
45
- span.events.forEach(event => {
46
- maybeCaptureExceptionForTimedEvent(hub, event, span);
47
- });
48
- }
49
-
50
- /**
51
- * Converts OpenTelemetry Spans to Sentry Spans and sends them to Sentry via
52
- * the Sentry SDK.
53
- */
54
- class SentrySpanProcessor extends BatchSpanProcessor {
55
- constructor() {
56
- super(new SentrySpanExporter());
57
-
58
- setIsSetup('SentrySpanProcessor');
59
- }
60
-
61
- /**
62
- * @inheritDoc
63
- */
64
- onStart(span, parentContext) {
65
- onSpanStart(span, parentContext);
66
-
67
- DEBUG_BUILD && logger.log(`[Tracing] Starting span "${span.name}" (${span.spanContext().spanId})`);
68
-
69
- return super.onStart(span, parentContext);
70
- }
71
-
72
- /** @inheritDoc */
73
- onEnd(span) {
74
- DEBUG_BUILD && logger.log(`[Tracing] Finishing span "${span.name}" (${span.spanContext().spanId})`);
75
-
76
- if (!this._shouldSendSpanToSentry(span)) {
77
- // Prevent this being called to super.onEnd(), which would pass this to the span exporter
78
- return;
79
- }
80
-
81
- onSpanEnd(span);
82
-
83
- return super.onEnd(span);
84
- }
85
-
86
- /**
87
- * You can overwrite this in a sub class to implement custom behavior for dropping spans.
88
- * If you return `false` here, the span will not be passed to the exporter and thus not be sent.
89
- */
90
- _shouldSendSpanToSentry(_span) {
91
- return true;
92
- }
93
- }
94
-
95
- export { SentrySpanProcessor };
96
- //# sourceMappingURL=spanProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanProcessor.js","sources":["../../src/spanProcessor.ts"],"sourcesContent":["import type { Context } from '@opentelemetry/api';\nimport { ROOT_CONTEXT, trace } from '@opentelemetry/api';\nimport type { Span, SpanProcessor as SpanProcessorInterface } from '@opentelemetry/sdk-trace-base';\nimport { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { getCurrentHub } from '@sentry/core';\nimport { logger } from '@sentry/utils';\n\nimport { DEBUG_BUILD } from './debug-build';\nimport { SentrySpanExporter } from './spanExporter';\nimport { maybeCaptureExceptionForTimedEvent } from './utils/captureExceptionForTimedEvent';\nimport { getHubFromContext } from './utils/contextData';\nimport { setIsSetup } from './utils/setupCheck';\nimport { getSpanHub, setSpanHub, setSpanParent, setSpanScopes } from './utils/spanData';\n\nfunction onSpanStart(span: Span, parentContext: Context): void {\n // This is a reliable way to get the parent span - because this is exactly how the parent is identified in the OTEL SDK\n const parentSpan = trace.getSpan(parentContext);\n const hub = getHubFromContext(parentContext);\n\n // We need access to the parent span in order to be able to move up the span tree for breadcrumbs\n if (parentSpan) {\n setSpanParent(span, parentSpan);\n }\n\n // The root context does not have a hub stored, so we check for this specifically\n // We do this instead of just falling back to `getCurrentHub` to avoid attaching the wrong hub\n let actualHub = hub;\n if (parentContext === ROOT_CONTEXT) {\n // eslint-disable-next-line deprecation/deprecation\n actualHub = getCurrentHub();\n }\n\n // We need the scope at time of span creation in order to apply it to the event when the span is finished\n if (actualHub) {\n // eslint-disable-next-line deprecation/deprecation\n const scope = actualHub.getScope();\n // eslint-disable-next-line deprecation/deprecation\n const isolationScope = actualHub.getIsolationScope();\n setSpanHub(span, actualHub);\n setSpanScopes(span, { scope, isolationScope });\n }\n}\n\nfunction onSpanEnd(span: Span): void {\n // Capture exceptions as events\n // eslint-disable-next-line deprecation/deprecation\n const hub = getSpanHub(span) || getCurrentHub();\n span.events.forEach(event => {\n maybeCaptureExceptionForTimedEvent(hub, event, span);\n });\n}\n\n/**\n * Converts OpenTelemetry Spans to Sentry Spans and sends them to Sentry via\n * the Sentry SDK.\n */\nexport class SentrySpanProcessor extends BatchSpanProcessor implements SpanProcessorInterface {\n public constructor() {\n super(new SentrySpanExporter());\n\n setIsSetup('SentrySpanProcessor');\n }\n\n /**\n * @inheritDoc\n */\n public onStart(span: Span, parentContext: Context): void {\n onSpanStart(span, parentContext);\n\n DEBUG_BUILD && logger.log(`[Tracing] Starting span \"${span.name}\" (${span.spanContext().spanId})`);\n\n return super.onStart(span, parentContext);\n }\n\n /** @inheritDoc */\n public onEnd(span: Span): void {\n DEBUG_BUILD && logger.log(`[Tracing] Finishing span \"${span.name}\" (${span.spanContext().spanId})`);\n\n if (!this._shouldSendSpanToSentry(span)) {\n // Prevent this being called to super.onEnd(), which would pass this to the span exporter\n return;\n }\n\n onSpanEnd(span);\n\n return super.onEnd(span);\n }\n\n /**\n * You can overwrite this in a sub class to implement custom behavior for dropping spans.\n * If you return `false` here, the span will not be passed to the exporter and thus not be sent.\n */\n protected _shouldSendSpanToSentry(_span: Span): boolean {\n return true;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAcA,SAAS,WAAW,CAAC,IAAI,EAAQ,aAAa,EAAiB;AAC/D;AACA,EAAE,MAAM,aAAa,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;AACjD,EAAE,MAAM,GAAI,GAAE,iBAAiB,CAAC,aAAa,CAAC,CAAA;AAC9C;AACA;AACA,EAAE,IAAI,UAAU,EAAE;AAClB,IAAI,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;AACnC,GAAE;AACF;AACA;AACA;AACA,EAAE,IAAI,SAAU,GAAE,GAAG,CAAA;AACrB,EAAE,IAAI,aAAc,KAAI,YAAY,EAAE;AACtC;AACA,IAAI,SAAU,GAAE,aAAa,EAAE,CAAA;AAC/B,GA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AAS,KAAK,CAAC,IAAI,EAAc;AACjC,IAAI,WAAA,IAAe,MAAM,CAAC,GAAG,CAAC,CAAC,0BAA0B,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACvG;AACA,IAAI,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE;AAC7C;AACA,MAAM,OAAM;AACZ,KAAI;AACJ;AACA,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;AACnB;AACA,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAC5B,GAAE;AACF;AACA;AACA;AACA;AACA;AACA,GAAY,uBAAuB,CAAC,KAAK,EAAiB;AAC1D,IAAI,OAAO,IAAI,CAAA;AACf,GAAE;AACF;;;;"}
package/esm/trace.js DELETED
@@ -1,217 +0,0 @@
1
- import { trace, SpanStatusCode, context, TraceFlags } from '@opentelemetry/api';
2
- import { suppressTracing, TraceState } from '@opentelemetry/core';
3
- import { handleCallbackErrors, getCurrentScope, getClient, SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
4
- import { dynamicSamplingContextToSentryBaggageHeader } from '@sentry/utils';
5
- import { SENTRY_TRACE_STATE_DSC } from './constants.js';
6
- import { getContextFromScope } from './utils/contextData.js';
7
- import { getDynamicSamplingContextFromSpan } from './utils/dynamicSamplingContext.js';
8
- import { getRootSpan } from './utils/getActiveSpan.js';
9
- import { setSpanMetadata } from './utils/spanData.js';
10
-
11
- /**
12
- * Wraps a function with a transaction/span and finishes the span after the function is done.
13
- * The created span is the active span and will be used as parent by other spans created inside the function
14
- * and can be accessed via `Sentry.getSpan()`, as long as the function is executed while the scope is active.
15
- *
16
- * If you want to create a span that is not set as active, use {@link startInactiveSpan}.
17
- *
18
- * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.
19
- */
20
- function startSpan(options, callback) {
21
- const tracer = getTracer();
22
-
23
- const { name } = options;
24
-
25
- const activeCtx = getContext(options.scope, options.forceTransaction);
26
- const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
27
- const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;
28
-
29
- const spanContext = getSpanContext(options);
30
-
31
- return tracer.startActiveSpan(name, spanContext, ctx, span => {
32
- _applySentryAttributesToSpan(span, options);
33
-
34
- return handleCallbackErrors(
35
- () => callback(span),
36
- () => {
37
- span.setStatus({ code: SpanStatusCode.ERROR });
38
- },
39
- () => span.end(),
40
- );
41
- });
42
- }
43
-
44
- /**
45
- * Similar to `Sentry.startSpan`. Wraps a function with a span, but does not finish the span
46
- * after the function is done automatically. You'll have to call `span.end()` manually.
47
- *
48
- * The created span is the active span and will be used as parent by other spans created inside the function
49
- * and can be accessed via `Sentry.getActiveSpan()`, as long as the function is executed while the scope is active.
50
- *
51
- * Note that you'll always get a span passed to the callback, it may just be a NonRecordingSpan if the span is not sampled.
52
- */
53
- function startSpanManual(options, callback) {
54
- const tracer = getTracer();
55
-
56
- const { name } = options;
57
-
58
- const activeCtx = getContext(options.scope, options.forceTransaction);
59
- const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
60
- const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;
61
-
62
- const spanContext = getSpanContext(options);
63
-
64
- return tracer.startActiveSpan(name, spanContext, ctx, span => {
65
- _applySentryAttributesToSpan(span, options);
66
-
67
- return handleCallbackErrors(
68
- () => callback(span),
69
- () => {
70
- span.setStatus({ code: SpanStatusCode.ERROR });
71
- },
72
- );
73
- });
74
- }
75
-
76
- /**
77
- * Creates a span. This span is not set as active, so will not get automatic instrumentation spans
78
- * as children or be able to be accessed via `Sentry.getSpan()`.
79
- *
80
- * If you want to create a span that is set as active, use {@link startSpan}.
81
- *
82
- * Note that if you have not enabled tracing extensions via `addTracingExtensions`
83
- * or you didn't set `tracesSampleRate` or `tracesSampler`, this function will not generate spans
84
- * and the `span` returned from the callback will be undefined.
85
- */
86
- function startInactiveSpan(options) {
87
- const tracer = getTracer();
88
-
89
- const { name } = options;
90
-
91
- const activeCtx = getContext(options.scope, options.forceTransaction);
92
- const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
93
- const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;
94
-
95
- const spanContext = getSpanContext(options);
96
-
97
- const span = tracer.startSpan(name, spanContext, ctx);
98
-
99
- _applySentryAttributesToSpan(span, options);
100
-
101
- return span;
102
- }
103
-
104
- /**
105
- * Forks the current scope and sets the provided span as active span in the context of the provided callback. Can be
106
- * passed `null` to start an entirely new span tree.
107
- *
108
- * @param span Spans started in the context of the provided callback will be children of this span. If `null` is passed,
109
- * spans started within the callback will not be attached to a parent span.
110
- * @param callback Execution context in which the provided span will be active. Is passed the newly forked scope.
111
- * @returns the value returned from the provided callback function.
112
- */
113
- function withActiveSpan(span, callback) {
114
- const newContextWithActiveSpan = span ? trace.setSpan(context.active(), span) : trace.deleteSpan(context.active());
115
- return context.with(newContextWithActiveSpan, () => callback(getCurrentScope()));
116
- }
117
-
118
- function getTracer() {
119
- const client = getClient();
120
- return (client && client.tracer) || trace.getTracer('@sentry/opentelemetry', SDK_VERSION);
121
- }
122
-
123
- function _applySentryAttributesToSpan(span, options) {
124
- // eslint-disable-next-line deprecation/deprecation
125
- const { origin, op, source, metadata } = options;
126
-
127
- if (origin) {
128
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
129
- }
130
-
131
- if (op) {
132
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, op);
133
- }
134
-
135
- if (source) {
136
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
137
- }
138
-
139
- if (metadata) {
140
- setSpanMetadata(span, metadata);
141
- }
142
- }
143
-
144
- function getSpanContext(options) {
145
- const { startTime, attributes, kind } = options;
146
-
147
- // OTEL expects timestamps in ms, not seconds
148
- const fixedStartTime = typeof startTime === 'number' ? ensureTimestampInMilliseconds(startTime) : startTime;
149
-
150
- return {
151
- attributes,
152
- kind,
153
- startTime: fixedStartTime,
154
- };
155
- }
156
-
157
- function ensureTimestampInMilliseconds(timestamp) {
158
- const isMs = timestamp < 9999999999;
159
- return isMs ? timestamp * 1000 : timestamp;
160
- }
161
-
162
- function getContext(scope, forceTransaction) {
163
- const ctx = getContextForScope(scope);
164
-
165
- if (!forceTransaction) {
166
- return ctx;
167
- }
168
-
169
- // Else we need to "fix" the context to have no parent span
170
- const parentSpan = trace.getSpan(ctx);
171
-
172
- // If there is no parent span, all good, nothing to do!
173
- if (!parentSpan) {
174
- return ctx;
175
- }
176
-
177
- // Else, we need to do two things:
178
- // 1. Unset the parent span from the context, so we'll create a new root span
179
- // 2. Ensure the propagation context is correct, so we'll continue from the parent span
180
- const ctxWithoutSpan = trace.deleteSpan(ctx);
181
-
182
- const { spanId, traceId, traceFlags } = parentSpan.spanContext();
183
- // eslint-disable-next-line no-bitwise
184
- const sampled = Boolean(traceFlags & TraceFlags.SAMPLED);
185
-
186
- const rootSpan = getRootSpan(parentSpan);
187
- const dsc = getDynamicSamplingContextFromSpan(rootSpan);
188
- const dscString = dynamicSamplingContextToSentryBaggageHeader(dsc);
189
-
190
- const traceState = dscString ? new TraceState().set(SENTRY_TRACE_STATE_DSC, dscString) : undefined;
191
-
192
- const spanContext = {
193
- traceId,
194
- spanId,
195
- isRemote: true,
196
- traceFlags: sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,
197
- traceState,
198
- };
199
-
200
- const ctxWithSpanContext = trace.setSpanContext(ctxWithoutSpan, spanContext);
201
-
202
- return ctxWithSpanContext;
203
- }
204
-
205
- function getContextForScope(scope) {
206
- if (scope) {
207
- const ctx = getContextFromScope(scope);
208
- if (ctx) {
209
- return ctx;
210
- }
211
- }
212
-
213
- return context.active();
214
- }
215
-
216
- export { startInactiveSpan, startSpan, startSpanManual, withActiveSpan };
217
- //# sourceMappingURL=trace.js.map
package/esm/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":[],"mappings":";;;;;;;;;;AAwBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,SAAS,CAAI,OAAO,EAA4B,QAAQ,EAAwB;AAChG,EAAE,MAAM,MAAA,GAAS,SAAS,EAAE,CAAA;AAC5B;AACA,EAAE,MAAM,EAAE,IAAK,EAAA,GAAI,OAAO,CAAA;AAC1B;AACA,EAAE,MAAM,SAAA,GAAY,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAA;AACvE,EAAE,MAAM,cAAA,GAAiB,OAAO,CAAC,YAAA,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E,2CAA2C,CAAC,GAAG,CAAC,CAAA;AACpE;AACA,EAAE,MAAM,UAAW,GAAE,SAAU,GAAE,IAAI,UAAU,EAAE,CAAC,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAA,GAAI,SAAS,CAAA;AACpG;AACA,EAAE,MAAM,WAAW,GAAgB;AACnC,IAAI,OAAO;AACX,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,IAAI;AAClB,IAAI,UAAU,EAAE,OAAA,GAAU,UAAU,CAAC,OAAQ,GAAE,UAAU,CAAC,IAAI;AAC9D,IAAI,UAAU;AACd,GAAG,CAAA;AACH;AACA,EAAE,MAAM,kBAAmB,GAAE,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;AAC9E;AACA,EAAE,OAAO,kBAAkB,CAAA;AAC3B,CAAA;AACA;AACA,SAAS,kBAAkB,CAAC,KAAK,EAAmB;AACpD,EAAE,IAAI,KAAK,EAAE;AACb,IAAI,MAAM,GAAI,GAAE,mBAAmB,CAAC,KAAK,CAAC,CAAA;AAC1C,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,OAAO,GAAG,CAAA;AAChB,KAAI;AACJ,GAAE;AACF;AACA,EAAE,OAAO,OAAO,CAAC,MAAM,EAAE,CAAA;AACzB;;;;"}
@@ -1,9 +0,0 @@
1
- import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
2
-
3
- /** Adds an origin to an OTEL Span. */
4
- function addOriginToSpan(span, origin) {
5
- span.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, origin);
6
- }
7
-
8
- export { addOriginToSpan };
9
- //# 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":[],"mappings":";;AAIA;AACO,SAAS,eAAe,CAAC,IAAI,EAAQ,MAAM,EAAoB;AACtE,EAAE,IAAI,CAAC,YAAY,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAA;AAC7D;;;;"}
@@ -1,57 +0,0 @@
1
- import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
2
- import { isString } from '@sentry/utils';
3
-
4
- /**
5
- * Maybe capture a Sentry exception for an OTEL timed event.
6
- * This will check if the event is exception-like and in that case capture it as an exception.
7
- */
8
- function maybeCaptureExceptionForTimedEvent(hub, event, otelSpan) {
9
- if (event.name !== 'exception') {
10
- return;
11
- }
12
-
13
- const attributes = event.attributes;
14
- if (!attributes) {
15
- return;
16
- }
17
-
18
- const message = attributes[SemanticAttributes.EXCEPTION_MESSAGE];
19
-
20
- if (typeof message !== 'string') {
21
- return;
22
- }
23
-
24
- const syntheticError = new Error(message);
25
-
26
- const stack = attributes[SemanticAttributes.EXCEPTION_STACKTRACE];
27
- if (isString(stack)) {
28
- syntheticError.stack = stack;
29
- }
30
-
31
- const type = attributes[SemanticAttributes.EXCEPTION_TYPE];
32
- if (isString(type)) {
33
- syntheticError.name = type;
34
- }
35
-
36
- // eslint-disable-next-line deprecation/deprecation
37
- hub.captureException(syntheticError, {
38
- captureContext: otelSpan
39
- ? {
40
- contexts: {
41
- otel: {
42
- attributes: otelSpan.attributes,
43
- resource: otelSpan.resource.attributes,
44
- },
45
- trace: {
46
- trace_id: otelSpan.spanContext().traceId,
47
- span_id: otelSpan.spanContext().spanId,
48
- parent_span_id: otelSpan.parentSpanId,
49
- },
50
- },
51
- }
52
- : undefined,
53
- });
54
- }
55
-
56
- export { maybeCaptureExceptionForTimedEvent };
57
- //# 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":[],"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;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-
3
- const SCOPE_CONTEXT_MAP = new WeakMap();
4
-
5
- /**
6
- * Try to get the Hub from the given OTEL context.
7
- * This requires a Context Manager that was wrapped with getWrappedContextManager.
8
- */
9
- function getHubFromContext(context) {
10
- return context.getValue(SENTRY_HUB_CONTEXT_KEY) ;
11
- }
12
-
13
- /**
14
- * Set a Hub on an OTEL context..
15
- * This will return a forked context with the Propagation Context set.
16
- */
17
- function setHubOnContext(context, hub) {
18
- return context.setValue(SENTRY_HUB_CONTEXT_KEY, hub);
19
- }
20
-
21
- /**
22
- * Try to get the current scopes from the given OTEL context.
23
- * This requires a Context Manager that was wrapped with getWrappedContextManager.
24
- */
25
- function getScopesFromContext(context) {
26
- return context.getValue(SENTRY_SCOPES_CONTEXT_KEY) ;
27
- }
28
-
29
- /**
30
- * Set the current scopes on an OTEL context.
31
- * This will return a forked context with the Propagation Context set.
32
- */
33
- function setScopesOnContext(context, scopes) {
34
- return context.setValue(SENTRY_SCOPES_CONTEXT_KEY, scopes);
35
- }
36
-
37
- /**
38
- * Set the context on the scope so we can later look it up.
39
- * We need this to get the context from the scope in the `trace` functions.
40
- */
41
- function setContextOnScope(scope, context) {
42
- SCOPE_CONTEXT_MAP.set(scope, context);
43
- }
44
-
45
- /**
46
- * Get the context related to a scope.
47
- * TODO v8: Use this for the `trace` functions.
48
- * */
49
- function getContextFromScope(scope) {
50
- return SCOPE_CONTEXT_MAP.get(scope);
51
- }
52
-
53
- export { getContextFromScope, getHubFromContext, getScopesFromContext, setContextOnScope, setHubOnContext, setScopesOnContext };
54
- //# 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, Scope } from '@sentry/types';\n\nimport { SENTRY_HUB_CONTEXT_KEY, SENTRY_SCOPES_CONTEXT_KEY } from '../constants';\nimport type { CurrentScopes } from '../types';\n\nconst SCOPE_CONTEXT_MAP = new WeakMap<Scope, Context>();\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":[],"mappings":";;AAMA,MAAM,iBAAkB,GAAE,IAAI,OAAO,EAAkB,CAAA;AACvD;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,OAAO,EAA4B;AACrE,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAE,EAAA;AAClD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe,CAAC,OAAO,EAAW,GAAG,EAAgB;AACrE,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;AACtD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,OAAO,EAAsC;AAClF,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAE,EAAA;AACrD,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,kBAAkB,CAAC,OAAO,EAAW,MAAM,EAA0B;AACrF,EAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAA;AAC5D,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAS,OAAO,EAAiB;AACxE,EAAE,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AACvC,CAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,KAAK,EAA8B;AACvE,EAAE,OAAO,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACrC;;;;"}
@@ -1,7 +0,0 @@
1
- /** Convert an OTEL time to seconds */
2
- function convertOtelTimeToSeconds([seconds, nano]) {
3
- return seconds + nano / 1000000000;
4
- }
5
-
6
- export { convertOtelTimeToSeconds };
7
- //# 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,59 +0,0 @@
1
- import { _optionalChain } from '@sentry/utils';
2
- import { TraceFlags } from '@opentelemetry/api';
3
- import { getClient, getDynamicSamplingContextFromClient, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
4
- import { baggageHeaderToDynamicSamplingContext } from '@sentry/utils';
5
- import { SENTRY_TRACE_STATE_DSC } from '../constants.js';
6
- import { spanHasAttributes, spanHasName } from './spanTypes.js';
7
-
8
- /**
9
- * Creates a dynamic sampling context from a span (and client and scope)
10
- *
11
- * @param span the span from which a few values like the root span name and sample rate are extracted.
12
- *
13
- * @returns a dynamic sampling context
14
- */
15
- function getDynamicSamplingContextFromSpan(span) {
16
- const client = getClient();
17
- if (!client) {
18
- return {};
19
- }
20
-
21
- const traceState = span.spanContext().traceState;
22
- const traceStateDsc = _optionalChain([traceState, 'optionalAccess', _ => _.get, 'call', _2 => _2(SENTRY_TRACE_STATE_DSC)]);
23
-
24
- // If the span has a DSC, we want it to take precedence
25
- const dscOnSpan = traceStateDsc ? baggageHeaderToDynamicSamplingContext(traceStateDsc) : undefined;
26
-
27
- if (dscOnSpan) {
28
- return dscOnSpan;
29
- }
30
-
31
- const dsc = getDynamicSamplingContextFromClient(span.spanContext().traceId, client);
32
-
33
- const attributes = spanHasAttributes(span) ? span.attributes : {};
34
-
35
- const sampleRate = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE];
36
- if (sampleRate != null) {
37
- dsc.sample_rate = `${sampleRate}`;
38
- }
39
-
40
- // We don't want to have a transaction name in the DSC if the source is "url" because URLs might contain PII
41
- const source = attributes[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE];
42
- const name = spanHasName(span) ? span.name : '';
43
-
44
- if (source !== 'url' && name) {
45
- dsc.transaction = name;
46
- }
47
-
48
- // TODO: Once we aligned span types, use spanIsSampled() from core instead
49
- // eslint-disable-next-line no-bitwise
50
- const sampled = Boolean(span.spanContext().traceFlags & TraceFlags.SAMPLED);
51
- dsc.sampled = String(sampled);
52
-
53
- client.emit('createDsc', dsc);
54
-
55
- return dsc;
56
- }
57
-
58
- export { getDynamicSamplingContextFromSpan };
59
- //# 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":[],"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,EAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CACA;CACA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;CACA;CACA,EAAA,CAAA,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;CACA,CAAA;AACO,CAAS,CAAA,CAA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{ getSpanParent } from './spanData.js';
3
-
4
- /**
5
- * Returns the currently active span.
6
- */
7
- function getActiveSpan() {
8
- return trace.getActiveSpan();
9
- }
10
-
11
- /**
12
- * Get the root span for the given span.
13
- * The given span may be the root span itself.
14
- */
15
- function getRootSpan(span) {
16
- let parent = span;
17
-
18
- while (getSpanParent(parent)) {
19
- parent = getSpanParent(parent) ;
20
- }
21
-
22
- return parent;
23
- }
24
-
25
- export { getActiveSpan, getRootSpan };
26
- //# 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":[],"mappings":";;;AAKA;AACA;AACA;AACO,SAAS,aAAa,GAAqB;AAClD,EAAE,OAAO,KAAK,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,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE;AAChC,IAAI,MAAO,GAAE,aAAa,CAAC,MAAM,CAAE,EAAA;AACnC,GAAE;AACF;AACA,EAAE,OAAO,MAAM,CAAA;AACf;;;;"}