autotel 2.26.3 → 3.0.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 (191) hide show
  1. package/README.md +50 -23
  2. package/dist/attribute-redacting-processor.cjs +8 -8
  3. package/dist/attribute-redacting-processor.d.cts +10 -1
  4. package/dist/attribute-redacting-processor.d.ts +10 -1
  5. package/dist/attribute-redacting-processor.js +1 -1
  6. package/dist/attributes.cjs +21 -21
  7. package/dist/attributes.d.cts +3 -3
  8. package/dist/attributes.d.ts +3 -3
  9. package/dist/attributes.js +2 -2
  10. package/dist/auto.cjs +3 -3
  11. package/dist/auto.js +2 -2
  12. package/dist/business-baggage.d.cts +1 -1
  13. package/dist/business-baggage.d.ts +1 -1
  14. package/dist/chunk-4P6ZOARG.cjs +33 -0
  15. package/dist/chunk-4P6ZOARG.cjs.map +1 -0
  16. package/dist/{chunk-U54FTVFH.js → chunk-52PUSFC2.js} +3 -3
  17. package/dist/{chunk-U54FTVFH.js.map → chunk-52PUSFC2.js.map} +1 -1
  18. package/dist/{chunk-YEVCD6DR.cjs → chunk-7SMNC4LS.cjs} +7 -7
  19. package/dist/{chunk-YEVCD6DR.cjs.map → chunk-7SMNC4LS.cjs.map} +1 -1
  20. package/dist/{chunk-563EL6O6.cjs → chunk-BPO2PQ3T.cjs} +12 -8
  21. package/dist/chunk-BPO2PQ3T.cjs.map +1 -0
  22. package/dist/{chunk-WZOKY3PW.cjs → chunk-DAZ7EGR4.cjs} +19 -19
  23. package/dist/{chunk-WZOKY3PW.cjs.map → chunk-DAZ7EGR4.cjs.map} +1 -1
  24. package/dist/{chunk-ER43K7ES.js → chunk-DDXIUZEG.js} +3 -3
  25. package/dist/{chunk-ER43K7ES.js.map → chunk-DDXIUZEG.js.map} +1 -1
  26. package/dist/{chunk-JKIMEPI2.cjs → chunk-DQ2SUROF.cjs} +4 -4
  27. package/dist/{chunk-JKIMEPI2.cjs.map → chunk-DQ2SUROF.cjs.map} +1 -1
  28. package/dist/{chunk-B3ZHLLMP.js → chunk-DSMSIVTG.js} +2 -2
  29. package/dist/chunk-DSMSIVTG.js.map +1 -0
  30. package/dist/{chunk-OBWXM4NN.cjs → chunk-HKZHUGGN.cjs} +15 -14
  31. package/dist/chunk-HKZHUGGN.cjs.map +1 -0
  32. package/dist/{chunk-TDNKIHKT.js → chunk-JVWJDHDB.js} +13 -4
  33. package/dist/chunk-JVWJDHDB.js.map +1 -0
  34. package/dist/{chunk-YN7USLHW.js → chunk-K7HSRLP5.js} +11 -10
  35. package/dist/chunk-K7HSRLP5.js.map +1 -0
  36. package/dist/chunk-KIL5CUN6.js +31 -0
  37. package/dist/chunk-KIL5CUN6.js.map +1 -0
  38. package/dist/chunk-KKGM42RQ.cjs +1207 -0
  39. package/dist/chunk-KKGM42RQ.cjs.map +1 -0
  40. package/dist/{chunk-6YGUN7IY.cjs → chunk-MOO75VE4.cjs} +18 -17
  41. package/dist/chunk-MOO75VE4.cjs.map +1 -0
  42. package/dist/{chunk-GML3FBOT.cjs → chunk-NCSMD3TK.cjs} +2 -2
  43. package/dist/chunk-NCSMD3TK.cjs.map +1 -0
  44. package/dist/{chunk-CMNGGTQL.cjs → chunk-NXLRY2CE.cjs} +13 -4
  45. package/dist/chunk-NXLRY2CE.cjs.map +1 -0
  46. package/dist/{chunk-BJ2XPN77.js → chunk-OM4OSBOP.js} +5 -5
  47. package/dist/{chunk-BJ2XPN77.js.map → chunk-OM4OSBOP.js.map} +1 -1
  48. package/dist/{chunk-HPUGKUMZ.js → chunk-PMRWMRXY.js} +13 -640
  49. package/dist/chunk-PMRWMRXY.js.map +1 -0
  50. package/dist/{chunk-UTZR7P7E.cjs → chunk-QPH5ZKP5.cjs} +43 -673
  51. package/dist/chunk-QPH5ZKP5.cjs.map +1 -0
  52. package/dist/chunk-SEO6NAQT.js +14 -0
  53. package/dist/chunk-SEO6NAQT.js.map +1 -0
  54. package/dist/{chunk-QC5MNKVF.js → chunk-TFRZOUTV.js} +13 -12
  55. package/dist/chunk-TFRZOUTV.js.map +1 -0
  56. package/dist/chunk-VQTCQKHQ.cjs +17 -0
  57. package/dist/chunk-VQTCQKHQ.cjs.map +1 -0
  58. package/dist/chunk-Z7VAOK5X.js +1183 -0
  59. package/dist/chunk-Z7VAOK5X.js.map +1 -0
  60. package/dist/{chunk-W35FVJBC.js → chunk-ZDPIWKWD.js} +9 -5
  61. package/dist/chunk-ZDPIWKWD.js.map +1 -0
  62. package/dist/correlation-id.cjs +22 -10
  63. package/dist/correlation-id.js +14 -2
  64. package/dist/decorators.cjs +7 -8
  65. package/dist/decorators.cjs.map +1 -1
  66. package/dist/decorators.d.cts +1 -1
  67. package/dist/decorators.d.ts +1 -1
  68. package/dist/decorators.js +6 -7
  69. package/dist/decorators.js.map +1 -1
  70. package/dist/event.cjs +8 -9
  71. package/dist/event.js +5 -6
  72. package/dist/functional.cjs +13 -14
  73. package/dist/functional.d.cts +1 -1
  74. package/dist/functional.d.ts +1 -1
  75. package/dist/functional.js +6 -7
  76. package/dist/http.cjs +13 -2
  77. package/dist/http.cjs.map +1 -1
  78. package/dist/http.js +12 -1
  79. package/dist/http.js.map +1 -1
  80. package/dist/index.cjs +305 -280
  81. package/dist/index.cjs.map +1 -1
  82. package/dist/index.d.cts +89 -10
  83. package/dist/index.d.ts +89 -10
  84. package/dist/index.js +180 -181
  85. package/dist/index.js.map +1 -1
  86. package/dist/instrumentation.cjs +9 -9
  87. package/dist/instrumentation.js +2 -2
  88. package/dist/messaging-adapters.d.cts +1 -1
  89. package/dist/messaging-adapters.d.ts +1 -1
  90. package/dist/messaging-testing.d.cts +1 -1
  91. package/dist/messaging-testing.d.ts +1 -1
  92. package/dist/messaging.cjs +11 -11
  93. package/dist/messaging.d.cts +1 -1
  94. package/dist/messaging.d.ts +1 -1
  95. package/dist/messaging.js +8 -8
  96. package/dist/semantic-helpers.cjs +11 -12
  97. package/dist/semantic-helpers.d.cts +1 -1
  98. package/dist/semantic-helpers.d.ts +1 -1
  99. package/dist/semantic-helpers.js +7 -8
  100. package/dist/{trace-context-t5X1AP-e.d.cts → trace-context-DbGKd1Rn.d.cts} +18 -5
  101. package/dist/{trace-context-t5X1AP-e.d.ts → trace-context-DbGKd1Rn.d.ts} +18 -5
  102. package/dist/trace-helpers.cjs +13 -13
  103. package/dist/trace-helpers.d.cts +2 -2
  104. package/dist/trace-helpers.d.ts +2 -2
  105. package/dist/trace-helpers.js +1 -1
  106. package/dist/{utils-CbUkl8r1.d.cts → utils-BahBCFtJ.d.cts} +1 -1
  107. package/dist/{utils-Buel3cj0.d.ts → utils-CLKwaUlG.d.ts} +1 -1
  108. package/dist/webhook.cjs +21 -12
  109. package/dist/webhook.cjs.map +1 -1
  110. package/dist/webhook.d.cts +1 -1
  111. package/dist/webhook.d.ts +1 -1
  112. package/dist/webhook.js +20 -11
  113. package/dist/webhook.js.map +1 -1
  114. package/dist/workflow-distributed.cjs +25 -21
  115. package/dist/workflow-distributed.cjs.map +1 -1
  116. package/dist/workflow-distributed.d.cts +1 -1
  117. package/dist/workflow-distributed.d.ts +1 -1
  118. package/dist/workflow-distributed.js +23 -19
  119. package/dist/workflow-distributed.js.map +1 -1
  120. package/dist/workflow.cjs +12 -12
  121. package/dist/workflow.d.cts +1 -1
  122. package/dist/workflow.d.ts +1 -1
  123. package/dist/workflow.js +8 -8
  124. package/package.json +43 -45
  125. package/skills/analyze-traces/SKILL.md +178 -0
  126. package/skills/autotel-core/SKILL.md +2 -7
  127. package/skills/autotel-events/SKILL.md +2 -6
  128. package/skills/autotel-frameworks/SKILL.md +2 -9
  129. package/skills/autotel-instrumentation/SKILL.md +2 -7
  130. package/skills/autotel-request-logging/SKILL.md +2 -8
  131. package/skills/autotel-structured-errors/SKILL.md +2 -7
  132. package/skills/build-audit-trails/SKILL.md +302 -0
  133. package/skills/debug-missing-spans/SKILL.md +248 -0
  134. package/skills/migrate-to-autotel/SKILL.md +268 -0
  135. package/skills/review-otel-patterns/SKILL.md +488 -0
  136. package/skills/review-otel-patterns/references/code-review.md +75 -0
  137. package/skills/review-otel-patterns/references/processor-pipeline.md +205 -0
  138. package/skills/review-otel-patterns/references/structured-errors.md +102 -0
  139. package/skills/review-otel-patterns/references/wide-spans.md +85 -0
  140. package/skills/tune-sampling/SKILL.md +210 -0
  141. package/src/attribute-redacting-processor.test.ts +6 -4
  142. package/src/attribute-redacting-processor.ts +11 -2
  143. package/src/correlated-events.test.ts +151 -0
  144. package/src/correlated-events.ts +47 -0
  145. package/src/drain-toolkit.test.ts +113 -0
  146. package/src/drain-toolkit.ts +129 -0
  147. package/src/enricher-toolkit.test.ts +67 -0
  148. package/src/enricher-toolkit.ts +79 -0
  149. package/src/functional.ts +2 -0
  150. package/src/gen-ai-events.ts +14 -5
  151. package/src/index.ts +39 -4
  152. package/src/messaging.ts +10 -9
  153. package/src/redact-values.test.ts +24 -10
  154. package/src/redact-values.ts +9 -2
  155. package/src/request-logger.test.ts +91 -0
  156. package/src/request-logger.ts +40 -5
  157. package/src/structured-error.test.ts +86 -1
  158. package/src/structured-error.ts +9 -2
  159. package/src/trace-context.ts +39 -11
  160. package/src/trace-helpers.ts +2 -2
  161. package/src/trace-hybrid.test.ts +42 -0
  162. package/src/trace-hybrid.ts +37 -0
  163. package/src/webhook.ts +16 -7
  164. package/src/workflow-distributed.ts +18 -13
  165. package/src/workflow.ts +7 -6
  166. package/bin/intent.js +0 -6
  167. package/dist/chunk-563EL6O6.cjs.map +0 -1
  168. package/dist/chunk-6YGUN7IY.cjs.map +0 -1
  169. package/dist/chunk-B3ZHLLMP.js.map +0 -1
  170. package/dist/chunk-BBBWDIYQ.js +0 -211
  171. package/dist/chunk-BBBWDIYQ.js.map +0 -1
  172. package/dist/chunk-CMNGGTQL.cjs.map +0 -1
  173. package/dist/chunk-D5LMF53P.cjs +0 -150
  174. package/dist/chunk-D5LMF53P.cjs.map +0 -1
  175. package/dist/chunk-GML3FBOT.cjs.map +0 -1
  176. package/dist/chunk-HPUGKUMZ.js.map +0 -1
  177. package/dist/chunk-HZ3FYBJG.cjs +0 -217
  178. package/dist/chunk-HZ3FYBJG.cjs.map +0 -1
  179. package/dist/chunk-JSNUWSBH.cjs +0 -62
  180. package/dist/chunk-JSNUWSBH.cjs.map +0 -1
  181. package/dist/chunk-OBWXM4NN.cjs.map +0 -1
  182. package/dist/chunk-QC5MNKVF.js.map +0 -1
  183. package/dist/chunk-S4OFEXLA.js +0 -53
  184. package/dist/chunk-S4OFEXLA.js.map +0 -1
  185. package/dist/chunk-TDNKIHKT.js.map +0 -1
  186. package/dist/chunk-UTZR7P7E.cjs.map +0 -1
  187. package/dist/chunk-W35FVJBC.js.map +0 -1
  188. package/dist/chunk-WD4RP6IV.js +0 -146
  189. package/dist/chunk-WD4RP6IV.js.map +0 -1
  190. package/dist/chunk-YN7USLHW.js.map +0 -1
  191. package/src/package-manifest.test.ts +0 -24
@@ -1,642 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkGML3FBOT_cjs = require('./chunk-GML3FBOT.cjs');
4
- var chunkD5LMF53P_cjs = require('./chunk-D5LMF53P.cjs');
5
- var chunkJSNUWSBH_cjs = require('./chunk-JSNUWSBH.cjs');
6
- var chunkHZ3FYBJG_cjs = require('./chunk-HZ3FYBJG.cjs');
7
- var chunk563EL6O6_cjs = require('./chunk-563EL6O6.cjs');
3
+ var chunkNCSMD3TK_cjs = require('./chunk-NCSMD3TK.cjs');
4
+ var chunkVQTCQKHQ_cjs = require('./chunk-VQTCQKHQ.cjs');
5
+ var chunkKKGM42RQ_cjs = require('./chunk-KKGM42RQ.cjs');
6
+ var chunkBPO2PQ3T_cjs = require('./chunk-BPO2PQ3T.cjs');
8
7
  var chunkVH77IPJN_cjs = require('./chunk-VH77IPJN.cjs');
9
8
  var chunkESLWRGAG_cjs = require('./chunk-ESLWRGAG.cjs');
10
9
  var api = require('@opentelemetry/api');
11
10
  var fs = require('fs');
12
11
  var url = require('url');
13
12
 
14
- // src/rate-limiter.ts
15
- var TokenBucketRateLimiter = class {
16
- tokens;
17
- maxTokens;
18
- refillRate;
19
- // tokens per millisecond
20
- lastRefill;
21
- constructor(config) {
22
- this.maxTokens = config.burstCapacity || config.maxEventsPerSecond * 2;
23
- this.tokens = this.maxTokens;
24
- this.refillRate = config.maxEventsPerSecond / 1e3;
25
- this.lastRefill = Date.now();
26
- }
27
- /**
28
- * Try to consume a token (allow an event)
29
- * Returns true if allowed, false if rate limit exceeded
30
- */
31
- tryConsume(count = 1) {
32
- this.refill();
33
- if (this.tokens >= count) {
34
- this.tokens -= count;
35
- return true;
36
- }
37
- return false;
38
- }
39
- /**
40
- * Wait until a token is available (async rate limiting)
41
- * Returns a promise that resolves when the event can be processed
42
- */
43
- async waitForToken(count = 1) {
44
- this.refill();
45
- if (this.tokens >= count) {
46
- this.tokens -= count;
47
- return;
48
- }
49
- const tokensNeeded = count - this.tokens;
50
- const waitMs = Math.ceil(tokensNeeded / this.refillRate);
51
- await new Promise((resolve) => setTimeout(resolve, waitMs));
52
- return this.waitForToken(count);
53
- }
54
- /**
55
- * Refill tokens based on elapsed time
56
- */
57
- refill() {
58
- const now = Date.now();
59
- const elapsed = now - this.lastRefill;
60
- const tokensToAdd = elapsed * this.refillRate;
61
- this.tokens = Math.min(this.maxTokens, this.tokens + tokensToAdd);
62
- this.lastRefill = now;
63
- }
64
- /**
65
- * Get current available tokens (for testing/debugging)
66
- */
67
- getAvailableTokens() {
68
- this.refill();
69
- return Math.floor(this.tokens);
70
- }
71
- /**
72
- * Reset the rate limiter (for testing)
73
- */
74
- reset() {
75
- this.tokens = this.maxTokens;
76
- this.lastRefill = Date.now();
77
- }
78
- };
79
-
80
- // src/event-queue.ts
81
- var DEFAULT_CONFIG = {
82
- maxSize: 5e4,
83
- batchSize: 100,
84
- flushInterval: 1e4,
85
- maxRetries: 3,
86
- rateLimit: {
87
- maxEventsPerSecond: 100,
88
- burstCapacity: 200
89
- }
90
- };
91
- function getSubscriberName(subscriber) {
92
- if (subscriber.name) {
93
- return subscriber.name.toLowerCase();
94
- }
95
- const className = subscriber.constructor?.name || "unknown";
96
- return className.replace(/Subscriber$/i, "").toLowerCase();
97
- }
98
- var EventQueue = class {
99
- queue = [];
100
- flushTimer = null;
101
- config;
102
- subscribers;
103
- rateLimiter;
104
- flushPromise = null;
105
- isShuttingDown = false;
106
- // Metrics
107
- metrics = null;
108
- // Observable callback cleanup functions
109
- observableCleanups = [];
110
- // Subscriber health tracking (for observable gauges)
111
- subscriberHealthy = /* @__PURE__ */ new Map();
112
- constructor(subscribers, config) {
113
- this.subscribers = subscribers;
114
- this.config = { ...DEFAULT_CONFIG, ...config };
115
- this.rateLimiter = this.config.rateLimit ? new TokenBucketRateLimiter(this.config.rateLimit) : null;
116
- for (const subscriber of subscribers) {
117
- const name = getSubscriberName(subscriber);
118
- this.subscriberHealthy.set(name, true);
119
- }
120
- this.initMetrics();
121
- }
122
- /**
123
- * Initialize OTel metrics for queue observability
124
- */
125
- initMetrics() {
126
- const runtimeConfig = chunkESLWRGAG_cjs.getConfig();
127
- const meter = runtimeConfig.meter;
128
- const queueSize = meter.createObservableGauge(
129
- "autotel.event_delivery.queue.size",
130
- {
131
- description: "Current number of events in the delivery queue",
132
- unit: "count"
133
- }
134
- );
135
- const queueSizeCallback = (observableResult) => {
136
- observableResult.observe(this.queue.length);
137
- };
138
- queueSize.addCallback(queueSizeCallback);
139
- this.observableCleanups.push(
140
- () => queueSize.removeCallback(queueSizeCallback)
141
- );
142
- const oldestAge = meter.createObservableGauge(
143
- "autotel.event_delivery.queue.oldest_age_ms",
144
- {
145
- description: "Age of the oldest event in the queue in milliseconds",
146
- unit: "ms"
147
- }
148
- );
149
- const oldestAgeCallback = (observableResult) => {
150
- if (this.queue.length > 0) {
151
- const oldest = this.queue[0];
152
- const ageMs = Date.now() - oldest.timestamp;
153
- observableResult.observe(ageMs);
154
- } else {
155
- observableResult.observe(0);
156
- }
157
- };
158
- oldestAge.addCallback(oldestAgeCallback);
159
- this.observableCleanups.push(
160
- () => oldestAge.removeCallback(oldestAgeCallback)
161
- );
162
- const delivered = meter.createCounter(
163
- "autotel.event_delivery.queue.delivered",
164
- {
165
- description: "Number of events successfully delivered to subscribers",
166
- unit: "count"
167
- }
168
- );
169
- const failed = meter.createCounter("autotel.event_delivery.queue.failed", {
170
- description: "Number of events that failed delivery after all retry attempts",
171
- unit: "count"
172
- });
173
- const dropped = meter.createCounter(
174
- "autotel.event_delivery.queue.dropped",
175
- {
176
- description: "Number of events dropped from the queue",
177
- unit: "count"
178
- }
179
- );
180
- const latency = meter.createHistogram(
181
- "autotel.event_delivery.queue.latency_ms",
182
- {
183
- description: "Event delivery latency from enqueue to successful send",
184
- unit: "ms"
185
- }
186
- );
187
- const subscriberHealth = meter.createObservableGauge(
188
- "autotel.event_delivery.subscriber.health",
189
- {
190
- description: "Subscriber health status (1=healthy, 0=unhealthy)",
191
- unit: "1"
192
- }
193
- );
194
- const subscriberHealthCallback = (observableResult) => {
195
- for (const [subscriberName, isHealthy] of this.subscriberHealthy) {
196
- observableResult.observe(isHealthy ? 1 : 0, {
197
- subscriber: subscriberName
198
- });
199
- }
200
- };
201
- subscriberHealth.addCallback(subscriberHealthCallback);
202
- this.observableCleanups.push(
203
- () => subscriberHealth.removeCallback(subscriberHealthCallback)
204
- );
205
- this.metrics = {
206
- queueSize,
207
- oldestAge,
208
- delivered,
209
- failed,
210
- dropped,
211
- latency,
212
- subscriberHealth
213
- };
214
- }
215
- /**
216
- * Record a dropped event with reason and emit debug breadcrumb
217
- */
218
- recordDropped(reason, event, subscriberName) {
219
- const attrs = { reason };
220
- if (subscriberName) {
221
- attrs.subscriber = subscriberName;
222
- }
223
- this.metrics?.dropped.add(1, attrs);
224
- const logLevel = reason === "payload_invalid" ? "error" : "warn";
225
- const logger = chunk563EL6O6_cjs.getLogger();
226
- if (logLevel === "error") {
227
- logger.error(
228
- {
229
- eventName: event?.name,
230
- subscriber: subscriberName,
231
- reason,
232
- correlationId: event?._correlationId,
233
- traceId: event?._traceId
234
- },
235
- `[autotel] Event dropped: ${reason}`
236
- );
237
- } else {
238
- logger.warn(
239
- {
240
- eventName: event?.name,
241
- subscriber: subscriberName,
242
- reason,
243
- correlationId: event?._correlationId,
244
- traceId: event?._traceId
245
- },
246
- `[autotel] Event dropped: ${reason}`
247
- );
248
- }
249
- }
250
- /**
251
- * Record permanent delivery failure (after all retries exhausted)
252
- * Increments failed counter and logs error
253
- */
254
- recordFailed(event, subscriberName, error) {
255
- this.metrics?.failed.add(1, { subscriber: subscriberName });
256
- this.subscriberHealthy.set(subscriberName, false);
257
- chunk563EL6O6_cjs.getLogger().error(
258
- {
259
- eventName: event.name,
260
- subscriber: subscriberName,
261
- correlationId: event._correlationId,
262
- traceId: event._traceId,
263
- err: error
264
- },
265
- `[autotel] Event delivery failed after all retries`
266
- );
267
- }
268
- /**
269
- * Mark subscriber as unhealthy on transient failure (without incrementing failed counter)
270
- * Used during retry attempts - only recordFailed should increment the counter
271
- */
272
- markSubscriberUnhealthy(subscriberName) {
273
- this.subscriberHealthy.set(subscriberName, false);
274
- }
275
- /**
276
- * Record successful delivery
277
- */
278
- recordDelivered(event, subscriberName, startTime) {
279
- const latencyMs = Date.now() - startTime;
280
- this.metrics?.delivered.add(1, { subscriber: subscriberName });
281
- this.metrics?.latency.record(latencyMs, { subscriber: subscriberName });
282
- this.subscriberHealthy.set(subscriberName, true);
283
- }
284
- /**
285
- * Enqueue an event for sending
286
- *
287
- * Backpressure policy:
288
- * - Drops oldest event and logs warning if queue is full (same behavior in all environments)
289
- */
290
- enqueue(event) {
291
- if (this.isShuttingDown) {
292
- this.recordDropped("shutdown", event);
293
- return;
294
- }
295
- if (this.queue.length >= this.config.maxSize) {
296
- const droppedEvent = this.queue.shift();
297
- this.recordDropped("rate_limit", droppedEvent);
298
- chunk563EL6O6_cjs.getLogger().warn(
299
- {
300
- droppedEvent: droppedEvent?.name
301
- },
302
- `[autotel] Events queue full (${this.config.maxSize} events). Dropping oldest event. Events are being produced faster than they can be sent. Check your subscribers or reduce tracking frequency.`
303
- );
304
- }
305
- const enrichedEvent = {
306
- ...event,
307
- _correlationId: event._correlationId || chunkJSNUWSBH_cjs.getOrCreateCorrelationId()
308
- };
309
- this.queue.push(enrichedEvent);
310
- this.scheduleBatchFlush();
311
- }
312
- /**
313
- * Schedule a batch flush if not already scheduled
314
- */
315
- scheduleBatchFlush() {
316
- if (this.flushTimer || this.flushPromise) return;
317
- this.flushTimer = setTimeout(() => {
318
- this.flushTimer = null;
319
- void this.flushBatch();
320
- }, this.config.flushInterval);
321
- }
322
- /**
323
- * Flush a batch of events
324
- * Uses promise-based concurrency control to prevent race conditions
325
- */
326
- async flushBatch() {
327
- if (this.queue.length === 0) return;
328
- if (this.flushPromise) {
329
- await this.flushPromise;
330
- return;
331
- }
332
- this.flushPromise = this.doFlushBatch();
333
- try {
334
- await this.flushPromise;
335
- } finally {
336
- this.flushPromise = null;
337
- if (this.queue.length > 0) {
338
- this.scheduleBatchFlush();
339
- }
340
- }
341
- }
342
- /**
343
- * Internal flush implementation
344
- */
345
- async doFlushBatch() {
346
- const batch = this.queue.splice(0, this.config.batchSize);
347
- await this.sendWithRetry(batch, this.config.maxRetries);
348
- }
349
- /**
350
- * Send events with exponential backoff retry
351
- * Tracks per-event, per-subscriber failures so failed counter reflects actual failed deliveries.
352
- * On retry, only failed (event, subscriber) pairs are re-sent to avoid double-counting delivered.
353
- */
354
- async sendWithRetry(events, retriesLeft, subscribersByEventIndex) {
355
- const failedDeliveries = await this.sendToSubscribers(
356
- events,
357
- subscribersByEventIndex
358
- );
359
- if (failedDeliveries.length > 0) {
360
- if (retriesLeft > 0) {
361
- const failedEventIndices = new Set(
362
- failedDeliveries.map((f) => f.eventIndex)
363
- );
364
- const failedEventIndicesOrdered = [...failedEventIndices].sort(
365
- (a, b) => a - b
366
- );
367
- const eventsToRetry = failedEventIndicesOrdered.map(
368
- (i) => events[i]
369
- );
370
- const failedSubscribersByRetryIndex = /* @__PURE__ */ new Map();
371
- for (let j = 0; j < failedEventIndicesOrdered.length; j++) {
372
- const origIndex = failedEventIndicesOrdered[j];
373
- const set = /* @__PURE__ */ new Set();
374
- for (const { eventIndex, subscriberName } of failedDeliveries) {
375
- if (eventIndex === origIndex) set.add(subscriberName);
376
- }
377
- failedSubscribersByRetryIndex.set(j, set);
378
- }
379
- const delay = Math.pow(2, this.config.maxRetries - retriesLeft) * 1e3;
380
- await new Promise((resolve) => setTimeout(resolve, delay));
381
- return this.sendWithRetry(
382
- eventsToRetry,
383
- retriesLeft - 1,
384
- failedSubscribersByRetryIndex
385
- );
386
- } else {
387
- for (const { eventIndex, subscriberName, error } of failedDeliveries) {
388
- const event = events[eventIndex];
389
- if (event) this.recordFailed(event, subscriberName, error);
390
- }
391
- const failedSubscriberNames = [
392
- ...new Set(failedDeliveries.map((f) => f.subscriberName))
393
- ];
394
- chunk563EL6O6_cjs.getLogger().error(
395
- {
396
- failedSubscribers: failedSubscriberNames,
397
- retriesAttempted: this.config.maxRetries
398
- },
399
- "[autotel] Failed to send events after retries"
400
- );
401
- }
402
- }
403
- }
404
- /**
405
- * Send events to configured subscribers with rate limiting and metrics.
406
- * When subscribersByEventIndex is provided (retry path), only those subscribers are tried per event.
407
- * Returns per-event, per-subscriber failures (empty if all succeeded).
408
- */
409
- async sendToSubscribers(events, subscribersByEventIndex) {
410
- const failedDeliveries = [];
411
- const sendOne = async (event, eventIndex) => {
412
- const subscriberNames = subscribersByEventIndex?.get(eventIndex);
413
- const failures = await this.sendEventToSubscribers(
414
- event,
415
- subscriberNames ?? void 0
416
- );
417
- for (const failure of failures) {
418
- failedDeliveries.push({
419
- eventIndex,
420
- subscriberName: failure.subscriberName,
421
- error: failure.error
422
- });
423
- }
424
- };
425
- if (!this.rateLimiter) {
426
- for (let i = 0; i < events.length; i++) {
427
- const event = events[i];
428
- if (event) await sendOne(event, i);
429
- }
430
- return failedDeliveries;
431
- }
432
- for (let i = 0; i < events.length; i++) {
433
- await this.rateLimiter.waitForToken();
434
- const event = events[i];
435
- if (event) await sendOne(event, i);
436
- }
437
- return failedDeliveries;
438
- }
439
- /**
440
- * Send a single event to subscribers.
441
- * - When subscriberNames is undefined (initial attempt): send to all subscribers.
442
- * - When subscriberNames is provided (retry): send only to those subscribers (never re-send to healthy ones).
443
- * Returns list of subscribers that failed (empty if all succeeded).
444
- */
445
- async sendEventToSubscribers(event, subscriberNames) {
446
- const startTime = event.timestamp;
447
- const failures = [];
448
- const subscribersToTry = subscriberNames === void 0 ? this.subscribers : this.subscribers.filter(
449
- (s) => subscriberNames.has(getSubscriberName(s))
450
- );
451
- const results = await Promise.allSettled(
452
- subscribersToTry.map(async (subscriber) => {
453
- const subscriberName = getSubscriberName(subscriber);
454
- try {
455
- await subscriber.trackEvent(event.name, event.attributes, {
456
- autotel: event.autotel
457
- });
458
- this.recordDelivered(event, subscriberName, startTime);
459
- return { subscriberName, success: true };
460
- } catch (error) {
461
- this.markSubscriberUnhealthy(subscriberName);
462
- return {
463
- subscriberName,
464
- success: false,
465
- error: error instanceof Error ? error : void 0
466
- };
467
- }
468
- })
469
- );
470
- for (const result of results) {
471
- if (result.status === "fulfilled" && !result.value.success) {
472
- failures.push({
473
- subscriberName: result.value.subscriberName,
474
- error: result.value.error
475
- });
476
- }
477
- }
478
- return failures;
479
- }
480
- /**
481
- * Flush all remaining events. Queue remains usable after flush (e.g. for
482
- * auto-flush at root span end). Use shutdown() when tearing down the queue.
483
- */
484
- async flush() {
485
- if (this.flushTimer) {
486
- clearTimeout(this.flushTimer);
487
- this.flushTimer = null;
488
- }
489
- if (this.flushPromise) {
490
- await this.flushPromise;
491
- }
492
- while (this.queue.length > 0) {
493
- await this.doFlushBatch();
494
- }
495
- }
496
- /**
497
- * Flush remaining events and permanently disable the queue (reject new events).
498
- * Use for process/SDK shutdown; use flush() for periodic or span-end drain.
499
- */
500
- async shutdown() {
501
- this.isShuttingDown = true;
502
- await this.flush();
503
- }
504
- /**
505
- * Cleanup observable metric callbacks to prevent memory leaks
506
- * Call this when destroying the EventQueue instance
507
- */
508
- cleanup() {
509
- for (const cleanupFn of this.observableCleanups) {
510
- try {
511
- cleanupFn();
512
- } catch {
513
- }
514
- }
515
- this.observableCleanups = [];
516
- }
517
- /**
518
- * Get queue size (for testing/debugging)
519
- */
520
- size() {
521
- return this.queue.length;
522
- }
523
- /**
524
- * Get subscriber health status (for testing/debugging)
525
- */
526
- getSubscriberHealth() {
527
- return new Map(this.subscriberHealthy);
528
- }
529
- /**
530
- * Check if a specific subscriber is healthy
531
- */
532
- isSubscriberHealthy(subscriberName) {
533
- return this.subscriberHealthy.get(subscriberName.toLowerCase()) ?? true;
534
- }
535
- /**
536
- * Manually mark a subscriber as healthy or unhealthy
537
- * (used for circuit breaker integration)
538
- */
539
- setSubscriberHealth(subscriberName, healthy) {
540
- this.subscriberHealthy.set(subscriberName.toLowerCase(), healthy);
541
- }
542
- };
543
-
544
- // src/track.ts
545
- var eventsQueue = null;
546
- function buildAutotelContext(span2) {
547
- const eventsConfig = chunk563EL6O6_cjs.getEventsConfig();
548
- const config = chunk563EL6O6_cjs.getConfig();
549
- const correlationId = chunkJSNUWSBH_cjs.getOrCreateCorrelationId();
550
- if (!eventsConfig?.includeTraceContext) {
551
- return {
552
- correlation_id: correlationId
553
- };
554
- }
555
- const autotelContext = {
556
- correlation_id: correlationId
557
- };
558
- const spanContext = span2?.spanContext();
559
- if (spanContext) {
560
- autotelContext.trace_id = spanContext.traceId;
561
- autotelContext.span_id = spanContext.spanId;
562
- autotelContext.trace_flags = spanContext.traceFlags.toString(16).padStart(2, "0");
563
- const traceState = spanContext.traceState;
564
- if (traceState) {
565
- try {
566
- if (typeof traceState.serialize === "function") {
567
- const traceStateStr = traceState.serialize();
568
- if (traceStateStr) {
569
- autotelContext.trace_state = traceStateStr;
570
- }
571
- }
572
- } catch {
573
- }
574
- }
575
- if (eventsConfig.traceUrl && config) {
576
- const traceUrl = eventsConfig.traceUrl({
577
- traceId: spanContext.traceId,
578
- spanId: spanContext.spanId,
579
- correlationId,
580
- serviceName: config.service,
581
- environment: config.environment
582
- });
583
- if (traceUrl) {
584
- autotelContext.trace_url = traceUrl;
585
- }
586
- }
587
- } else {
588
- if (eventsConfig.traceUrl && config) {
589
- const traceUrl = eventsConfig.traceUrl({
590
- correlationId,
591
- serviceName: config.service,
592
- environment: config.environment
593
- });
594
- if (traceUrl) {
595
- autotelContext.trace_url = traceUrl;
596
- }
597
- }
598
- }
599
- return autotelContext;
600
- }
601
- function getOrCreateQueue() {
602
- if (!chunk563EL6O6_cjs.isInitialized()) {
603
- chunk563EL6O6_cjs.warnIfNotInitialized("track()");
604
- return null;
605
- }
606
- if (!eventsQueue) {
607
- const config = chunk563EL6O6_cjs.getConfig();
608
- if (!config?.subscribers || config.subscribers.length === 0) {
609
- return null;
610
- }
611
- eventsQueue = new EventQueue(config.subscribers);
612
- }
613
- return eventsQueue;
614
- }
615
- function track(event, data) {
616
- const queue = getOrCreateQueue();
617
- if (!queue) return;
618
- const validationConfig = chunk563EL6O6_cjs.getValidationConfig();
619
- const validated = chunkD5LMF53P_cjs.validateEvent(event, data, validationConfig || void 0);
620
- const span2 = api.trace.getActiveSpan();
621
- const enrichedData = span2 ? {
622
- ...validated.attributes,
623
- traceId: span2.spanContext().traceId,
624
- spanId: span2.spanContext().spanId
625
- } : validated.attributes;
626
- const autotelContext = buildAutotelContext(span2);
627
- queue.enqueue({
628
- name: validated.eventName,
629
- attributes: enrichedData,
630
- timestamp: Date.now(),
631
- autotel: autotelContext
632
- });
633
- }
634
- function getEventQueue() {
635
- return eventsQueue;
636
- }
637
- function resetEventQueue() {
638
- eventsQueue = null;
639
- }
640
13
  var inferenceCache = /* @__PURE__ */ new Map();
641
14
  var MAX_CACHE_SIZE = 50;
642
15
  function captureStackTrace() {
@@ -969,7 +342,7 @@ function shouldSkip(key, fn, skip) {
969
342
  function getCtxValue() {
970
343
  const activeSpan = api.trace.getActiveSpan();
971
344
  if (!activeSpan) return null;
972
- return chunkHZ3FYBJG_cjs.createTraceContext(activeSpan);
345
+ return chunkKKGM42RQ_cjs.createTraceContext(activeSpan);
973
346
  }
974
347
  var ctx = new Proxy(
975
348
  {},
@@ -1034,17 +407,17 @@ function wrapWithTracing(fnFactory, options, variableName) {
1034
407
  }
1035
408
  const startTime = performance.now();
1036
409
  const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
1037
- const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunk563EL6O6_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
1038
- const shouldAutoFlushSpans = chunk563EL6O6_cjs.getConfig()?.forceFlushOnShutdown ?? false;
410
+ const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkBPO2PQ3T_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
411
+ const shouldAutoFlushSpans = chunkBPO2PQ3T_cjs.getConfig()?.forceFlushOnShutdown ?? false;
1039
412
  const flushIfNeeded = async () => {
1040
413
  if (!shouldAutoFlush || !isRootSpan) return;
1041
414
  try {
1042
- const queue = getEventQueue();
415
+ const queue = chunkKKGM42RQ_cjs.getEventQueue();
1043
416
  if (queue && queue.size() > 0) {
1044
417
  await queue.flush();
1045
418
  }
1046
419
  if (shouldAutoFlushSpans) {
1047
- const sdk = chunk563EL6O6_cjs.getSdk();
420
+ const sdk = chunkBPO2PQ3T_cjs.getSdk();
1048
421
  if (sdk) {
1049
422
  try {
1050
423
  const sdkAny = sdk;
@@ -1059,7 +432,7 @@ function wrapWithTracing(fnFactory, options, variableName) {
1059
432
  }
1060
433
  }
1061
434
  } catch (error) {
1062
- const initConfig = chunk563EL6O6_cjs.getConfig();
435
+ const initConfig = chunkBPO2PQ3T_cjs.getConfig();
1063
436
  const logger = initConfig?.logger;
1064
437
  if (logger?.error) {
1065
438
  logger.error(
@@ -1078,21 +451,21 @@ function wrapWithTracing(fnFactory, options, variableName) {
1078
451
  if (options.spanKind !== void 0) {
1079
452
  spanOptions.kind = options.spanKind;
1080
453
  }
1081
- const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
454
+ const parentContext = chunkKKGM42RQ_cjs.getActiveContextWithBaggage();
1082
455
  return tracer.startActiveSpan(
1083
456
  spanName,
1084
457
  spanOptions,
1085
458
  parentContext,
1086
459
  async (span2) => {
1087
- return chunkD5LMF53P_cjs.runInOperationContext(spanName, async () => {
460
+ return chunkVQTCQKHQ_cjs.runInOperationContext(spanName, async () => {
1088
461
  let shouldKeepSpan = true;
1089
- chunkGML3FBOT_cjs.setSpanName(span2, spanName);
462
+ chunkNCSMD3TK_cjs.setSpanName(span2, spanName);
1090
463
  const initialContext = api.context.active();
1091
- const contextStorage = chunkHZ3FYBJG_cjs.getContextStorage();
464
+ const contextStorage = chunkKKGM42RQ_cjs.getContextStorage();
1092
465
  if (!contextStorage.getStore()) {
1093
- chunkHZ3FYBJG_cjs.enterOrRun(contextStorage, initialContext);
466
+ chunkKKGM42RQ_cjs.enterOrRun(contextStorage, initialContext);
1094
467
  }
1095
- const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
468
+ const ctxValue = chunkKKGM42RQ_cjs.createTraceContext(span2);
1096
469
  const fn = fnFactory(ctxValue);
1097
470
  const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
1098
471
  const handleTailSampling = (success, duration, error) => {
@@ -1177,7 +550,7 @@ function wrapWithTracing(fnFactory, options, variableName) {
1177
550
  status: "started"
1178
551
  });
1179
552
  const executeWithContext = async () => {
1180
- const currentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
553
+ const currentContext = chunkKKGM42RQ_cjs.getActiveContextWithBaggage();
1181
554
  return api.context.with(currentContext, async () => {
1182
555
  return fn.call(this, ...args);
1183
556
  });
@@ -1229,14 +602,14 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
1229
602
  }
1230
603
  const startTime = performance.now();
1231
604
  const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
1232
- const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunk563EL6O6_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
1233
- const shouldAutoFlushSpans = chunk563EL6O6_cjs.getConfig()?.forceFlushOnShutdown ?? false;
605
+ const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkBPO2PQ3T_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
606
+ const shouldAutoFlushSpans = chunkBPO2PQ3T_cjs.getConfig()?.forceFlushOnShutdown ?? false;
1234
607
  const flushIfNeeded = () => {
1235
608
  if (!shouldAutoFlush || !isRootSpan) return;
1236
- const queue = getEventQueue();
609
+ const queue = chunkKKGM42RQ_cjs.getEventQueue();
1237
610
  if (queue && queue.size() > 0) {
1238
611
  void queue.flush().catch((error) => {
1239
- const initConfig = chunk563EL6O6_cjs.getConfig();
612
+ const initConfig = chunkBPO2PQ3T_cjs.getConfig();
1240
613
  const logger = initConfig?.logger;
1241
614
  if (logger?.error) {
1242
615
  logger.error(
@@ -1249,7 +622,7 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
1249
622
  });
1250
623
  }
1251
624
  if (shouldAutoFlushSpans) {
1252
- const sdk = chunk563EL6O6_cjs.getSdk();
625
+ const sdk = chunkBPO2PQ3T_cjs.getSdk();
1253
626
  if (sdk) {
1254
627
  try {
1255
628
  const sdkAny = sdk;
@@ -1257,7 +630,7 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
1257
630
  const tracerProvider = sdkAny.getTracerProvider();
1258
631
  if (tracerProvider && typeof tracerProvider.forceFlush === "function") {
1259
632
  void tracerProvider.forceFlush().catch((error) => {
1260
- const initConfig = chunk563EL6O6_cjs.getConfig();
633
+ const initConfig = chunkBPO2PQ3T_cjs.getConfig();
1261
634
  const logger = initConfig?.logger;
1262
635
  if (logger?.error) {
1263
636
  logger.error(
@@ -1282,16 +655,16 @@ function wrapWithTracingSync(fnFactory, options, variableName) {
1282
655
  if (options.spanKind !== void 0) {
1283
656
  spanOptions.kind = options.spanKind;
1284
657
  }
1285
- const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
658
+ const parentContext = chunkKKGM42RQ_cjs.getActiveContextWithBaggage();
1286
659
  return tracer.startActiveSpan(
1287
660
  spanName,
1288
661
  spanOptions,
1289
662
  parentContext,
1290
663
  (span2) => {
1291
- return chunkD5LMF53P_cjs.runInOperationContext(spanName, () => {
664
+ return chunkVQTCQKHQ_cjs.runInOperationContext(spanName, () => {
1292
665
  let shouldKeepSpan = true;
1293
- chunkGML3FBOT_cjs.setSpanName(span2, spanName);
1294
- const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
666
+ chunkNCSMD3TK_cjs.setSpanName(span2, spanName);
667
+ const ctxValue = chunkKKGM42RQ_cjs.createTraceContext(span2);
1295
668
  const fn = fnFactory(ctxValue);
1296
669
  const argsAttributes = options.attributesFromArgs ? options.attributesFromArgs(args) : {};
1297
670
  const handleTailSampling = (success, duration, error) => {
@@ -1406,8 +779,8 @@ function executeImmediately(fn, options) {
1406
779
  }
1407
780
  const startTime = performance.now();
1408
781
  const isRootSpan = options.startNewRoot || api.trace.getActiveSpan() === void 0;
1409
- const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunk563EL6O6_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
1410
- const shouldAutoFlushSpans = chunk563EL6O6_cjs.getConfig()?.forceFlushOnShutdown ?? false;
782
+ const shouldAutoFlush = options.flushOnRootSpanEnd ?? chunkBPO2PQ3T_cjs.getConfig()?.flushOnRootSpanEnd ?? true;
783
+ const shouldAutoFlushSpans = chunkBPO2PQ3T_cjs.getConfig()?.forceFlushOnShutdown ?? false;
1411
784
  const callCounter = options.withMetrics ? meter.createCounter(`${spanName}.calls`, {
1412
785
  description: `Call count for ${spanName}`,
1413
786
  unit: "1"
@@ -1419,12 +792,12 @@ function executeImmediately(fn, options) {
1419
792
  const flushIfNeeded = async () => {
1420
793
  if (!shouldAutoFlush || !isRootSpan) return;
1421
794
  try {
1422
- const queue = getEventQueue();
795
+ const queue = chunkKKGM42RQ_cjs.getEventQueue();
1423
796
  if (queue && queue.size() > 0) {
1424
797
  await queue.flush();
1425
798
  }
1426
799
  if (shouldAutoFlushSpans) {
1427
- const sdk = chunk563EL6O6_cjs.getSdk();
800
+ const sdk = chunkBPO2PQ3T_cjs.getSdk();
1428
801
  if (sdk) {
1429
802
  try {
1430
803
  const sdkAny = sdk;
@@ -1439,7 +812,7 @@ function executeImmediately(fn, options) {
1439
812
  }
1440
813
  }
1441
814
  } catch (error) {
1442
- const initConfig = chunk563EL6O6_cjs.getConfig();
815
+ const initConfig = chunkBPO2PQ3T_cjs.getConfig();
1443
816
  const logger = initConfig?.logger;
1444
817
  if (logger?.error) {
1445
818
  logger.error(
@@ -1458,16 +831,16 @@ function executeImmediately(fn, options) {
1458
831
  if (options.spanKind !== void 0) {
1459
832
  spanOptions.kind = options.spanKind;
1460
833
  }
1461
- const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
834
+ const parentContext = chunkKKGM42RQ_cjs.getActiveContextWithBaggage();
1462
835
  return tracer.startActiveSpan(
1463
836
  spanName,
1464
837
  spanOptions,
1465
838
  parentContext,
1466
839
  (span2) => {
1467
- return chunkD5LMF53P_cjs.runInOperationContext(spanName, () => {
840
+ return chunkVQTCQKHQ_cjs.runInOperationContext(spanName, () => {
1468
841
  let shouldKeepSpan = true;
1469
- chunkGML3FBOT_cjs.setSpanName(span2, spanName);
1470
- const ctxValue = chunkHZ3FYBJG_cjs.createTraceContext(span2);
842
+ chunkNCSMD3TK_cjs.setSpanName(span2, spanName);
843
+ const ctxValue = chunkKKGM42RQ_cjs.createTraceContext(span2);
1471
844
  const handleTailSampling = (success, duration, error) => {
1472
845
  if (needsTailSampling && "shouldKeepTrace" in sampler && typeof sampler.shouldKeepTrace === "function") {
1473
846
  shouldKeepSpan = sampler.shouldKeepTrace(samplingContext, {
@@ -1618,7 +991,7 @@ function executeImmediately(fn, options) {
1618
991
  }
1619
992
  );
1620
993
  }
1621
- function trace2(fnOrNameOrOptions, maybeFn) {
994
+ function trace(fnOrNameOrOptions, maybeFn) {
1622
995
  if (typeof fnOrNameOrOptions === "function") {
1623
996
  if (looksLikeTraceFactory(fnOrNameOrOptions) && !isFactoryReturningFunction(
1624
997
  fnOrNameOrOptions
@@ -1702,7 +1075,7 @@ function span(options, fn) {
1702
1075
  const tracer = config.tracer;
1703
1076
  const { name, attributes } = options;
1704
1077
  const executeSpan = (span2) => {
1705
- return chunkD5LMF53P_cjs.runInOperationContext(name, () => {
1078
+ return chunkVQTCQKHQ_cjs.runInOperationContext(name, () => {
1706
1079
  try {
1707
1080
  if (attributes) {
1708
1081
  for (const [key, value] of Object.entries(attributes)) {
@@ -1748,7 +1121,7 @@ function span(options, fn) {
1748
1121
  }
1749
1122
  });
1750
1123
  };
1751
- const parentContext = chunkHZ3FYBJG_cjs.getActiveContextWithBaggage();
1124
+ const parentContext = chunkKKGM42RQ_cjs.getActiveContextWithBaggage();
1752
1125
  const result = tracer.startActiveSpan(name, {}, parentContext, executeSpan);
1753
1126
  if (result instanceof Promise) {
1754
1127
  return result;
@@ -1783,7 +1156,7 @@ function withBaggage(options) {
1783
1156
  updatedBaggage = updatedBaggage.setEntry(key, { value });
1784
1157
  }
1785
1158
  const newContext = api.propagation.setBaggage(currentContext, updatedBaggage);
1786
- const ctxStorage = chunkHZ3FYBJG_cjs.getContextStorage();
1159
+ const ctxStorage = chunkKKGM42RQ_cjs.getContextStorage();
1787
1160
  const previousStored = ctxStorage.getStore();
1788
1161
  const baggageEnrichedStored = previousStored ? { value: api.propagation.setBaggage(previousStored.value, updatedBaggage) } : { value: newContext };
1789
1162
  const result = previousStored ? ctxStorage.run(baggageEnrichedStored, () => api.context.with(newContext, fn)) : api.context.with(newContext, fn);
@@ -1809,14 +1182,11 @@ function withBaggage(options) {
1809
1182
  }
1810
1183
 
1811
1184
  exports.ctx = ctx;
1812
- exports.getEventQueue = getEventQueue;
1813
1185
  exports.instrument = instrument;
1814
- exports.resetEventQueue = resetEventQueue;
1815
1186
  exports.span = span;
1816
- exports.trace = trace2;
1817
- exports.track = track;
1187
+ exports.trace = trace;
1818
1188
  exports.withBaggage = withBaggage;
1819
1189
  exports.withNewContext = withNewContext;
1820
1190
  exports.withTracing = withTracing;
1821
- //# sourceMappingURL=chunk-UTZR7P7E.cjs.map
1822
- //# sourceMappingURL=chunk-UTZR7P7E.cjs.map
1191
+ //# sourceMappingURL=chunk-QPH5ZKP5.cjs.map
1192
+ //# sourceMappingURL=chunk-QPH5ZKP5.cjs.map