@sentry/core 10.39.0-alpha.0 → 10.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/build/cjs/attributes.js.map +1 -1
  2. package/build/cjs/client.js +7 -13
  3. package/build/cjs/client.js.map +1 -1
  4. package/build/cjs/envelope.js +7 -41
  5. package/build/cjs/envelope.js.map +1 -1
  6. package/build/cjs/exports.js +4 -2
  7. package/build/cjs/exports.js.map +1 -1
  8. package/build/cjs/fetch.js +8 -4
  9. package/build/cjs/fetch.js.map +1 -1
  10. package/build/cjs/index.js +3 -48
  11. package/build/cjs/index.js.map +1 -1
  12. package/build/cjs/integration.js +0 -12
  13. package/build/cjs/integration.js.map +1 -1
  14. package/build/cjs/integrations/eventFilters.js +1 -1
  15. package/build/cjs/integrations/eventFilters.js.map +1 -1
  16. package/build/cjs/integrations/requestdata.js +6 -72
  17. package/build/cjs/integrations/requestdata.js.map +1 -1
  18. package/build/cjs/semanticAttributes.js +0 -84
  19. package/build/cjs/semanticAttributes.js.map +1 -1
  20. package/build/cjs/tracing/langgraph/index.js +1 -1
  21. package/build/cjs/tracing/langgraph/index.js.map +1 -1
  22. package/build/cjs/tracing/sentrySpan.js +0 -32
  23. package/build/cjs/tracing/sentrySpan.js.map +1 -1
  24. package/build/cjs/tracing/trace.js +0 -1
  25. package/build/cjs/tracing/trace.js.map +1 -1
  26. package/build/cjs/tracing/vercel-ai/index.js +0 -1
  27. package/build/cjs/tracing/vercel-ai/index.js.map +1 -1
  28. package/build/cjs/utils/featureFlags.js +0 -1
  29. package/build/cjs/utils/featureFlags.js.map +1 -1
  30. package/build/cjs/utils/misc.js +7 -0
  31. package/build/cjs/utils/misc.js.map +1 -1
  32. package/build/cjs/utils/node-stack-trace.js +11 -2
  33. package/build/cjs/utils/node-stack-trace.js.map +1 -1
  34. package/build/cjs/utils/scopeData.js +0 -4
  35. package/build/cjs/utils/scopeData.js.map +1 -1
  36. package/build/cjs/utils/should-ignore-span.js +9 -31
  37. package/build/cjs/utils/should-ignore-span.js.map +1 -1
  38. package/build/cjs/utils/spanUtils.js +2 -90
  39. package/build/cjs/utils/spanUtils.js.map +1 -1
  40. package/build/cjs/utils/tunnel.js +74 -0
  41. package/build/cjs/utils/tunnel.js.map +1 -0
  42. package/build/cjs/utils/version.js +1 -1
  43. package/build/cjs/utils/version.js.map +1 -1
  44. package/build/cjs/utils/worldwide.js.map +1 -1
  45. package/build/esm/attributes.js.map +1 -1
  46. package/build/esm/client.js +3 -9
  47. package/build/esm/client.js.map +1 -1
  48. package/build/esm/envelope.js +8 -41
  49. package/build/esm/envelope.js.map +1 -1
  50. package/build/esm/exports.js +4 -2
  51. package/build/esm/exports.js.map +1 -1
  52. package/build/esm/fetch.js +8 -4
  53. package/build/esm/fetch.js.map +1 -1
  54. package/build/esm/index.js +5 -11
  55. package/build/esm/index.js.map +1 -1
  56. package/build/esm/integration.js +1 -12
  57. package/build/esm/integration.js.map +1 -1
  58. package/build/esm/integrations/eventFilters.js +1 -1
  59. package/build/esm/integrations/eventFilters.js.map +1 -1
  60. package/build/esm/integrations/requestdata.js +6 -72
  61. package/build/esm/integrations/requestdata.js.map +1 -1
  62. package/build/esm/package.json +1 -1
  63. package/build/esm/semanticAttributes.js +1 -57
  64. package/build/esm/semanticAttributes.js.map +1 -1
  65. package/build/esm/tracing/langgraph/index.js +1 -1
  66. package/build/esm/tracing/langgraph/index.js.map +1 -1
  67. package/build/esm/tracing/sentrySpan.js +1 -33
  68. package/build/esm/tracing/sentrySpan.js.map +1 -1
  69. package/build/esm/tracing/trace.js +0 -1
  70. package/build/esm/tracing/trace.js.map +1 -1
  71. package/build/esm/tracing/vercel-ai/index.js +0 -1
  72. package/build/esm/tracing/vercel-ai/index.js.map +1 -1
  73. package/build/esm/utils/featureFlags.js +0 -1
  74. package/build/esm/utils/featureFlags.js.map +1 -1
  75. package/build/esm/utils/misc.js +7 -1
  76. package/build/esm/utils/misc.js.map +1 -1
  77. package/build/esm/utils/node-stack-trace.js +11 -2
  78. package/build/esm/utils/node-stack-trace.js.map +1 -1
  79. package/build/esm/utils/scopeData.js +0 -4
  80. package/build/esm/utils/scopeData.js.map +1 -1
  81. package/build/esm/utils/should-ignore-span.js +9 -31
  82. package/build/esm/utils/should-ignore-span.js.map +1 -1
  83. package/build/esm/utils/spanUtils.js +3 -87
  84. package/build/esm/utils/spanUtils.js.map +1 -1
  85. package/build/esm/utils/tunnel.js +72 -0
  86. package/build/esm/utils/tunnel.js.map +1 -0
  87. package/build/esm/utils/version.js +1 -1
  88. package/build/esm/utils/version.js.map +1 -1
  89. package/build/esm/utils/worldwide.js.map +1 -1
  90. package/build/types/attributes.d.ts +1 -1
  91. package/build/types/attributes.d.ts.map +1 -1
  92. package/build/types/client.d.ts +2 -40
  93. package/build/types/client.d.ts.map +1 -1
  94. package/build/types/envelope.d.ts +1 -6
  95. package/build/types/envelope.d.ts.map +1 -1
  96. package/build/types/exports.d.ts.map +1 -1
  97. package/build/types/fetch.d.ts.map +1 -1
  98. package/build/types/index.d.ts +7 -12
  99. package/build/types/index.d.ts.map +1 -1
  100. package/build/types/integration.d.ts +0 -4
  101. package/build/types/integration.d.ts.map +1 -1
  102. package/build/types/integrations/requestdata.d.ts.map +1 -1
  103. package/build/types/semanticAttributes.d.ts +0 -38
  104. package/build/types/semanticAttributes.d.ts.map +1 -1
  105. package/build/types/tracing/sentrySpan.d.ts +1 -10
  106. package/build/types/tracing/sentrySpan.d.ts.map +1 -1
  107. package/build/types/tracing/vercel-ai/index.d.ts.map +1 -1
  108. package/build/types/types-hoist/envelope.d.ts +2 -22
  109. package/build/types/types-hoist/envelope.d.ts.map +1 -1
  110. package/build/types/types-hoist/integration.d.ts +0 -7
  111. package/build/types/types-hoist/integration.d.ts.map +1 -1
  112. package/build/types/types-hoist/link.d.ts +2 -2
  113. package/build/types/types-hoist/link.d.ts.map +1 -1
  114. package/build/types/types-hoist/options.d.ts +2 -18
  115. package/build/types/types-hoist/options.d.ts.map +1 -1
  116. package/build/types/types-hoist/span.d.ts +0 -27
  117. package/build/types/types-hoist/span.d.ts.map +1 -1
  118. package/build/types/utils/featureFlags.d.ts.map +1 -1
  119. package/build/types/utils/misc.d.ts +7 -0
  120. package/build/types/utils/misc.d.ts.map +1 -1
  121. package/build/types/utils/node-stack-trace.d.ts.map +1 -1
  122. package/build/types/utils/scopeData.d.ts.map +1 -1
  123. package/build/types/utils/should-ignore-span.d.ts +3 -3
  124. package/build/types/utils/should-ignore-span.d.ts.map +1 -1
  125. package/build/types/utils/spanUtils.d.ts +2 -22
  126. package/build/types/utils/spanUtils.d.ts.map +1 -1
  127. package/build/types/utils/tunnel.d.ts +16 -0
  128. package/build/types/utils/tunnel.d.ts.map +1 -0
  129. package/build/types/utils/worldwide.d.ts +0 -2
  130. package/build/types/utils/worldwide.d.ts.map +1 -1
  131. package/build/types-ts3.8/attributes.d.ts +1 -1
  132. package/build/types-ts3.8/client.d.ts +2 -40
  133. package/build/types-ts3.8/envelope.d.ts +1 -6
  134. package/build/types-ts3.8/index.d.ts +7 -12
  135. package/build/types-ts3.8/integration.d.ts +0 -4
  136. package/build/types-ts3.8/semanticAttributes.d.ts +0 -38
  137. package/build/types-ts3.8/tracing/sentrySpan.d.ts +1 -10
  138. package/build/types-ts3.8/types-hoist/envelope.d.ts +2 -22
  139. package/build/types-ts3.8/types-hoist/integration.d.ts +0 -7
  140. package/build/types-ts3.8/types-hoist/link.d.ts +2 -2
  141. package/build/types-ts3.8/types-hoist/options.d.ts +2 -18
  142. package/build/types-ts3.8/types-hoist/span.d.ts +0 -27
  143. package/build/types-ts3.8/utils/misc.d.ts +7 -0
  144. package/build/types-ts3.8/utils/should-ignore-span.d.ts +3 -3
  145. package/build/types-ts3.8/utils/spanUtils.d.ts +2 -22
  146. package/build/types-ts3.8/utils/tunnel.d.ts +16 -0
  147. package/build/types-ts3.8/utils/worldwide.d.ts +0 -2
  148. package/package.json +2 -3
  149. package/build/cjs/integrations/spanStreaming.js +0 -54
  150. package/build/cjs/integrations/spanStreaming.js.map +0 -1
  151. package/build/cjs/spans/captureSpan.js +0 -104
  152. package/build/cjs/spans/captureSpan.js.map +0 -1
  153. package/build/cjs/spans/spanBuffer.js +0 -121
  154. package/build/cjs/spans/spanBuffer.js.map +0 -1
  155. package/build/cjs/spans/spanFirstUtils.js +0 -186
  156. package/build/cjs/spans/spanFirstUtils.js.map +0 -1
  157. package/build/cjs/utils/beforeSendSpan.js +0 -36
  158. package/build/cjs/utils/beforeSendSpan.js.map +0 -1
  159. package/build/cjs/utils/hasSpanStreamingEnabled.js +0 -21
  160. package/build/cjs/utils/hasSpanStreamingEnabled.js.map +0 -1
  161. package/build/esm/integrations/spanStreaming.js +0 -52
  162. package/build/esm/integrations/spanStreaming.js.map +0 -1
  163. package/build/esm/spans/captureSpan.js +0 -102
  164. package/build/esm/spans/captureSpan.js.map +0 -1
  165. package/build/esm/spans/spanBuffer.js +0 -119
  166. package/build/esm/spans/spanBuffer.js.map +0 -1
  167. package/build/esm/spans/spanFirstUtils.js +0 -182
  168. package/build/esm/spans/spanFirstUtils.js.map +0 -1
  169. package/build/esm/utils/beforeSendSpan.js +0 -33
  170. package/build/esm/utils/beforeSendSpan.js.map +0 -1
  171. package/build/esm/utils/hasSpanStreamingEnabled.js +0 -19
  172. package/build/esm/utils/hasSpanStreamingEnabled.js.map +0 -1
  173. package/build/types/integrations/spanStreaming.d.ts +0 -11
  174. package/build/types/integrations/spanStreaming.d.ts.map +0 -1
  175. package/build/types/spans/captureSpan.d.ts +0 -10
  176. package/build/types/spans/captureSpan.d.ts.map +0 -1
  177. package/build/types/spans/spanBuffer.d.ts +0 -35
  178. package/build/types/spans/spanBuffer.d.ts.map +0 -1
  179. package/build/types/spans/spanFirstUtils.d.ts +0 -20
  180. package/build/types/spans/spanFirstUtils.d.ts.map +0 -1
  181. package/build/types/types-hoist/attributes.d.ts +0 -19
  182. package/build/types/types-hoist/attributes.d.ts.map +0 -1
  183. package/build/types/utils/beforeSendSpan.d.ts +0 -22
  184. package/build/types/utils/beforeSendSpan.d.ts.map +0 -1
  185. package/build/types/utils/hasSpanStreamingEnabled.d.ts +0 -9
  186. package/build/types/utils/hasSpanStreamingEnabled.d.ts.map +0 -1
  187. package/build/types-ts3.8/integrations/spanStreaming.d.ts +0 -11
  188. package/build/types-ts3.8/spans/captureSpan.d.ts +0 -10
  189. package/build/types-ts3.8/spans/spanBuffer.d.ts +0 -35
  190. package/build/types-ts3.8/spans/spanFirstUtils.d.ts +0 -20
  191. package/build/types-ts3.8/types-hoist/attributes.d.ts +0 -19
  192. package/build/types-ts3.8/utils/beforeSendSpan.d.ts +0 -22
  193. package/build/types-ts3.8/utils/hasSpanStreamingEnabled.d.ts +0 -9
@@ -1,186 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const attributes = require('../attributes.js');
4
- const is = require('../utils/is.js');
5
- const spanUtils = require('../utils/spanUtils.js');
6
-
7
- /**
8
- * Only set a span JSON attribute if it is not already set.
9
- * This is used to safely set attributes on JSON objects without mutating already-ended span instances.
10
- */
11
- function safeSetSpanJSONAttributes(
12
- spanJSON,
13
- newAttributes,
14
- ) {
15
- if (!spanJSON.attributes) {
16
- spanJSON.attributes = {};
17
- }
18
-
19
- const originalAttributes = spanJSON.attributes;
20
-
21
- Object.keys(newAttributes).forEach(key => {
22
- if (!originalAttributes?.[key]) {
23
- setAttributeOnSpanJSONWithMaybeUnit(
24
- // type-casting here because we ensured above that the attributes object exists
25
- spanJSON ,
26
- key,
27
- newAttributes[key],
28
- );
29
- }
30
- });
31
- }
32
-
33
- /**
34
- * Apply a user-provided beforeSendSpan callback to a span JSON.
35
- */
36
- function applyBeforeSendSpanCallback(
37
- span,
38
- beforeSendSpan,
39
- ) {
40
- const modifedSpan = beforeSendSpan(span);
41
- if (!modifedSpan) {
42
- spanUtils.showSpanDropWarning();
43
- return span;
44
- }
45
- return modifedSpan;
46
- }
47
-
48
- function setAttributeOnSpanJSONWithMaybeUnit(
49
- spanJSON,
50
- attributeKey,
51
- attributeValue,
52
- ) {
53
- const { value, unit } = attributes.isAttributeObject(attributeValue)
54
- ? attributeValue
55
- : { value: attributeValue, unit: undefined };
56
- const typedAttributeValue = attributes.attributeValueToTypedAttributeValue(value);
57
-
58
- if (typedAttributeValue && isSupportedSerializableType(value)) {
59
- spanJSON.attributes[attributeKey] = typedAttributeValue;
60
- if (unit) {
61
- spanJSON.attributes[attributeKey].unit = unit;
62
- }
63
- }
64
- }
65
-
66
- function isSupportedSerializableType(value) {
67
- return ['string', 'number', 'boolean'].includes(typeof value) || Array.isArray(value);
68
- }
69
-
70
- // map of attributes->context keys for those attributes that don't correspond 1:1 to the context key
71
- const explicitAttributeToContextMapping = {
72
- 'os.build_id': 'os.build',
73
- 'app.name': 'app.app_name',
74
- 'app.identifier': 'app.app_identifier',
75
- 'app.version': 'app.app_version',
76
- 'app.memory': 'app.app_memory',
77
- 'app.start_time': 'app.app_start_time',
78
- };
79
-
80
- const knownContexts = [
81
- // set by `nodeContextIntegration`
82
- 'app',
83
- 'os',
84
- 'device',
85
- 'culture',
86
- 'cloud_resource',
87
- 'runtime',
88
-
89
- // TODO: These need more thorough checking if they're all setting expected attributes
90
-
91
- // set by the `instrumentPostgresJs`
92
- 'postgresjsConnection',
93
- // set by `ensureIsWrapped`
94
- 'missing_instrumentation',
95
- // set by `nodeProfilingIntegration`
96
- 'profile',
97
- // set by angular `init`
98
- 'angular',
99
- // set by AWS Lambda SDK
100
- 'aws.lambda',
101
- 'aws.cloudwatch.logs',
102
- // set by `instrumentBunServe`
103
- 'response',
104
- // set by `trpcMiddleware`
105
- 'trpc',
106
- // set by `instrumentSupabaseClient`
107
- 'supabase',
108
- // set by `gcp.function.context`
109
- 'gcp.function.context',
110
- // set by nextjs SDK
111
- 'nextjs',
112
- // set by react SDK `captureReactException`, `init`
113
- 'react',
114
- // set by react SDK `createReduxEnhancer`
115
- 'state',
116
- // set by `replayIntegration`
117
- 'Replays',
118
- // Other information:
119
- // - no need to handler feature flags `flags` context because it's already added to the active span
120
- ];
121
-
122
- /**
123
- * Converts a context object to a set of attributes.
124
- * Only includes attributes that are primitives (for now).
125
- * @param contexts - The context object to convert.
126
- * @returns The attributes object.
127
- */
128
- function contextsToAttributes(contexts) {
129
- function contextToAttribute(context) {
130
- return Object.keys(context).reduce(
131
- (acc, key) => {
132
- if (!is.isPrimitive(context[key])) {
133
- return acc;
134
- }
135
- acc[key] = context[key];
136
- return acc;
137
- },
138
- {} ,
139
- );
140
- }
141
-
142
- const contextsWithPrimitiveValues = Object.keys(contexts).reduce((acc, key) => {
143
- if (!knownContexts.includes(key)) {
144
- return acc;
145
- }
146
- const context = contexts[key];
147
- if (context) {
148
- acc[key] = contextToAttribute(context);
149
- }
150
- return acc;
151
- }, {} );
152
-
153
- const explicitlyMappedAttributes = Object.entries(explicitAttributeToContextMapping).reduce(
154
- (acc, [attributeKey, contextKey]) => {
155
- const [contextName, contextValueKey] = contextKey.split('.');
156
- if (contextName && contextValueKey && contextsWithPrimitiveValues[contextName]?.[contextValueKey]) {
157
- acc[attributeKey] = contextsWithPrimitiveValues[contextName]?.[contextValueKey];
158
- // now we delete this key from `contextsWithPrimitiveValues` so we don't include it in the next step
159
- delete contextsWithPrimitiveValues[contextName]?.[contextValueKey];
160
- }
161
- return acc;
162
- },
163
- {} ,
164
- );
165
-
166
- return {
167
- ...explicitlyMappedAttributes,
168
- ...Object.entries(contextsWithPrimitiveValues).reduce(
169
- (acc, [contextName, contextObj]) => {
170
- contextObj &&
171
- Object.entries(contextObj).forEach(([key, value]) => {
172
- if (value) {
173
- acc[`${contextName}.${key}`] = value;
174
- }
175
- });
176
- return acc;
177
- },
178
- {} ,
179
- ),
180
- };
181
- }
182
-
183
- exports.applyBeforeSendSpanCallback = applyBeforeSendSpanCallback;
184
- exports.contextsToAttributes = contextsToAttributes;
185
- exports.safeSetSpanJSONAttributes = safeSetSpanJSONAttributes;
186
- //# sourceMappingURL=spanFirstUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanFirstUtils.js","sources":["../../../src/spans/spanFirstUtils.ts"],"sourcesContent":["import type { RawAttributes } from '../attributes';\nimport { attributeValueToTypedAttributeValue, isAttributeObject } from '../attributes';\nimport type { Context, Contexts } from '../types-hoist/context';\nimport type { SpanV2JSON } from '../types-hoist/span';\nimport { isPrimitive } from '../utils/is';\nimport { showSpanDropWarning } from '../utils/spanUtils';\n\n/**\n * Only set a span JSON attribute if it is not already set.\n * This is used to safely set attributes on JSON objects without mutating already-ended span instances.\n */\nexport function safeSetSpanJSONAttributes(\n spanJSON: SpanV2JSON,\n newAttributes: RawAttributes<Record<string, unknown>>,\n): void {\n if (!spanJSON.attributes) {\n spanJSON.attributes = {};\n }\n\n const originalAttributes = spanJSON.attributes;\n\n Object.keys(newAttributes).forEach(key => {\n if (!originalAttributes?.[key]) {\n setAttributeOnSpanJSONWithMaybeUnit(\n // type-casting here because we ensured above that the attributes object exists\n spanJSON as SpanV2JSON & Required<Pick<SpanV2JSON, 'attributes'>>,\n key,\n newAttributes[key],\n );\n }\n });\n}\n\n/**\n * Apply a user-provided beforeSendSpan callback to a span JSON.\n */\nexport function applyBeforeSendSpanCallback(\n span: SpanV2JSON,\n beforeSendSpan: (span: SpanV2JSON) => SpanV2JSON,\n): SpanV2JSON {\n const modifedSpan = beforeSendSpan(span);\n if (!modifedSpan) {\n showSpanDropWarning();\n return span;\n }\n return modifedSpan;\n}\n\nfunction setAttributeOnSpanJSONWithMaybeUnit(\n spanJSON: SpanV2JSON & Required<Pick<SpanV2JSON, 'attributes'>>,\n attributeKey: string,\n attributeValue: unknown,\n): void {\n const { value, unit } = isAttributeObject(attributeValue)\n ? attributeValue\n : { value: attributeValue, unit: undefined };\n const typedAttributeValue = attributeValueToTypedAttributeValue(value);\n\n if (typedAttributeValue && isSupportedSerializableType(value)) {\n spanJSON.attributes[attributeKey] = typedAttributeValue;\n if (unit) {\n spanJSON.attributes[attributeKey].unit = unit;\n }\n }\n}\n\nfunction isSupportedSerializableType(value: unknown): boolean {\n return ['string', 'number', 'boolean'].includes(typeof value) || Array.isArray(value);\n}\n\n// map of attributes->context keys for those attributes that don't correspond 1:1 to the context key\nconst explicitAttributeToContextMapping = {\n 'os.build_id': 'os.build',\n 'app.name': 'app.app_name',\n 'app.identifier': 'app.app_identifier',\n 'app.version': 'app.app_version',\n 'app.memory': 'app.app_memory',\n 'app.start_time': 'app.app_start_time',\n};\n\nconst knownContexts = [\n // set by `nodeContextIntegration`\n 'app',\n 'os',\n 'device',\n 'culture',\n 'cloud_resource',\n 'runtime',\n\n // TODO: These need more thorough checking if they're all setting expected attributes\n\n // set by the `instrumentPostgresJs`\n 'postgresjsConnection',\n // set by `ensureIsWrapped`\n 'missing_instrumentation',\n // set by `nodeProfilingIntegration`\n 'profile',\n // set by angular `init`\n 'angular',\n // set by AWS Lambda SDK\n 'aws.lambda',\n 'aws.cloudwatch.logs',\n // set by `instrumentBunServe`\n 'response',\n // set by `trpcMiddleware`\n 'trpc',\n // set by `instrumentSupabaseClient`\n 'supabase',\n // set by `gcp.function.context`\n 'gcp.function.context',\n // set by nextjs SDK\n 'nextjs',\n // set by react SDK `captureReactException`, `init`\n 'react',\n // set by react SDK `createReduxEnhancer`\n 'state',\n // set by `replayIntegration`\n 'Replays',\n // Other information:\n // - no need to handler feature flags `flags` context because it's already added to the active span\n];\n\n/**\n * Converts a context object to a set of attributes.\n * Only includes attributes that are primitives (for now).\n * @param contexts - The context object to convert.\n * @returns The attributes object.\n */\nexport function contextsToAttributes(contexts: Contexts): RawAttributes<Record<string, unknown>> {\n function contextToAttribute(context: Context): Context {\n return Object.keys(context).reduce(\n (acc, key) => {\n if (!isPrimitive(context[key])) {\n return acc;\n }\n acc[key] = context[key];\n return acc;\n },\n {} as Record<string, unknown>,\n );\n }\n\n const contextsWithPrimitiveValues = Object.keys(contexts).reduce((acc, key) => {\n if (!knownContexts.includes(key)) {\n return acc;\n }\n const context = contexts[key];\n if (context) {\n acc[key] = contextToAttribute(context);\n }\n return acc;\n }, {} as Contexts);\n\n const explicitlyMappedAttributes = Object.entries(explicitAttributeToContextMapping).reduce(\n (acc, [attributeKey, contextKey]) => {\n const [contextName, contextValueKey] = contextKey.split('.');\n if (contextName && contextValueKey && contextsWithPrimitiveValues[contextName]?.[contextValueKey]) {\n acc[attributeKey] = contextsWithPrimitiveValues[contextName]?.[contextValueKey];\n // now we delete this key from `contextsWithPrimitiveValues` so we don't include it in the next step\n delete contextsWithPrimitiveValues[contextName]?.[contextValueKey];\n }\n return acc;\n },\n {} as Record<string, unknown>,\n );\n\n return {\n ...explicitlyMappedAttributes,\n ...Object.entries(contextsWithPrimitiveValues).reduce(\n (acc, [contextName, contextObj]) => {\n contextObj &&\n Object.entries(contextObj).forEach(([key, value]) => {\n if (value) {\n acc[`${contextName}.${key}`] = value;\n }\n });\n return acc;\n },\n {} as Record<string, unknown>,\n ),\n };\n}\n"],"names":["showSpanDropWarning","isAttributeObject","attributeValueToTypedAttributeValue","isPrimitive"],"mappings":";;;;;;AAOA;AACA;AACA;AACA;AACO,SAAS,yBAAyB;AACzC,EAAE,QAAQ;AACV,EAAE,aAAa;AACf,EAAQ;AACR,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;AAC5B,IAAI,QAAQ,CAAC,UAAA,GAAa,EAAE;AAC5B,EAAE;;AAEF,EAAE,MAAM,kBAAA,GAAqB,QAAQ,CAAC,UAAU;;AAEhD,EAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,GAAA,IAAO;AAC5C,IAAI,IAAI,CAAC,kBAAkB,GAAG,GAAG,CAAC,EAAE;AACpC,MAAM,mCAAmC;AACzC;AACA,QAAQ,QAAA;AACR,QAAQ,GAAG;AACX,QAAQ,aAAa,CAAC,GAAG,CAAC;AAC1B,OAAO;AACP,IAAI;AACJ,EAAE,CAAC,CAAC;AACJ;;AAEA;AACA;AACA;AACO,SAAS,2BAA2B;AAC3C,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,MAAA,EAAA;AACA,KAAA;AACA,GAAA;AACA;;;;;;"}
@@ -1,36 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const object = require('./object.js');
4
-
5
- /**
6
- * A wrapper to use the new span format in your `beforeSendSpan` callback.
7
- *
8
- * @example
9
- *
10
- * Sentry.init({
11
- * beforeSendSpan: withStreamSpan((span) => {
12
- * return span;
13
- * }),
14
- * });
15
- *
16
- * @param callback
17
- * @returns
18
- */
19
- function withStreamSpan(callback) {
20
- object.addNonEnumerableProperty(callback, '_v2', true);
21
- // type-casting here because TS can't infer the type correctly
22
- return callback ;
23
- }
24
-
25
- /**
26
- * Typesafe check to identify the expected span json format of the `beforeSendSpan` callback.
27
- */
28
- function isV2BeforeSendSpanCallback(
29
- callback,
30
- ) {
31
- return !!callback && '_v2' in callback && !!callback._v2;
32
- }
33
-
34
- exports.isV2BeforeSendSpanCallback = isV2BeforeSendSpanCallback;
35
- exports.withStreamSpan = withStreamSpan;
36
- //# sourceMappingURL=beforeSendSpan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"beforeSendSpan.js","sources":["../../../src/utils/beforeSendSpan.ts"],"sourcesContent":["import type { ClientOptions, SpanV2CompatibleBeforeSendSpanCallback } from '../types-hoist/options';\nimport type { SpanV2JSON } from '../types-hoist/span';\nimport { addNonEnumerableProperty } from './object';\n\n/**\n * A wrapper to use the new span format in your `beforeSendSpan` callback.\n *\n * @example\n *\n * Sentry.init({\n * beforeSendSpan: withStreamSpan((span) => {\n * return span;\n * }),\n * });\n *\n * @param callback\n * @returns\n */\nexport function withStreamSpan(callback: (span: SpanV2JSON) => SpanV2JSON): SpanV2CompatibleBeforeSendSpanCallback {\n addNonEnumerableProperty(callback, '_v2', true);\n // type-casting here because TS can't infer the type correctly\n return callback as SpanV2CompatibleBeforeSendSpanCallback;\n}\n\n/**\n * Typesafe check to identify the expected span json format of the `beforeSendSpan` callback.\n */\nexport function isV2BeforeSendSpanCallback(\n callback: ClientOptions['beforeSendSpan'],\n): callback is SpanV2CompatibleBeforeSendSpanCallback {\n return !!callback && '_v2' in callback && !!callback._v2;\n}\n"],"names":["addNonEnumerableProperty"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,QAAQ,EAA4E;AACnH,EAAEA,+BAAwB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;AACjD;AACA,EAAE,OAAO,QAAA;AACT;;AAEA;AACA;AACA;AACO,SAAS,0BAA0B;AAC1C,EAAE,QAAQ;AACV,EAAsD;AACtD,EAAE,OAAO,CAAC,CAAC,QAAA,IAAY,KAAA,IAAS,QAAA,IAAY,CAAC,CAAC,QAAQ,CAAC,GAAG;AAC1D;;;;;"}
@@ -1,21 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const currentScopes = require('../currentScopes.js');
4
-
5
- // Treeshakable guard to remove all code related to tracing
6
-
7
- /**
8
- * Determines if the SDK is configured for span streaming.
9
- * Span streaming is enabled when `traceLifecycle` is set to `stream`.
10
- * (In Browser, users must add `spanStreamingIntegration` as well but it
11
- * already checks itself and configures `traceLifecycle` appropriately)
12
- */
13
- function hasSpanStreamingEnabled(maybeClient = currentScopes.getClient()) {
14
- if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {
15
- return false;
16
- }
17
- return (maybeClient ?? currentScopes.getClient())?.getOptions()?.traceLifecycle === 'stream';
18
- }
19
-
20
- exports.hasSpanStreamingEnabled = hasSpanStreamingEnabled;
21
- //# sourceMappingURL=hasSpanStreamingEnabled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hasSpanStreamingEnabled.js","sources":["../../../src/utils/hasSpanStreamingEnabled.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\n\n// Treeshakable guard to remove all code related to tracing\ndeclare const __SENTRY_TRACING__: boolean | undefined;\n\n/**\n * Determines if the SDK is configured for span streaming.\n * Span streaming is enabled when `traceLifecycle` is set to `stream`.\n * (In Browser, users must add `spanStreamingIntegration` as well but it\n * already checks itself and configures `traceLifecycle` appropriately)\n */\nexport function hasSpanStreamingEnabled(maybeClient: Client | undefined = getClient()): boolean {\n if (typeof __SENTRY_TRACING__ === 'boolean' && !__SENTRY_TRACING__) {\n return false;\n }\n return (maybeClient ?? getClient())?.getOptions()?.traceLifecycle === 'stream';\n}\n"],"names":["getClient"],"mappings":";;;;AAGA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,uBAAuB,CAAC,WAAW,GAAuBA,uBAAS,EAAE,EAAW;AAChG,EAAE,IAAI,OAAO,kBAAA,KAAuB,SAAA,IAAa,CAAC,kBAAkB,EAAE;AACtE,IAAI,OAAO,KAAK;AAChB,EAAE;AACF,EAAE,OAAO,CAAC,WAAA,IAAeA,uBAAS,EAAE,GAAG,UAAU,EAAE,EAAE,cAAA,KAAmB,QAAQ;AAChF;;;;"}
@@ -1,52 +0,0 @@
1
- import { DEBUG_BUILD } from '../debug-build.js';
2
- import { defineIntegration } from '../integration.js';
3
- import { captureSpan } from '../spans/captureSpan.js';
4
- import { SpanBuffer } from '../spans/spanBuffer.js';
5
- import { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan.js';
6
- import { debug } from '../utils/debug-logger.js';
7
-
8
- const INTEGRATION_NAME = 'SpanStreaming';
9
-
10
- const _spanStreamingIntegration = ((options) => {
11
- return {
12
- name: INTEGRATION_NAME,
13
- setup(client) {
14
- const clientOptions = client.getOptions();
15
- const beforeSendSpan = clientOptions.beforeSendSpan;
16
-
17
- const initialMessage = 'spanStreamingIntegration requires';
18
- const fallbackMsg = 'Falling back to static trace lifecycle.';
19
-
20
- if (clientOptions.traceLifecycle !== 'stream') {
21
- client.getOptions().traceLifecycle = 'static';
22
- DEBUG_BUILD && debug.warn(`${initialMessage} \`traceLifecycle\` to be set to "stream"! ${fallbackMsg}`);
23
- return;
24
- }
25
-
26
- if (beforeSendSpan && !isV2BeforeSendSpanCallback(beforeSendSpan)) {
27
- client.getOptions().traceLifecycle = 'static';
28
- DEBUG_BUILD &&
29
- debug.warn(`${initialMessage} a beforeSendSpan callback using \`withStreamSpan\`! ${fallbackMsg}`);
30
- return;
31
- }
32
-
33
- const buffer = new SpanBuffer(client, options);
34
-
35
- client.on('enqueueSpan', spanJSON => {
36
- buffer.addSpan(spanJSON);
37
- });
38
-
39
- client.on('afterSpanEnd', span => {
40
- captureSpan(span, client);
41
- });
42
- },
43
- };
44
- }) ;
45
-
46
- /**
47
- * Span streaming integration used by server runtime SDKs.
48
- */
49
- const spanStreamingIntegration = defineIntegration(_spanStreamingIntegration);
50
-
51
- export { spanStreamingIntegration };
52
- //# sourceMappingURL=spanStreaming.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanStreaming.js","sources":["../../../src/integrations/spanStreaming.ts"],"sourcesContent":["import { DEBUG_BUILD } from '../debug-build';\nimport { defineIntegration } from '../integration';\nimport { captureSpan } from '../spans/captureSpan';\nimport { SpanBuffer } from '../spans/spanBuffer';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan';\nimport { debug } from '../utils/debug-logger';\n\nexport interface ServerSpanStreamingOptions {\n /** Max spans per envelope batch (default: 1000) */\n maxSpanLimit?: number;\n /** Flush interval in ms (default: 5000) */\n flushInterval?: number;\n}\n\nconst INTEGRATION_NAME = 'SpanStreaming';\n\nconst _spanStreamingIntegration = ((options?: ServerSpanStreamingOptions) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const clientOptions = client.getOptions();\n const beforeSendSpan = clientOptions.beforeSendSpan;\n\n const initialMessage = 'spanStreamingIntegration requires';\n const fallbackMsg = 'Falling back to static trace lifecycle.';\n\n if (clientOptions.traceLifecycle !== 'stream') {\n client.getOptions().traceLifecycle = 'static';\n DEBUG_BUILD && debug.warn(`${initialMessage} \\`traceLifecycle\\` to be set to \"stream\"! ${fallbackMsg}`);\n return;\n }\n\n if (beforeSendSpan && !isV2BeforeSendSpanCallback(beforeSendSpan)) {\n client.getOptions().traceLifecycle = 'static';\n DEBUG_BUILD &&\n debug.warn(`${initialMessage} a beforeSendSpan callback using \\`withStreamSpan\\`! ${fallbackMsg}`);\n return;\n }\n\n const buffer = new SpanBuffer(client, options);\n\n client.on('enqueueSpan', spanJSON => {\n buffer.addSpan(spanJSON);\n });\n\n client.on('afterSpanEnd', span => {\n captureSpan(span, client);\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Span streaming integration used by server runtime SDKs.\n */\nexport const spanStreamingIntegration = defineIntegration(_spanStreamingIntegration);\n"],"names":[],"mappings":";;;;;;;AAeA,MAAM,gBAAA,GAAmB,eAAe;;AAExC,MAAM,6BAA6B,CAAC,OAAO,KAAkC;AAC7E,EAAE,OAAO;AACT,IAAI,IAAI,EAAE,gBAAgB;AAC1B,IAAI,KAAK,CAAC,MAAM,EAAE;AAClB,MAAM,MAAM,aAAA,GAAgB,MAAM,CAAC,UAAU,EAAE;AAC/C,MAAM,MAAM,cAAA,GAAiB,aAAa,CAAC,cAAc;;AAEzD,MAAM,MAAM,cAAA,GAAiB,mCAAmC;AAChE,MAAM,MAAM,WAAA,GAAc,yCAAyC;;AAEnE,MAAM,IAAI,aAAa,CAAC,cAAA,KAAmB,QAAQ,EAAE;AACrD,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC,cAAA,GAAiB,QAAQ;AACrD,QAAQ,eAAe,KAAK,CAAC,IAAI,CAAC,CAAC,EAAA,cAAA,CAAA,2CAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,IAAA,cAAA,IAAA,CAAA,0BAAA,CAAA,cAAA,CAAA,EAAA;AACA,QAAA,MAAA,CAAA,UAAA,EAAA,CAAA,cAAA,GAAA,QAAA;AACA,QAAA,WAAA;AACA,UAAA,KAAA,CAAA,IAAA,CAAA,CAAA,EAAA,cAAA,CAAA,qDAAA,EAAA,WAAA,CAAA,CAAA,CAAA;AACA,QAAA;AACA,MAAA;;AAEA,MAAA,MAAA,MAAA,GAAA,IAAA,UAAA,CAAA,MAAA,EAAA,OAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,aAAA,EAAA,QAAA,IAAA;AACA,QAAA,MAAA,CAAA,OAAA,CAAA,QAAA,CAAA;AACA,MAAA,CAAA,CAAA;;AAEA,MAAA,MAAA,CAAA,EAAA,CAAA,cAAA,EAAA,IAAA,IAAA;AACA,QAAA,WAAA,CAAA,IAAA,EAAA,MAAA,CAAA;AACA,MAAA,CAAA,CAAA;AACA,IAAA,CAAA;AACA,GAAA;AACA,CAAA,CAAA;;AAEA;AACA;AACA;AACA,MAAA,wBAAA,GAAA,iBAAA,CAAA,yBAAA;;;;"}
@@ -1,102 +0,0 @@
1
- import { getClient } from '../currentScopes.js';
2
- import { DEBUG_BUILD } from '../debug-build.js';
3
- import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE, SEMANTIC_ATTRIBUTE_USER_USERNAME, SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS, SEMANTIC_ATTRIBUTE_USER_EMAIL, SEMANTIC_ATTRIBUTE_USER_ID, SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID, SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME, SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT, SEMANTIC_ATTRIBUTE_SENTRY_RELEASE } from '../semanticAttributes.js';
4
- import { getCapturedScopesOnSpan } from '../tracing/utils.js';
5
- import { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan.js';
6
- import { debug } from '../utils/debug-logger.js';
7
- import { getCombinedScopeData } from '../utils/scopeData.js';
8
- import { spanToV2JSON, INTERNAL_getSegmentSpan } from '../utils/spanUtils.js';
9
- import { applyBeforeSendSpanCallback, safeSetSpanJSONAttributes, contextsToAttributes } from './spanFirstUtils.js';
10
-
11
- /**
12
- * Captures a span and returns a JSON representation to be enqueued for sending.
13
- *
14
- * IMPORTANT: This function converts the span to JSON immediately to avoid writing
15
- * to an already-ended OTel span instance (which is blocked by the OTel Span class).
16
- */
17
- function captureSpan(span, client = getClient()) {
18
- if (!client) {
19
- DEBUG_BUILD && debug.warn('No client available to capture span.');
20
- return;
21
- }
22
-
23
- // Convert to JSON FIRST - we cannot write to an already-ended span
24
- const spanJSON = spanToV2JSON(span);
25
-
26
- const segmentSpan = INTERNAL_getSegmentSpan(span);
27
- const serializedSegmentSpan = spanToV2JSON(segmentSpan);
28
-
29
- const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);
30
-
31
- const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);
32
-
33
- applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);
34
-
35
- if (span === segmentSpan) {
36
- applyScopeToSegmentSpan(spanJSON, finalScopeData);
37
- client.emit('processSegmentSpan', spanJSON, { scopeData: finalScopeData });
38
- }
39
-
40
- // Allow integrations to add additional data to the span JSON
41
- client.emit('processSpan', spanJSON, { readOnlySpan: span });
42
-
43
- const beforeSendSpan = client.getOptions().beforeSendSpan;
44
- const processedSpan = isV2BeforeSendSpanCallback(beforeSendSpan)
45
- ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)
46
- : spanJSON;
47
-
48
- // Backfill sentry.span.source from sentry.source for the PoC
49
- // TODO(v11): Stop sending `sentry.source` attribute and only send `sentry.span.source`
50
- // probably easiest done by just renaming SEMANTIC_ATTRIBUTE_SENTRY_SOURCE
51
- if (processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]) {
52
- safeSetSpanJSONAttributes(processedSpan, {
53
- [SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]?.value,
54
- });
55
- }
56
-
57
- const spanWithRef = {
58
- ...processedSpan,
59
- _segmentSpan: segmentSpan,
60
- };
61
-
62
- client.emit('enqueueSpan', spanWithRef);
63
- }
64
-
65
- function applyScopeToSegmentSpan(segmentSpanJSON, scopeData) {
66
- // TODO: Apply all scope and request data from auto instrumentation (contexts, request) to segment span
67
- const { contexts } = scopeData;
68
-
69
- safeSetSpanJSONAttributes(segmentSpanJSON, contextsToAttributes(contexts));
70
- }
71
-
72
- function applyCommonSpanAttributes(
73
- spanJSON,
74
- serializedSegmentSpan,
75
- client,
76
- scopeData,
77
- ) {
78
- const sdk = client.getSdkMetadata();
79
- const { release, environment, sendDefaultPii } = client.getOptions();
80
-
81
- // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)
82
- safeSetSpanJSONAttributes(spanJSON, {
83
- [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,
84
- [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment,
85
- [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,
86
- [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,
87
- [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,
88
- [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,
89
- ...(sendDefaultPii
90
- ? {
91
- [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,
92
- [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,
93
- [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,
94
- [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,
95
- }
96
- : {}),
97
- ...scopeData.attributes,
98
- });
99
- }
100
-
101
- export { captureSpan };
102
- //# sourceMappingURL=captureSpan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureSpan.js","sources":["../../../src/spans/captureSpan.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { getClient } from '../currentScopes';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { ScopeData } from '../scope';\nimport {\n SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT,\n SEMANTIC_ATTRIBUTE_SENTRY_RELEASE,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID,\n SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE,\n SEMANTIC_ATTRIBUTE_USER_EMAIL,\n SEMANTIC_ATTRIBUTE_USER_ID,\n SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS,\n SEMANTIC_ATTRIBUTE_USER_USERNAME,\n} from '../semanticAttributes';\nimport { getCapturedScopesOnSpan } from '../tracing/utils';\nimport type { Span, SpanV2JSON } from '../types-hoist/span';\nimport { isV2BeforeSendSpanCallback } from '../utils/beforeSendSpan';\nimport { debug } from '../utils/debug-logger';\nimport { getCombinedScopeData } from '../utils/scopeData';\nimport { INTERNAL_getSegmentSpan, spanToV2JSON } from '../utils/spanUtils';\nimport { applyBeforeSendSpanCallback, contextsToAttributes, safeSetSpanJSONAttributes } from './spanFirstUtils';\n/**\n * Captures a span and returns a JSON representation to be enqueued for sending.\n *\n * IMPORTANT: This function converts the span to JSON immediately to avoid writing\n * to an already-ended OTel span instance (which is blocked by the OTel Span class).\n */\nexport function captureSpan(span: Span, client = getClient()): void {\n if (!client) {\n DEBUG_BUILD && debug.warn('No client available to capture span.');\n return;\n }\n\n // Convert to JSON FIRST - we cannot write to an already-ended span\n const spanJSON = spanToV2JSON(span);\n\n const segmentSpan = INTERNAL_getSegmentSpan(span);\n const serializedSegmentSpan = spanToV2JSON(segmentSpan);\n\n const { isolationScope: spanIsolationScope, scope: spanScope } = getCapturedScopesOnSpan(span);\n\n const finalScopeData = getCombinedScopeData(spanIsolationScope, spanScope);\n\n applyCommonSpanAttributes(spanJSON, serializedSegmentSpan, client, finalScopeData);\n\n if (span === segmentSpan) {\n applyScopeToSegmentSpan(spanJSON, finalScopeData);\n client.emit('processSegmentSpan', spanJSON, { scopeData: finalScopeData });\n }\n\n // Allow integrations to add additional data to the span JSON\n client.emit('processSpan', spanJSON, { readOnlySpan: span });\n\n const beforeSendSpan = client.getOptions().beforeSendSpan;\n const processedSpan = isV2BeforeSendSpanCallback(beforeSendSpan)\n ? applyBeforeSendSpanCallback(spanJSON, beforeSendSpan)\n : spanJSON;\n\n // Backfill sentry.span.source from sentry.source for the PoC\n // TODO(v11): Stop sending `sentry.source` attribute and only send `sentry.span.source`\n // probably easiest done by just renaming SEMANTIC_ATTRIBUTE_SENTRY_SOURCE\n if (processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]) {\n safeSetSpanJSONAttributes(processedSpan, {\n [SEMANTIC_ATTRIBUTE_SENTRY_SPAN_SOURCE]: processedSpan.attributes?.[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]?.value,\n });\n }\n\n const spanWithRef = {\n ...processedSpan,\n _segmentSpan: segmentSpan,\n };\n\n client.emit('enqueueSpan', spanWithRef);\n}\n\nfunction applyScopeToSegmentSpan(segmentSpanJSON: SpanV2JSON, scopeData: ScopeData): void {\n // TODO: Apply all scope and request data from auto instrumentation (contexts, request) to segment span\n const { contexts } = scopeData;\n\n safeSetSpanJSONAttributes(segmentSpanJSON, contextsToAttributes(contexts));\n}\n\nfunction applyCommonSpanAttributes(\n spanJSON: SpanV2JSON,\n serializedSegmentSpan: SpanV2JSON,\n client: Client,\n scopeData: ScopeData,\n): void {\n const sdk = client.getSdkMetadata();\n const { release, environment, sendDefaultPii } = client.getOptions();\n\n // avoid overwriting any previously set attributes (from users or potentially our SDK instrumentation)\n safeSetSpanJSONAttributes(spanJSON, {\n [SEMANTIC_ATTRIBUTE_SENTRY_RELEASE]: release,\n [SEMANTIC_ATTRIBUTE_SENTRY_ENVIRONMENT]: environment,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_NAME]: serializedSegmentSpan.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SEGMENT_ID]: serializedSegmentSpan.span_id,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_NAME]: sdk?.sdk?.name,\n [SEMANTIC_ATTRIBUTE_SENTRY_SDK_VERSION]: sdk?.sdk?.version,\n ...(sendDefaultPii\n ? {\n [SEMANTIC_ATTRIBUTE_USER_ID]: scopeData.user?.id,\n [SEMANTIC_ATTRIBUTE_USER_EMAIL]: scopeData.user?.email,\n [SEMANTIC_ATTRIBUTE_USER_IP_ADDRESS]: scopeData.user?.ip_address,\n [SEMANTIC_ATTRIBUTE_USER_USERNAME]: scopeData.user?.username,\n }\n : {}),\n ...scopeData.attributes,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,WAAW,CAAC,IAAI,EAAQ,MAAA,GAAS,SAAS,EAAE,EAAQ;AACpE,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI,eAAe,KAAK,CAAC,IAAI,CAAC,sCAAsC,CAAC;AACrE,IAAI;AACJ,EAAE;;AAEF;AACA,EAAE,MAAM,QAAA,GAAW,YAAY,CAAC,IAAI,CAAC;;AAErC,EAAE,MAAM,WAAA,GAAc,uBAAuB,CAAC,IAAI,CAAC;AACnD,EAAE,MAAM,qBAAA,GAAwB,YAAY,CAAC,WAAW,CAAC;;AAEzD,EAAE,MAAM,EAAE,cAAc,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAA,EAAU,GAAI,uBAAuB,CAAC,IAAI,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E;;AAEA,SAAS,yBAAyB;AAClC,EAAE,QAAQ;AACV,EAAE,qBAAqB;AACvB,EAAE,MAAM;AACR,EAAE,SAAS;AACX,EAAQ;AACR,EAAE,MAAM,GAAA,GAAM,MAAM,CAAC,cAAc,EAAE;AACrC,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,cAAA,EAAe,GAAI,MAAM,CAAC,UAAU,EAAE;;AAEtE;AACA,EAAE,yBAAyB,CAAC,QAAQ,EAAE;AACtC,IAAI,CAAC,iCAAiC,GAAG,OAAO;AAChD,IAAI,CAAC,qCAAqC,GAAG,WAAW;AACxD,IAAI,CAAC,sCAAsC,GAAG,qBAAqB,CAAC,IAAI;AACxE,IAAI,CAAC,oCAAoC,GAAG,qBAAqB,CAAC,OAAO;AACzE,IAAI,CAAC,kCAAkC,GAAG,GAAG,EAAE,GAAG,EAAE,IAAI;AACxD,IAAI,CAAC,qCAAqC,GAAG,GAAG,EAAE,GAAG,EAAE,OAAO;AAC9D,IAAI,IAAI;AACR,QAAQ;AACR,UAAU,CAAC,0BAA0B,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE;AAC1D,UAAU,CAAC,6BAA6B,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK;AAChE,UAAU,CAAC,kCAAkC,GAAG,SAAS,CAAC,IAAI,EAAE,UAAU;AAC1E,UAAU,CAAC,gCAAgC,GAAG,SAAS,CAAC,IAAI,EAAE,QAAQ;AACtE;AACA,QAAQ,EAAE,CAAC;AACX,IAAI,GAAG,SAAS,CAAC,UAAU;AAC3B,GAAG,CAAC;AACJ;;;;"}
@@ -1,119 +0,0 @@
1
- import { DEBUG_BUILD } from '../debug-build.js';
2
- import { createSpanV2Envelope } from '../envelope.js';
3
- import { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext.js';
4
- import { debug } from '../utils/debug-logger.js';
5
-
6
- /**
7
- * A buffer for span JSON objects that flushes them to Sentry in Span v2 envelopes.
8
- * Handles interval-based flushing, size thresholds, and graceful shutdown.
9
- */
10
- class SpanBuffer {
11
-
12
- constructor(client, options) {
13
- this._spanTreeMap = new Map();
14
- this._client = client;
15
-
16
- const { maxSpanLimit, flushInterval } = options ?? {};
17
-
18
- this._maxSpanLimit = maxSpanLimit && maxSpanLimit > 0 && maxSpanLimit <= 1000 ? maxSpanLimit : 1000;
19
- this._flushInterval = flushInterval && flushInterval > 0 ? flushInterval : 5000;
20
-
21
- this._flushIntervalId = setInterval(() => {
22
- this.flush();
23
- }, this._flushInterval);
24
-
25
- this._client.on('flush', () => {
26
- this.flush();
27
- });
28
- }
29
-
30
- /**
31
- * Add a span to the buffer.
32
- */
33
- addSpan(spanJSON) {
34
- const traceId = spanJSON.trace_id;
35
- let traceBucket = this._spanTreeMap.get(traceId);
36
- if (traceBucket) {
37
- traceBucket.add(spanJSON);
38
- } else {
39
- traceBucket = new Set([spanJSON]);
40
- this._spanTreeMap.set(traceId, traceBucket);
41
- }
42
-
43
- if (traceBucket.size >= this._maxSpanLimit) {
44
- this.flushTrace(traceId);
45
- this._debounceFlushInterval();
46
- }
47
- }
48
-
49
- /**
50
- * Flush all buffered traces.
51
- */
52
- flush() {
53
- if (!this._spanTreeMap.size) {
54
- return;
55
- }
56
-
57
- DEBUG_BUILD && debug.log(`Flushing span tree map with ${this._spanTreeMap.size} traces`);
58
-
59
- this._spanTreeMap.forEach((_, traceId) => {
60
- this.flushTrace(traceId);
61
- });
62
- this._debounceFlushInterval();
63
- }
64
-
65
- /**
66
- * Flush spans of a specific trace.
67
- * In contrast to {@link SpanBuffer.flush}, this method does not flush all traces, but only the one with the given traceId.
68
- */
69
- flushTrace(traceId) {
70
- const traceBucket = this._spanTreeMap.get(traceId);
71
- if (!traceBucket) {
72
- return;
73
- }
74
-
75
- if (!traceBucket.size) {
76
- this._spanTreeMap.delete(traceId);
77
- return;
78
- }
79
-
80
- const firstSpanJSON = traceBucket.values().next().value;
81
-
82
- const segmentSpan = firstSpanJSON?._segmentSpan;
83
- if (!segmentSpan) {
84
- DEBUG_BUILD && debug.warn('No segment span reference found on span JSON, cannot compute DSC');
85
- this._spanTreeMap.delete(traceId);
86
- return;
87
- }
88
-
89
- const dsc = getDynamicSamplingContextFromSpan(segmentSpan);
90
-
91
- const cleanedSpans = Array.from(traceBucket).map(spanJSON => {
92
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
93
- const { _segmentSpan, ...cleanSpanJSON } = spanJSON;
94
- return cleanSpanJSON;
95
- });
96
-
97
- const envelope = createSpanV2Envelope(cleanedSpans, dsc, this._client);
98
-
99
- DEBUG_BUILD && debug.log(`Sending span envelope for trace ${traceId} with ${cleanedSpans.length} spans`);
100
-
101
- this._client.sendEnvelope(envelope).then(null, reason => {
102
- DEBUG_BUILD && debug.error('Error while sending span stream envelope:', reason);
103
- });
104
-
105
- this._spanTreeMap.delete(traceId);
106
- }
107
-
108
- _debounceFlushInterval() {
109
- if (this._flushIntervalId) {
110
- clearInterval(this._flushIntervalId);
111
- }
112
- this._flushIntervalId = setInterval(() => {
113
- this.flush();
114
- }, this._flushInterval);
115
- }
116
- }
117
-
118
- export { SpanBuffer };
119
- //# sourceMappingURL=spanBuffer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spanBuffer.js","sources":["../../../src/spans/spanBuffer.ts"],"sourcesContent":["import type { Client } from '../client';\nimport { DEBUG_BUILD } from '../debug-build';\nimport { createSpanV2Envelope } from '../envelope';\nimport { getDynamicSamplingContextFromSpan } from '../tracing/dynamicSamplingContext';\nimport type { SpanV2JSON, SpanV2JSONWithSegmentRef } from '../types-hoist/span';\nimport { debug } from '../utils/debug-logger';\n\nexport interface SpanBufferOptions {\n /** Max spans per trace before auto-flush (default: 1000) */\n maxSpanLimit?: number;\n /** Flush interval in ms (default: 5000) */\n flushInterval?: number;\n}\n\n/**\n * A buffer for span JSON objects that flushes them to Sentry in Span v2 envelopes.\n * Handles interval-based flushing, size thresholds, and graceful shutdown.\n */\nexport class SpanBuffer {\n private _spanTreeMap: Map<string, Set<SpanV2JSONWithSegmentRef>>;\n private _flushIntervalId: ReturnType<typeof setInterval> | null;\n private _client: Client;\n private _maxSpanLimit: number;\n private _flushInterval: number;\n\n public constructor(client: Client, options?: SpanBufferOptions) {\n this._spanTreeMap = new Map();\n this._client = client;\n\n const { maxSpanLimit, flushInterval } = options ?? {};\n\n this._maxSpanLimit = maxSpanLimit && maxSpanLimit > 0 && maxSpanLimit <= 1000 ? maxSpanLimit : 1000;\n this._flushInterval = flushInterval && flushInterval > 0 ? flushInterval : 5_000;\n\n this._flushIntervalId = setInterval(() => {\n this.flush();\n }, this._flushInterval);\n\n this._client.on('flush', () => {\n this.flush();\n });\n }\n\n /**\n * Add a span to the buffer.\n */\n public addSpan(spanJSON: SpanV2JSONWithSegmentRef): void {\n const traceId = spanJSON.trace_id;\n let traceBucket = this._spanTreeMap.get(traceId);\n if (traceBucket) {\n traceBucket.add(spanJSON);\n } else {\n traceBucket = new Set([spanJSON]);\n this._spanTreeMap.set(traceId, traceBucket);\n }\n\n if (traceBucket.size >= this._maxSpanLimit) {\n this.flushTrace(traceId);\n this._debounceFlushInterval();\n }\n }\n\n /**\n * Flush all buffered traces.\n */\n public flush(): void {\n if (!this._spanTreeMap.size) {\n return;\n }\n\n DEBUG_BUILD && debug.log(`Flushing span tree map with ${this._spanTreeMap.size} traces`);\n\n this._spanTreeMap.forEach((_, traceId) => {\n this.flushTrace(traceId);\n });\n this._debounceFlushInterval();\n }\n\n /**\n * Flush spans of a specific trace.\n * In contrast to {@link SpanBuffer.flush}, this method does not flush all traces, but only the one with the given traceId.\n */\n public flushTrace(traceId: string): void {\n const traceBucket = this._spanTreeMap.get(traceId);\n if (!traceBucket) {\n return;\n }\n\n if (!traceBucket.size) {\n this._spanTreeMap.delete(traceId);\n return;\n }\n\n const firstSpanJSON = traceBucket.values().next().value;\n\n const segmentSpan = firstSpanJSON?._segmentSpan;\n if (!segmentSpan) {\n DEBUG_BUILD && debug.warn('No segment span reference found on span JSON, cannot compute DSC');\n this._spanTreeMap.delete(traceId);\n return;\n }\n\n const dsc = getDynamicSamplingContextFromSpan(segmentSpan);\n\n const cleanedSpans: SpanV2JSON[] = Array.from(traceBucket).map(spanJSON => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { _segmentSpan, ...cleanSpanJSON } = spanJSON;\n return cleanSpanJSON;\n });\n\n const envelope = createSpanV2Envelope(cleanedSpans, dsc, this._client);\n\n DEBUG_BUILD && debug.log(`Sending span envelope for trace ${traceId} with ${cleanedSpans.length} spans`);\n\n this._client.sendEnvelope(envelope).then(null, reason => {\n DEBUG_BUILD && debug.error('Error while sending span stream envelope:', reason);\n });\n\n this._spanTreeMap.delete(traceId);\n }\n\n private _debounceFlushInterval(): void {\n if (this._flushIntervalId) {\n clearInterval(this._flushIntervalId);\n }\n this._flushIntervalId = setInterval(() => {\n this.flush();\n }, this._flushInterval);\n }\n}\n"],"names":[],"mappings":";;;;;AAcA;AACA;AACA;AACA;AACO,MAAM,UAAA,CAAW;;AAOxB,GAAS,WAAW,CAAC,MAAM,EAAU,OAAO,EAAsB;AAClE,IAAI,IAAI,CAAC,YAAA,GAAe,IAAI,GAAG,EAAE;AACjC,IAAI,IAAI,CAAC,OAAA,GAAU,MAAM;;AAEzB,IAAI,MAAM,EAAE,YAAY,EAAE,aAAA,KAAkB,OAAA,IAAW,EAAE;;AAEzD,IAAI,IAAI,CAAC,aAAA,GAAgB,YAAA,IAAgB,YAAA,GAAe,CAAA,IAAK,gBAAgB,IAAA,GAAO,YAAA,GAAe,IAAI;AACvG,IAAI,IAAI,CAAC,cAAA,GAAiB,aAAA,IAAiB,aAAA,GAAgB,CAAA,GAAI,aAAA,GAAgB,IAAK;;AAEpF,IAAI,IAAI,CAAC,gBAAA,GAAmB,WAAW,CAAC,MAAM;AAC9C,MAAM,IAAI,CAAC,KAAK,EAAE;AAClB,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC;;AAE3B,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC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