@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
@@ -1,74 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const spanData = require('./spanData.js');
4
-
5
- /**
6
- * This function runs through a list of OTEL Spans, and wraps them in an `SpanNode`
7
- * where each node holds a reference to their parent node.
8
- */
9
- function groupSpansWithParents(spans) {
10
- const nodeMap = new Map();
11
-
12
- for (const span of spans) {
13
- createOrUpdateSpanNodeAndRefs(nodeMap, span);
14
- }
15
-
16
- return Array.from(nodeMap, function ([_id, spanNode]) {
17
- return spanNode;
18
- });
19
- }
20
-
21
- function createOrUpdateSpanNodeAndRefs(nodeMap, span) {
22
- const parentSpan = spanData.getSpanParent(span);
23
- const parentIsRemote = parentSpan ? !!parentSpan.spanContext().isRemote : false;
24
-
25
- const id = span.spanContext().spanId;
26
-
27
- // If the parentId is the trace parent ID, we pretend it's undefined
28
- // As this means the parent exists somewhere else
29
- const parentId = !parentIsRemote ? span.parentSpanId : undefined;
30
-
31
- if (!parentId) {
32
- createOrUpdateNode(nodeMap, { id, span, children: [] });
33
- return;
34
- }
35
-
36
- // Else make sure to create parent node as well
37
- // Note that the parent may not know it's parent _yet_, this may be updated in a later pass
38
- const parentNode = createOrGetParentNode(nodeMap, parentId);
39
- const node = createOrUpdateNode(nodeMap, { id, span, parentNode, children: [] });
40
- parentNode.children.push(node);
41
- }
42
-
43
- function createOrGetParentNode(nodeMap, id) {
44
- const existing = nodeMap.get(id);
45
-
46
- if (existing) {
47
- return existing;
48
- }
49
-
50
- return createOrUpdateNode(nodeMap, { id, children: [] });
51
- }
52
-
53
- function createOrUpdateNode(nodeMap, spanNode) {
54
- const existing = nodeMap.get(spanNode.id);
55
-
56
- // If span is already set, nothing to do here
57
- if (existing && existing.span) {
58
- return existing;
59
- }
60
-
61
- // If it exists but span is not set yet, we update it
62
- if (existing && !existing.span) {
63
- existing.span = spanNode.span;
64
- existing.parentNode = spanNode.parentNode;
65
- return existing;
66
- }
67
-
68
- // Else, we create a new one...
69
- nodeMap.set(spanNode.id, spanNode);
70
- return spanNode;
71
- }
72
-
73
- exports.groupSpansWithParents = groupSpansWithParents;
74
- //# sourceMappingURL=groupSpansWithParents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"groupSpansWithParents.js","sources":["../../../src/utils/groupSpansWithParents.ts"],"sourcesContent":["import type { ReadableSpan } from '@opentelemetry/sdk-trace-base';\n\nimport { getSpanParent } from './spanData';\n\nexport interface SpanNode {\n id: string;\n span?: ReadableSpan;\n parentNode?: SpanNode | undefined;\n children: SpanNode[];\n}\n\ntype SpanMap = Map<string, SpanNode>;\n\n/**\n * This function runs through a list of OTEL Spans, and wraps them in an `SpanNode`\n * where each node holds a reference to their parent node.\n */\nexport function groupSpansWithParents(spans: ReadableSpan[]): SpanNode[] {\n const nodeMap: SpanMap = new Map<string, SpanNode>();\n\n for (const span of spans) {\n createOrUpdateSpanNodeAndRefs(nodeMap, span);\n }\n\n return Array.from(nodeMap, function ([_id, spanNode]) {\n return spanNode;\n });\n}\n\nfunction createOrUpdateSpanNodeAndRefs(nodeMap: SpanMap, span: ReadableSpan): void {\n const parentSpan = getSpanParent(span);\n const parentIsRemote = parentSpan ? !!parentSpan.spanContext().isRemote : false;\n\n const id = span.spanContext().spanId;\n\n // If the parentId is the trace parent ID, we pretend it's undefined\n // As this means the parent exists somewhere else\n const parentId = !parentIsRemote ? span.parentSpanId : undefined;\n\n if (!parentId) {\n createOrUpdateNode(nodeMap, { id, span, children: [] });\n return;\n }\n\n // Else make sure to create parent node as well\n // Note that the parent may not know it's parent _yet_, this may be updated in a later pass\n const parentNode = createOrGetParentNode(nodeMap, parentId);\n const node = createOrUpdateNode(nodeMap, { id, span, parentNode, children: [] });\n parentNode.children.push(node);\n}\n\nfunction createOrGetParentNode(nodeMap: SpanMap, id: string): SpanNode {\n const existing = nodeMap.get(id);\n\n if (existing) {\n return existing;\n }\n\n return createOrUpdateNode(nodeMap, { id, children: [] });\n}\n\nfunction createOrUpdateNode(nodeMap: SpanMap, spanNode: SpanNode): SpanNode {\n const existing = nodeMap.get(spanNode.id);\n\n // If span is already set, nothing to do here\n if (existing && existing.span) {\n return existing;\n }\n\n // If it exists but span is not set yet, we update it\n if (existing && !existing.span) {\n existing.span = spanNode.span;\n existing.parentNode = spanNode.parentNode;\n return existing;\n }\n\n // Else, we create a new one...\n nodeMap.set(spanNode.id, spanNode);\n return spanNode;\n}\n"],"names":["getSpanParent"],"mappings":";;;;AAaA;AACA;AACA;AACA;AACO,SAAS,qBAAqB,CAAC,KAAK,EAA8B;AACzE,EAAE,MAAM,OAAO,GAAY,IAAI,GAAG,EAAoB,CAAA;AACtD;AACA,EAAE,KAAK,MAAM,IAAK,IAAG,KAAK,EAAE;AAC5B,IAAI,6BAA6B,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAChD,GAAE;AACF;AACA,EAAE,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,EAAE,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AQ,EAAE,EAAC,EAAG,CAAC,CAAA;AAC1D,CAAA;AACA;AACA,SAAS,kBAAkB,CAAC,OAAO,EAAW,QAAQ,EAAsB;AAC5E,EAAE,MAAM,QAAS,GAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAC3C;AACA;AACA,EAAE,IAAI,QAAA,IAAY,QAAQ,CAAC,IAAI,EAAE;AACjC,IAAI,OAAO,QAAQ,CAAA;AACnB,GAAE;AACF;AACA;AACA,EAAE,IAAI,QAAS,IAAG,CAAC,QAAQ,CAAC,IAAI,EAAE;AAClC,IAAI,QAAQ,CAAC,IAAA,GAAO,QAAQ,CAAC,IAAI,CAAA;AACjC,IAAI,QAAQ,CAAC,UAAA,GAAa,QAAQ,CAAC,UAAU,CAAA;AAC7C,IAAI,OAAO,QAAQ,CAAA;AACnB,GAAE;AACF;AACA;AACA,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;AACpC,EAAE,OAAO,QAAQ,CAAA;AACjB;;;;"}
@@ -1,29 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const semanticConventions = require('@opentelemetry/semantic-conventions');
4
- const core = require('@sentry/core');
5
- const spanTypes = require('./spanTypes.js');
6
-
7
- /**
8
- *
9
- * @param otelSpan Checks wheter a given OTEL Span is an http request to sentry.
10
- * @returns boolean
11
- */
12
- function isSentryRequestSpan(span) {
13
- if (!spanTypes.spanHasAttributes(span)) {
14
- return false;
15
- }
16
-
17
- const { attributes } = span;
18
-
19
- const httpUrl = attributes[semanticConventions.SemanticAttributes.HTTP_URL];
20
-
21
- if (!httpUrl) {
22
- return false;
23
- }
24
-
25
- return core.isSentryRequestUrl(httpUrl.toString(), core.getClient());
26
- }
27
-
28
- exports.isSentryRequestSpan = isSentryRequestSpan;
29
- //# sourceMappingURL=isSentryRequest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isSentryRequest.js","sources":["../../../src/utils/isSentryRequest.ts"],"sourcesContent":["import { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport { getClient, isSentryRequestUrl } from '@sentry/core';\n\nimport type { AbstractSpan } from '../types';\nimport { spanHasAttributes } from './spanTypes';\n\n/**\n *\n * @param otelSpan Checks wheter a given OTEL Span is an http request to sentry.\n * @returns boolean\n */\nexport function isSentryRequestSpan(span: AbstractSpan): boolean {\n if (!spanHasAttributes(span)) {\n return false;\n }\n\n const { attributes } = span;\n\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n\n if (!httpUrl) {\n return false;\n }\n\n return isSentryRequestUrl(httpUrl.toString(), getClient());\n}\n"],"names":["spanHasAttributes","SemanticAttributes","isSentryRequestUrl","getClient"],"mappings":";;;;;;AAMA;AACA;AACA;AACA;AACA;AACO,SAAS,mBAAmB,CAAC,IAAI,EAAyB;AACjE,EAAE,IAAI,CAACA,2BAAiB,CAAC,IAAI,CAAC,EAAE;AAChC,IAAI,OAAO,KAAK,CAAA;AAChB,GAAE;AACF;AACA,EAAE,MAAM,EAAE,UAAW,EAAA,GAAI,IAAI,CAAA;AAC7B;AACA,EAAE,MAAM,UAAU,UAAU,CAACC,sCAAkB,CAAC,QAAQ,CAAC,CAAA;AACzD;AACA,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,OAAO,KAAK,CAAA;AAChB,GAAE;AACF;AACA,EAAE,OAAOC,uBAAkB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAEC,cAAS,EAAE,CAAC,CAAA;AAC5D;;;;"}
@@ -1,76 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const api = require('@opentelemetry/api');
4
- const semanticConventions = require('@opentelemetry/semantic-conventions');
5
- const spanTypes = require('./spanTypes.js');
6
-
7
- // canonicalCodesHTTPMap maps some HTTP codes to Sentry's span statuses. See possible mapping in https://develop.sentry.dev/sdk/event-payloads/span/
8
- const canonicalCodesHTTPMap = {
9
- '400': 'failed_precondition',
10
- '401': 'unauthenticated',
11
- '403': 'permission_denied',
12
- '404': 'not_found',
13
- '409': 'aborted',
14
- '429': 'resource_exhausted',
15
- '499': 'cancelled',
16
- '500': 'internal_error',
17
- '501': 'unimplemented',
18
- '503': 'unavailable',
19
- '504': 'deadline_exceeded',
20
- } ;
21
-
22
- // canonicalCodesGrpcMap maps some GRPC codes to Sentry's span statuses. See description in grpc documentation.
23
- const canonicalCodesGrpcMap = {
24
- '1': 'cancelled',
25
- '2': 'unknown_error',
26
- '3': 'invalid_argument',
27
- '4': 'deadline_exceeded',
28
- '5': 'not_found',
29
- '6': 'already_exists',
30
- '7': 'permission_denied',
31
- '8': 'resource_exhausted',
32
- '9': 'failed_precondition',
33
- '10': 'aborted',
34
- '11': 'out_of_range',
35
- '12': 'unimplemented',
36
- '13': 'internal_error',
37
- '14': 'unavailable',
38
- '15': 'data_loss',
39
- '16': 'unauthenticated',
40
- } ;
41
-
42
- /**
43
- * Get a Sentry span status from an otel span.
44
- */
45
- function mapStatus(span) {
46
- const attributes = spanTypes.spanHasAttributes(span) ? span.attributes : {};
47
- const status = spanTypes.spanHasStatus(span) ? span.status : undefined;
48
-
49
- const httpCode = attributes[semanticConventions.SemanticAttributes.HTTP_STATUS_CODE];
50
- const grpcCode = attributes[semanticConventions.SemanticAttributes.RPC_GRPC_STATUS_CODE];
51
-
52
- const code = typeof httpCode === 'string' ? httpCode : typeof httpCode === 'number' ? httpCode.toString() : undefined;
53
- if (code) {
54
- const sentryStatus = canonicalCodesHTTPMap[code];
55
- if (sentryStatus) {
56
- return sentryStatus;
57
- }
58
- }
59
-
60
- if (typeof grpcCode === 'string') {
61
- const sentryStatus = canonicalCodesGrpcMap[grpcCode];
62
- if (sentryStatus) {
63
- return sentryStatus;
64
- }
65
- }
66
-
67
- const statusCode = status && status.code;
68
- if (statusCode === api.SpanStatusCode.OK || statusCode === api.SpanStatusCode.UNSET) {
69
- return 'ok';
70
- }
71
-
72
- return 'unknown_error';
73
- }
74
-
75
- exports.mapStatus = mapStatus;
76
- //# sourceMappingURL=mapStatus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mapStatus.js","sources":["../../../src/utils/mapStatus.ts"],"sourcesContent":["import { SpanStatusCode } from '@opentelemetry/api';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport type { SpanStatusType as SentryStatus } from '@sentry/core';\n\nimport type { AbstractSpan } from '../types';\nimport { spanHasAttributes, spanHasStatus } from './spanTypes';\n\n// canonicalCodesHTTPMap maps some HTTP codes to Sentry's span statuses. See possible mapping in https://develop.sentry.dev/sdk/event-payloads/span/\nconst canonicalCodesHTTPMap: Record<string, SentryStatus> = {\n '400': 'failed_precondition',\n '401': 'unauthenticated',\n '403': 'permission_denied',\n '404': 'not_found',\n '409': 'aborted',\n '429': 'resource_exhausted',\n '499': 'cancelled',\n '500': 'internal_error',\n '501': 'unimplemented',\n '503': 'unavailable',\n '504': 'deadline_exceeded',\n} as const;\n\n// canonicalCodesGrpcMap maps some GRPC codes to Sentry's span statuses. See description in grpc documentation.\nconst canonicalCodesGrpcMap: Record<string, SentryStatus> = {\n '1': 'cancelled',\n '2': 'unknown_error',\n '3': 'invalid_argument',\n '4': 'deadline_exceeded',\n '5': 'not_found',\n '6': 'already_exists',\n '7': 'permission_denied',\n '8': 'resource_exhausted',\n '9': 'failed_precondition',\n '10': 'aborted',\n '11': 'out_of_range',\n '12': 'unimplemented',\n '13': 'internal_error',\n '14': 'unavailable',\n '15': 'data_loss',\n '16': 'unauthenticated',\n} as const;\n\n/**\n * Get a Sentry span status from an otel span.\n */\nexport function mapStatus(span: AbstractSpan): SentryStatus {\n const attributes = spanHasAttributes(span) ? span.attributes : {};\n const status = spanHasStatus(span) ? span.status : undefined;\n\n const httpCode = attributes[SemanticAttributes.HTTP_STATUS_CODE];\n const grpcCode = attributes[SemanticAttributes.RPC_GRPC_STATUS_CODE];\n\n const code = typeof httpCode === 'string' ? httpCode : typeof httpCode === 'number' ? httpCode.toString() : undefined;\n if (code) {\n const sentryStatus = canonicalCodesHTTPMap[code];\n if (sentryStatus) {\n return sentryStatus;\n }\n }\n\n if (typeof grpcCode === 'string') {\n const sentryStatus = canonicalCodesGrpcMap[grpcCode];\n if (sentryStatus) {\n return sentryStatus;\n }\n }\n\n const statusCode = status && status.code;\n if (statusCode === SpanStatusCode.OK || statusCode === SpanStatusCode.UNSET) {\n return 'ok';\n }\n\n return 'unknown_error';\n}\n"],"names":["spanHasAttributes","spanHasStatus","SemanticAttributes","SpanStatusCode"],"mappings":";;;;;;AAOA;AACA,MAAM,qBAAqB,GAAiC;AAC5D,EAAE,KAAK,EAAE,qBAAqB;AAC9B,EAAE,KAAK,EAAE,iBAAiB;AAC1B,EAAE,KAAK,EAAE,mBAAmB;AAC5B,EAAE,KAAK,EAAE,WAAW;AACpB,EAAE,KAAK,EAAE,SAAS;AAClB,EAAE,KAAK,EAAE,oBAAoB;AAC7B,EAAE,KAAK,EAAE,WAAW;AACpB,EAAE,KAAK,EAAE,gBAAgB;AACzB,EAAE,KAAK,EAAE,eAAe;AACxB,EAAE,KAAK,EAAE,aAAa;AACtB,EAAE,KAAK,EAAE,mBAAmB;AAC5B,CAAE,EAAA;AACF;AACA;AACA,MAAM,qBAAqB,GAAiC;AAC5D,EAAE,GAAG,EAAE,WAAW;AAClB,EAAE,GAAG,EAAE,eAAe;AACtB,EAAE,GAAG,EAAE,kBAAkB;AACzB,EAAE,GAAG,EAAE,mBAAmB;AAC1B,EAAE,GAAG,EAAE,WAAW;AAClB,EAAE,GAAG,EAAE,gBAAgB;AACvB,EAAE,GAAG,EAAE,mBAAmB;AAC1B,EAAE,GAAG,EAAE,oBAAoB;AAC3B,EAAE,GAAG,EAAE,qBAAqB;AAC5B,EAAE,IAAI,EAAE,SAAS;AACjB,EAAE,IAAI,EAAE,cAAc;AACtB,EAAE,IAAI,EAAE,eAAe;AACvB,EAAE,IAAI,EAAE,gBAAgB;AACxB,EAAE,IAAI,EAAE,aAAa;AACrB,EA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}
@@ -1,158 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const api = require('@opentelemetry/api');
4
- const semanticConventions = require('@opentelemetry/semantic-conventions');
5
- const utils = require('@sentry/utils');
6
- const getSpanKind = require('./getSpanKind.js');
7
- const spanTypes = require('./spanTypes.js');
8
-
9
- /**
10
- * Extract better op/description from an otel span.
11
- *
12
- * Based on https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/7422ce2a06337f68a59b552b8c5a2ac125d6bae5/exporter/sentryexporter/sentry_exporter.go#L306
13
- */
14
- function parseSpanDescription(span) {
15
- const attributes = spanTypes.spanHasAttributes(span) ? span.attributes : {};
16
- const name = spanTypes.spanHasName(span) ? span.name : '<unknown>';
17
-
18
- // if http.method exists, this is an http request span
19
- const httpMethod = attributes[semanticConventions.SemanticAttributes.HTTP_METHOD];
20
- if (httpMethod) {
21
- return descriptionForHttpMethod({ attributes, name, kind: getSpanKind.getSpanKind(span) }, httpMethod);
22
- }
23
-
24
- // If db.type exists then this is a database call span.
25
- const dbSystem = attributes[semanticConventions.SemanticAttributes.DB_SYSTEM];
26
- if (dbSystem) {
27
- return descriptionForDbSystem({ attributes, name });
28
- }
29
-
30
- // If rpc.service exists then this is a rpc call span.
31
- const rpcService = attributes[semanticConventions.SemanticAttributes.RPC_SERVICE];
32
- if (rpcService) {
33
- return {
34
- op: 'rpc',
35
- description: name,
36
- source: 'route',
37
- };
38
- }
39
-
40
- // If messaging.system exists then this is a messaging system span.
41
- const messagingSystem = attributes[semanticConventions.SemanticAttributes.MESSAGING_SYSTEM];
42
- if (messagingSystem) {
43
- return {
44
- op: 'message',
45
- description: name,
46
- source: 'route',
47
- };
48
- }
49
-
50
- // If faas.trigger exists then this is a function as a service span.
51
- const faasTrigger = attributes[semanticConventions.SemanticAttributes.FAAS_TRIGGER];
52
- if (faasTrigger) {
53
- return { op: faasTrigger.toString(), description: name, source: 'route' };
54
- }
55
-
56
- return { op: undefined, description: name, source: 'custom' };
57
- }
58
-
59
- function descriptionForDbSystem({ attributes, name }) {
60
- // Use DB statement (Ex "SELECT * FROM table") if possible as description.
61
- const statement = attributes[semanticConventions.SemanticAttributes.DB_STATEMENT];
62
-
63
- const description = statement ? statement.toString() : name;
64
-
65
- return { op: 'db', description, source: 'task' };
66
- }
67
-
68
- /** Only exported for tests. */
69
- function descriptionForHttpMethod(
70
- { name, kind, attributes },
71
- httpMethod,
72
- ) {
73
- const opParts = ['http'];
74
-
75
- switch (kind) {
76
- case api.SpanKind.CLIENT:
77
- opParts.push('client');
78
- break;
79
- case api.SpanKind.SERVER:
80
- opParts.push('server');
81
- break;
82
- }
83
-
84
- const { urlPath, url, query, fragment, hasRoute } = getSanitizedUrl(attributes, kind);
85
-
86
- if (!urlPath) {
87
- return { op: opParts.join('.'), description: name, source: 'custom' };
88
- }
89
-
90
- // Ex. description="GET /api/users".
91
- const description = `${httpMethod} ${urlPath}`;
92
-
93
- // If `httpPath` is a root path, then we can categorize the transaction source as route.
94
- const source = hasRoute || urlPath === '/' ? 'route' : 'url';
95
-
96
- const data = {};
97
-
98
- if (url) {
99
- data.url = url;
100
- }
101
- if (query) {
102
- data['http.query'] = query;
103
- }
104
- if (fragment) {
105
- data['http.fragment'] = fragment;
106
- }
107
-
108
- return {
109
- op: opParts.join('.'),
110
- description,
111
- source,
112
- data,
113
- };
114
- }
115
-
116
- /** Exported for tests only */
117
- function getSanitizedUrl(
118
- attributes,
119
- kind,
120
- )
121
-
122
- {
123
- // This is the relative path of the URL, e.g. /sub
124
- const httpTarget = attributes[semanticConventions.SemanticAttributes.HTTP_TARGET];
125
- // This is the full URL, including host & query params etc., e.g. https://example.com/sub?foo=bar
126
- const httpUrl = attributes[semanticConventions.SemanticAttributes.HTTP_URL];
127
- // This is the normalized route name - may not always be available!
128
- const httpRoute = attributes[semanticConventions.SemanticAttributes.HTTP_ROUTE];
129
-
130
- const parsedUrl = typeof httpUrl === 'string' ? utils.parseUrl(httpUrl) : undefined;
131
- const url = parsedUrl ? utils.getSanitizedUrlString(parsedUrl) : undefined;
132
- const query = parsedUrl && parsedUrl.search ? parsedUrl.search : undefined;
133
- const fragment = parsedUrl && parsedUrl.hash ? parsedUrl.hash : undefined;
134
-
135
- if (typeof httpRoute === 'string') {
136
- return { urlPath: httpRoute, url, query, fragment, hasRoute: true };
137
- }
138
-
139
- if (kind === api.SpanKind.SERVER && typeof httpTarget === 'string') {
140
- return { urlPath: utils.stripUrlQueryAndFragment(httpTarget), url, query, fragment, hasRoute: false };
141
- }
142
-
143
- if (parsedUrl) {
144
- return { urlPath: url, url, query, fragment, hasRoute: false };
145
- }
146
-
147
- // fall back to target even for client spans, if no URL is present
148
- if (typeof httpTarget === 'string') {
149
- return { urlPath: utils.stripUrlQueryAndFragment(httpTarget), url, query, fragment, hasRoute: false };
150
- }
151
-
152
- return { urlPath: undefined, url, query, fragment, hasRoute: false };
153
- }
154
-
155
- exports.descriptionForHttpMethod = descriptionForHttpMethod;
156
- exports.getSanitizedUrl = getSanitizedUrl;
157
- exports.parseSpanDescription = parseSpanDescription;
158
- //# sourceMappingURL=parseSpanDescription.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseSpanDescription.js","sources":["../../../src/utils/parseSpanDescription.ts"],"sourcesContent":["import type { AttributeValue, Attributes } from '@opentelemetry/api';\nimport { SpanKind } from '@opentelemetry/api';\nimport { SemanticAttributes } from '@opentelemetry/semantic-conventions';\nimport type { TransactionSource } from '@sentry/types';\nimport { getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment } from '@sentry/utils';\n\nimport type { AbstractSpan } from '../types';\nimport { getSpanKind } from './getSpanKind';\nimport { spanHasAttributes, spanHasName } from './spanTypes';\n\ninterface SpanDescription {\n op: string | undefined;\n description: string;\n source: TransactionSource;\n data?: Record<string, string>;\n}\n\n/**\n * Extract better op/description from an otel span.\n *\n * Based on https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/7422ce2a06337f68a59b552b8c5a2ac125d6bae5/exporter/sentryexporter/sentry_exporter.go#L306\n */\nexport function parseSpanDescription(span: AbstractSpan): SpanDescription {\n const attributes = spanHasAttributes(span) ? span.attributes : {};\n const name = spanHasName(span) ? span.name : '<unknown>';\n\n // if http.method exists, this is an http request span\n const httpMethod = attributes[SemanticAttributes.HTTP_METHOD];\n if (httpMethod) {\n return descriptionForHttpMethod({ attributes, name, kind: getSpanKind(span) }, httpMethod);\n }\n\n // If db.type exists then this is a database call span.\n const dbSystem = attributes[SemanticAttributes.DB_SYSTEM];\n if (dbSystem) {\n return descriptionForDbSystem({ attributes, name });\n }\n\n // If rpc.service exists then this is a rpc call span.\n const rpcService = attributes[SemanticAttributes.RPC_SERVICE];\n if (rpcService) {\n return {\n op: 'rpc',\n description: name,\n source: 'route',\n };\n }\n\n // If messaging.system exists then this is a messaging system span.\n const messagingSystem = attributes[SemanticAttributes.MESSAGING_SYSTEM];\n if (messagingSystem) {\n return {\n op: 'message',\n description: name,\n source: 'route',\n };\n }\n\n // If faas.trigger exists then this is a function as a service span.\n const faasTrigger = attributes[SemanticAttributes.FAAS_TRIGGER];\n if (faasTrigger) {\n return { op: faasTrigger.toString(), description: name, source: 'route' };\n }\n\n return { op: undefined, description: name, source: 'custom' };\n}\n\nfunction descriptionForDbSystem({ attributes, name }: { attributes: Attributes; name: string }): SpanDescription {\n // Use DB statement (Ex \"SELECT * FROM table\") if possible as description.\n const statement = attributes[SemanticAttributes.DB_STATEMENT];\n\n const description = statement ? statement.toString() : name;\n\n return { op: 'db', description, source: 'task' };\n}\n\n/** Only exported for tests. */\nexport function descriptionForHttpMethod(\n { name, kind, attributes }: { name: string; attributes: Attributes; kind: SpanKind },\n httpMethod: AttributeValue,\n): SpanDescription {\n const opParts = ['http'];\n\n switch (kind) {\n case SpanKind.CLIENT:\n opParts.push('client');\n break;\n case SpanKind.SERVER:\n opParts.push('server');\n break;\n }\n\n const { urlPath, url, query, fragment, hasRoute } = getSanitizedUrl(attributes, kind);\n\n if (!urlPath) {\n return { op: opParts.join('.'), description: name, source: 'custom' };\n }\n\n // Ex. description=\"GET /api/users\".\n const description = `${httpMethod} ${urlPath}`;\n\n // If `httpPath` is a root path, then we can categorize the transaction source as route.\n const source: TransactionSource = hasRoute || urlPath === '/' ? 'route' : 'url';\n\n const data: Record<string, string> = {};\n\n if (url) {\n data.url = url;\n }\n if (query) {\n data['http.query'] = query;\n }\n if (fragment) {\n data['http.fragment'] = fragment;\n }\n\n return {\n op: opParts.join('.'),\n description,\n source,\n data,\n };\n}\n\n/** Exported for tests only */\nexport function getSanitizedUrl(\n attributes: Attributes,\n kind: SpanKind,\n): {\n url: string | undefined;\n urlPath: string | undefined;\n query: string | undefined;\n fragment: string | undefined;\n hasRoute: boolean;\n} {\n // This is the relative path of the URL, e.g. /sub\n const httpTarget = attributes[SemanticAttributes.HTTP_TARGET];\n // This is the full URL, including host & query params etc., e.g. https://example.com/sub?foo=bar\n const httpUrl = attributes[SemanticAttributes.HTTP_URL];\n // This is the normalized route name - may not always be available!\n const httpRoute = attributes[SemanticAttributes.HTTP_ROUTE];\n\n const parsedUrl = typeof httpUrl === 'string' ? parseUrl(httpUrl) : undefined;\n const url = parsedUrl ? getSanitizedUrlString(parsedUrl) : undefined;\n const query = parsedUrl && parsedUrl.search ? parsedUrl.search : undefined;\n const fragment = parsedUrl && parsedUrl.hash ? parsedUrl.hash : undefined;\n\n if (typeof httpRoute === 'string') {\n return { urlPath: httpRoute, url, query, fragment, hasRoute: true };\n }\n\n if (kind === SpanKind.SERVER && typeof httpTarget === 'string') {\n return { urlPath: stripUrlQueryAndFragment(httpTarget), url, query, fragment, hasRoute: false };\n }\n\n if (parsedUrl) {\n return { urlPath: url, url, query, fragment, hasRoute: false };\n }\n\n // fall back to target even for client spans, if no URL is present\n if (typeof httpTarget === 'string') {\n return { urlPath: stripUrlQueryAndFragment(httpTarget), url, query, fragment, hasRoute: false };\n }\n\n return { urlPath: undefined, url, query, fragment, hasRoute: false };\n}\n"],"names":["spanHasAttributes","spanHasName","SemanticAttributes","getSpanKind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,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA;AACA;;;;;;"}
@@ -1,72 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- // We store the parent span, scopes & metadata in separate weakmaps, so we can access them for a given span
4
- // This way we can enhance the data that an OTEL Span natively gives us
5
- // and since we are using weakmaps, we do not need to clean up after ourselves
6
- const SpanScopes = new WeakMap
7
-
8
- ();
9
- const SpanHub = new WeakMap();
10
- const SpanParent = new WeakMap();
11
- const SpanMetadata = new WeakMap();
12
-
13
- /** Set the Sentry hub on an OTEL span. */
14
- function setSpanHub(span, hub) {
15
- SpanHub.set(span, hub);
16
- }
17
-
18
- /** Get the Sentry hub of an OTEL span. */
19
- function getSpanHub(span) {
20
- return SpanHub.get(span);
21
- }
22
-
23
- /** Set the parent OTEL span on an OTEL span. */
24
- function setSpanParent(span, parentSpan) {
25
- SpanParent.set(span, parentSpan);
26
- }
27
-
28
- /** Get the parent OTEL span of an OTEL span. */
29
- function getSpanParent(span) {
30
- return SpanParent.get(span);
31
- }
32
-
33
- /** Set metadata for an OTEL span. */
34
- function setSpanMetadata(span, metadata) {
35
- SpanMetadata.set(span, metadata);
36
- }
37
-
38
- /** Get metadata for an OTEL span. */
39
- function getSpanMetadata(span) {
40
- return SpanMetadata.get(span);
41
- }
42
-
43
- /**
44
- * Set the Sentry scope to be used for finishing a given OTEL span.
45
- * This is different from `setCapturedScopesOnSpan`, as that works on _sentry_ spans,
46
- * while here we are basically "caching" this on the otel spans.
47
- */
48
- function setSpanScopes(
49
- span,
50
- scopes
51
-
52
- ,
53
- ) {
54
- SpanScopes.set(span, scopes);
55
- }
56
-
57
- /** Get the Sentry scopes to use for finishing an OTEL span. */
58
- function getSpanScopes(span)
59
-
60
- {
61
- return SpanScopes.get(span);
62
- }
63
-
64
- exports.getSpanHub = getSpanHub;
65
- exports.getSpanMetadata = getSpanMetadata;
66
- exports.getSpanParent = getSpanParent;
67
- exports.getSpanScopes = getSpanScopes;
68
- exports.setSpanHub = setSpanHub;
69
- exports.setSpanMetadata = setSpanMetadata;
70
- exports.setSpanParent = setSpanParent;
71
- exports.setSpanScopes = setSpanScopes;
72
- //# sourceMappingURL=spanData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanData.js","sources":["../../../src/utils/spanData.ts"],"sourcesContent":["import type { Span } from '@opentelemetry/api';\nimport type { Hub, Scope, TransactionMetadata } from '@sentry/types';\n\nimport type { AbstractSpan } from '../types';\n\n// We store the parent span, scopes & metadata in separate weakmaps, so we can access them for a given span\n// This way we can enhance the data that an OTEL Span natively gives us\n// and since we are using weakmaps, we do not need to clean up after ourselves\nconst SpanScopes = new WeakMap<\n AbstractSpan,\n {\n scope: Scope;\n isolationScope: Scope;\n }\n>();\nconst SpanHub = new WeakMap<AbstractSpan, Hub>();\nconst SpanParent = new WeakMap<AbstractSpan, Span>();\nconst SpanMetadata = new WeakMap<AbstractSpan, Partial<TransactionMetadata>>();\n\n/** Set the Sentry hub on an OTEL span. */\nexport function setSpanHub(span: AbstractSpan, hub: Hub): void {\n SpanHub.set(span, hub);\n}\n\n/** Get the Sentry hub of an OTEL span. */\nexport function getSpanHub(span: AbstractSpan): Hub | undefined {\n return SpanHub.get(span);\n}\n\n/** Set the parent OTEL span on an OTEL span. */\nexport function setSpanParent(span: AbstractSpan, parentSpan: Span): void {\n SpanParent.set(span, parentSpan);\n}\n\n/** Get the parent OTEL span of an OTEL span. */\nexport function getSpanParent(span: AbstractSpan): Span | undefined {\n return SpanParent.get(span);\n}\n\n/** Set metadata for an OTEL span. */\nexport function setSpanMetadata(span: AbstractSpan, metadata: Partial<TransactionMetadata>): void {\n SpanMetadata.set(span, metadata);\n}\n\n/** Get metadata for an OTEL span. */\nexport function getSpanMetadata(span: AbstractSpan): Partial<TransactionMetadata> | undefined {\n return SpanMetadata.get(span);\n}\n\n/**\n * Set the Sentry scope to be used for finishing a given OTEL span.\n * This is different from `setCapturedScopesOnSpan`, as that works on _sentry_ spans,\n * while here we are basically \"caching\" this on the otel spans.\n */\nexport function setSpanScopes(\n span: AbstractSpan,\n scopes: {\n scope: Scope;\n isolationScope: Scope;\n },\n): void {\n SpanScopes.set(span, scopes);\n}\n\n/** Get the Sentry scopes to use for finishing an OTEL span. */\nexport function getSpanScopes(span: AbstractSpan):\n | {\n scope: Scope;\n isolationScope: Scope;\n }\n | undefined {\n return SpanScopes.get(span);\n}\n"],"names":[],"mappings":";;AAKA;AACA;AACA;AACA,MAAM,UAAA,GAAa,IAAI,OAAO;;AAM9B,EAAG,CAAA;AACH,MAAM,OAAQ,GAAE,IAAI,OAAO,EAAqB,CAAA;AAChD,MAAM,UAAW,GAAE,IAAI,OAAO,EAAsB,CAAA;AACpD,MAAM,YAAa,GAAE,IAAI,OAAO,EAA8C,CAAA;AAC9E;AACA;AACO,SAAS,UAAU,CAAC,IAAI,EAAgB,GAAG,EAAa;AAC/D,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AACxB,CAAA;AACA;AACA;AACO,SAAS,UAAU,CAAC,IAAI,EAAiC;AAChE,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI,EAAgB,UAAU,EAAc;AAC1E,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;AAClC,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI,EAAkC;AACpE,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7B,CAAA;AACA;AACA;AACO,SAAS,eAAe,CAAC,IAAI,EAAgB,QAAQ,EAAsC;AAClG,EAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAClC,CAAA;AACA;AACA;AACO,SAAS,eAAe,CAAC,IAAI,EAA0D;AAC9F,EAAE,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa;AAC7B,EAAE,IAAI;AACN,EAAE,MAAM;;AAGN;AACF,EAAQ;AACR,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAC9B,CAAA;AACA;AACA;AACO,SAAS,aAAa,CAAC,IAAI;;AAKhC,CAAY;AACd,EAAE,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC7B;;;;;;;;;;;"}
@@ -1,77 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- /**
4
- * Check if a given span has attributes.
5
- * This is necessary because the base `Span` type does not have attributes,
6
- * so in places where we are passed a generic span, we need to check if we want to access them.
7
- */
8
- function spanHasAttributes(
9
- span,
10
- ) {
11
- const castSpan = span ;
12
- return !!castSpan.attributes && typeof castSpan.attributes === 'object';
13
- }
14
-
15
- /**
16
- * Check if a given span has a kind.
17
- * This is necessary because the base `Span` type does not have a kind,
18
- * so in places where we are passed a generic span, we need to check if we want to access it.
19
- */
20
- function spanHasKind(span) {
21
- const castSpan = span ;
22
- return !!castSpan.kind;
23
- }
24
-
25
- /**
26
- * Check if a given span has a status.
27
- * This is necessary because the base `Span` type does not have a status,
28
- * so in places where we are passed a generic span, we need to check if we want to access it.
29
- */
30
- function spanHasStatus(
31
- span,
32
- ) {
33
- const castSpan = span ;
34
- return !!castSpan.status;
35
- }
36
-
37
- /**
38
- * Check if a given span has a name.
39
- * This is necessary because the base `Span` type does not have a name,
40
- * so in places where we are passed a generic span, we need to check if we want to access it.
41
- */
42
- function spanHasName(span) {
43
- const castSpan = span ;
44
- return !!castSpan.name;
45
- }
46
-
47
- /**
48
- * Check if a given span has a kind.
49
- * This is necessary because the base `Span` type does not have a kind,
50
- * so in places where we are passed a generic span, we need to check if we want to access it.
51
- */
52
- function spanHasParentId(
53
- span,
54
- ) {
55
- const castSpan = span ;
56
- return !!castSpan.parentSpanId;
57
- }
58
-
59
- /**
60
- * Check if a given span has events.
61
- * This is necessary because the base `Span` type does not have events,
62
- * so in places where we are passed a generic span, we need to check if we want to access it.
63
- */
64
- function spanHasEvents(
65
- span,
66
- ) {
67
- const castSpan = span ;
68
- return Array.isArray(castSpan.events);
69
- }
70
-
71
- exports.spanHasAttributes = spanHasAttributes;
72
- exports.spanHasEvents = spanHasEvents;
73
- exports.spanHasKind = spanHasKind;
74
- exports.spanHasName = spanHasName;
75
- exports.spanHasParentId = spanHasParentId;
76
- exports.spanHasStatus = spanHasStatus;
77
- //# sourceMappingURL=spanTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanTypes.js","sources":["../../../src/utils/spanTypes.ts"],"sourcesContent":["import type { SpanKind, SpanStatus } from '@opentelemetry/api';\nimport type { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';\n\nimport type { AbstractSpan } from '../types';\n\n/**\n * Check if a given span has attributes.\n * This is necessary because the base `Span` type does not have attributes,\n * so in places where we are passed a generic span, we need to check if we want to access them.\n */\nexport function spanHasAttributes<SpanType extends AbstractSpan>(\n span: SpanType,\n): span is SpanType & { attributes: ReadableSpan['attributes'] } {\n const castSpan = span as ReadableSpan;\n return !!castSpan.attributes && typeof castSpan.attributes === 'object';\n}\n\n/**\n * Check if a given span has a kind.\n * This is necessary because the base `Span` type does not have a kind,\n * so in places where we are passed a generic span, we need to check if we want to access it.\n */\nexport function spanHasKind<SpanType extends AbstractSpan>(span: SpanType): span is SpanType & { kind: SpanKind } {\n const castSpan = span as ReadableSpan;\n return !!castSpan.kind;\n}\n\n/**\n * Check if a given span has a status.\n * This is necessary because the base `Span` type does not have a status,\n * so in places where we are passed a generic span, we need to check if we want to access it.\n */\nexport function spanHasStatus<SpanType extends AbstractSpan>(\n span: SpanType,\n): span is SpanType & { status: SpanStatus } {\n const castSpan = span as ReadableSpan;\n return !!castSpan.status;\n}\n\n/**\n * Check if a given span has a name.\n * This is necessary because the base `Span` type does not have a name,\n * so in places where we are passed a generic span, we need to check if we want to access it.\n */\nexport function spanHasName<SpanType extends AbstractSpan>(span: SpanType): span is SpanType & { name: string } {\n const castSpan = span as ReadableSpan;\n return !!castSpan.name;\n}\n\n/**\n * Check if a given span has a kind.\n * This is necessary because the base `Span` type does not have a kind,\n * so in places where we are passed a generic span, we need to check if we want to access it.\n */\nexport function spanHasParentId<SpanType extends AbstractSpan>(\n span: SpanType,\n): span is SpanType & { parentSpanId: string } {\n const castSpan = span as ReadableSpan;\n return !!castSpan.parentSpanId;\n}\n\n/**\n * Check if a given span has events.\n * This is necessary because the base `Span` type does not have events,\n * so in places where we are passed a generic span, we need to check if we want to access it.\n */\nexport function spanHasEvents<SpanType extends AbstractSpan>(\n span: SpanType,\n): span is SpanType & { events: TimedEvent[] } {\n const castSpan = span as ReadableSpan;\n return Array.isArray(castSpan.events);\n}\n"],"names":[],"mappings":";;AAKA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB;AACjC,EAAE,IAAI;AACN,EAAiE;AACjE,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAA,IAAc,OAAO,QAAQ,CAAC,UAAW,KAAI,QAAQ,CAAA;AACzE,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAgC,IAAI,EAAmD;AAClH,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAA;AACxB,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa;AAC7B,EAAE,IAAI;AACN,EAA6C;AAC7C,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAA;AAC1B,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAgC,IAAI,EAAiD;AAChH,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAA;AACxB,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,eAAe;AAC/B,EAAE,IAAI;AACN,EAA+C;AAC/C,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAA;AAChC,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,aAAa;AAC7B,EAAE,IAAI;AACN,EAA+C;AAC/C,EAAE,MAAM,QAAS,GAAE,IAAK,EAAA;AACxB,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACvC;;;;;;;;;"}