@synnaxlabs/alamos 0.53.0 → 0.55.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.
@@ -0,0 +1,434 @@
1
+ //#region src/meta.ts
2
+ var e = class e {
3
+ _noop = !1;
4
+ key;
5
+ path;
6
+ serviceName;
7
+ constructor(e, t, n = "", r = !1) {
8
+ this.key = e, this.path = t, this.serviceName = n, this._noop = r;
9
+ }
10
+ child(t) {
11
+ return new e(t, this.extendPath(t), this.serviceName, this.noop);
12
+ }
13
+ extendPath(e) {
14
+ return `${this.path}.${e}`;
15
+ }
16
+ get noop() {
17
+ return this._noop;
18
+ }
19
+ static NOOP = new e("", "", "");
20
+ }, t = [
21
+ "debug",
22
+ "info",
23
+ "warn",
24
+ "error"
25
+ ], n = (e) => {
26
+ let n = t.indexOf(e);
27
+ return ({ level: e }) => t.indexOf(e) >= n;
28
+ }, r = (e) => {
29
+ let { include: t, exclude: n } = e;
30
+ return ({ path: e }) => !(t != null && !t.some((t) => e.startsWith(t)) || n != null && n.some((t) => e.startsWith(t)));
31
+ }, i = class t {
32
+ meta = e.NOOP;
33
+ filters;
34
+ constructor(e = {}) {
35
+ let { filters: t = [] } = e;
36
+ this.filters = t;
37
+ }
38
+ filter(e) {
39
+ return !this.meta.noop && this.filters.every((t) => t({
40
+ key: this.meta.key,
41
+ path: this.meta.path,
42
+ level: e
43
+ }));
44
+ }
45
+ child(e) {
46
+ let n = new t({ filters: this.filters });
47
+ return n.meta = e, n;
48
+ }
49
+ debug(e, t, n = !1) {
50
+ !this.filter("debug") && !n || (t == null ? console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e) : console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e, a(t)));
51
+ }
52
+ info(e, t, n = !1) {
53
+ !this.filter("info") && !n || (t == null ? console.log("%cINFO", "color: #005eff;", this.meta.path, e) : console.log("%cINFO", "color: #005eff;", this.meta.path, e, a(t)));
54
+ }
55
+ warn(e, t, n = !1) {
56
+ !this.filter("warn") && !n || (t == null ? console.warn("WARN", this.meta.path, e) : console.warn("WARN", this.meta.path, e, a(t)));
57
+ }
58
+ error(e, t, n = !1) {
59
+ !this.filter("error") && !n || (t == null ? console.error("ERROR", this.meta.path, e) : console.error("ERROR", this.meta.path, e, a(t)));
60
+ }
61
+ static NOOP = new t();
62
+ }, a = (e) => typeof e == "function" ? e() : e, o = "1.9.1", s = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
63
+ function c(e) {
64
+ let t = new Set([e]), n = /* @__PURE__ */ new Set(), r = e.match(s);
65
+ if (!r) return () => !1;
66
+ let i = {
67
+ major: +r[1],
68
+ minor: +r[2],
69
+ patch: +r[3],
70
+ prerelease: r[4]
71
+ };
72
+ if (i.prerelease != null) return function(t) {
73
+ return t === e;
74
+ };
75
+ function a(e) {
76
+ return n.add(e), !1;
77
+ }
78
+ function o(e) {
79
+ return t.add(e), !0;
80
+ }
81
+ return function(e) {
82
+ if (t.has(e)) return !0;
83
+ if (n.has(e)) return !1;
84
+ let r = e.match(s);
85
+ if (!r) return a(e);
86
+ let c = {
87
+ major: +r[1],
88
+ minor: +r[2],
89
+ patch: +r[3],
90
+ prerelease: r[4]
91
+ };
92
+ return c.prerelease != null || i.major !== c.major ? a(e) : i.major === 0 ? i.minor === c.minor && i.patch <= c.patch ? o(e) : a(e) : i.minor <= c.minor ? o(e) : a(e);
93
+ };
94
+ }
95
+ var l = c(o), u = o.split(".")[0], d = Symbol.for(`opentelemetry.js.api.${u}`), f = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {};
96
+ function p(e, t, n, r = !1) {
97
+ let i = f[d] = f[d] ?? { version: o };
98
+ if (!r && i[e]) {
99
+ let t = /* @__PURE__ */ Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);
100
+ return n.error(t.stack || t.message), !1;
101
+ }
102
+ if (i.version !== "1.9.1") {
103
+ let t = /* @__PURE__ */ Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${o}`);
104
+ return n.error(t.stack || t.message), !1;
105
+ }
106
+ return i[e] = t, n.debug(`@opentelemetry/api: Registered a global for ${e} v${o}.`), !0;
107
+ }
108
+ function m(e) {
109
+ let t = f[d]?.version;
110
+ if (!(!t || !l(t))) return f[d]?.[e];
111
+ }
112
+ function h(e, t) {
113
+ t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${o}.`);
114
+ let n = f[d];
115
+ n && delete n[e];
116
+ }
117
+ //#endregion
118
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
119
+ var g = class {
120
+ constructor(e) {
121
+ this._namespace = e.namespace || "DiagComponentLogger";
122
+ }
123
+ debug(...e) {
124
+ return _("debug", this._namespace, e);
125
+ }
126
+ error(...e) {
127
+ return _("error", this._namespace, e);
128
+ }
129
+ info(...e) {
130
+ return _("info", this._namespace, e);
131
+ }
132
+ warn(...e) {
133
+ return _("warn", this._namespace, e);
134
+ }
135
+ verbose(...e) {
136
+ return _("verbose", this._namespace, e);
137
+ }
138
+ };
139
+ function _(e, t, n) {
140
+ let r = m("diag");
141
+ if (r) return r[e](t, ...n);
142
+ }
143
+ //#endregion
144
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/diag/types.js
145
+ var v;
146
+ (function(e) {
147
+ e[e.NONE = 0] = "NONE", e[e.ERROR = 30] = "ERROR", e[e.WARN = 50] = "WARN", e[e.INFO = 60] = "INFO", e[e.DEBUG = 70] = "DEBUG", e[e.VERBOSE = 80] = "VERBOSE", e[e.ALL = 9999] = "ALL";
148
+ })(v ||= {});
149
+ //#endregion
150
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
151
+ function y(e, t) {
152
+ e < v.NONE ? e = v.NONE : e > v.ALL && (e = v.ALL), t ||= {};
153
+ function n(n, r) {
154
+ let i = t[n];
155
+ return typeof i == "function" && e >= r ? i.bind(t) : function() {};
156
+ }
157
+ return {
158
+ error: n("error", v.ERROR),
159
+ warn: n("warn", v.WARN),
160
+ info: n("info", v.INFO),
161
+ debug: n("debug", v.DEBUG),
162
+ verbose: n("verbose", v.VERBOSE)
163
+ };
164
+ }
165
+ //#endregion
166
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/api/diag.js
167
+ var b = "diag", x = class e {
168
+ static instance() {
169
+ return this._instance ||= new e(), this._instance;
170
+ }
171
+ constructor() {
172
+ function e(e) {
173
+ return function(...t) {
174
+ let n = m("diag");
175
+ if (n) return n[e](...t);
176
+ };
177
+ }
178
+ let t = this;
179
+ t.setLogger = (e, n = { logLevel: v.INFO }) => {
180
+ if (e === t) {
181
+ let e = /* @__PURE__ */ Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
182
+ return t.error(e.stack ?? e.message), !1;
183
+ }
184
+ typeof n == "number" && (n = { logLevel: n });
185
+ let r = m("diag"), i = y(n.logLevel ?? v.INFO, e);
186
+ if (r && !n.suppressOverrideMessage) {
187
+ let e = (/* @__PURE__ */ Error()).stack ?? "<failed to generate stacktrace>";
188
+ r.warn(`Current logger will be overwritten from ${e}`), i.warn(`Current logger will overwrite one already registered from ${e}`);
189
+ }
190
+ return p("diag", i, t, !0);
191
+ }, t.disable = () => {
192
+ h(b, t);
193
+ }, t.createComponentLogger = (e) => new g(e), t.verbose = e("verbose"), t.debug = e("debug"), t.info = e("info"), t.warn = e("warn"), t.error = e("error");
194
+ }
195
+ }, S = class e {
196
+ constructor(e) {
197
+ this._entries = e ? new Map(e) : /* @__PURE__ */ new Map();
198
+ }
199
+ getEntry(e) {
200
+ let t = this._entries.get(e);
201
+ if (t) return Object.assign({}, t);
202
+ }
203
+ getAllEntries() {
204
+ return Array.from(this._entries.entries());
205
+ }
206
+ setEntry(t, n) {
207
+ let r = new e(this._entries);
208
+ return r._entries.set(t, n), r;
209
+ }
210
+ removeEntry(t) {
211
+ let n = new e(this._entries);
212
+ return n._entries.delete(t), n;
213
+ }
214
+ removeEntries(...t) {
215
+ let n = new e(this._entries);
216
+ for (let e of t) n._entries.delete(e);
217
+ return n;
218
+ }
219
+ clear() {
220
+ return new e();
221
+ }
222
+ };
223
+ x.instance();
224
+ function C(e = {}) {
225
+ return new S(new Map(Object.entries(e)));
226
+ }
227
+ //#endregion
228
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/context/context.js
229
+ function w(e) {
230
+ return Symbol.for(e);
231
+ }
232
+ var T = new class e {
233
+ constructor(t) {
234
+ let n = this;
235
+ n._currentContext = t ? new Map(t) : /* @__PURE__ */ new Map(), n.getValue = (e) => n._currentContext.get(e), n.setValue = (t, r) => {
236
+ let i = new e(n._currentContext);
237
+ return i._currentContext.set(t, r), i;
238
+ }, n.deleteValue = (t) => {
239
+ let r = new e(n._currentContext);
240
+ return r._currentContext.delete(t), r;
241
+ };
242
+ }
243
+ }(), E = {
244
+ get(e, t) {
245
+ if (e != null) return e[t];
246
+ },
247
+ keys(e) {
248
+ return e == null ? [] : Object.keys(e);
249
+ }
250
+ }, D = { set(e, t, n) {
251
+ e != null && (e[t] = n);
252
+ } }, O = class {
253
+ active() {
254
+ return T;
255
+ }
256
+ with(e, t, n, ...r) {
257
+ return t.call(n, ...r);
258
+ }
259
+ bind(e, t) {
260
+ return t;
261
+ }
262
+ enable() {
263
+ return this;
264
+ }
265
+ disable() {
266
+ return this;
267
+ }
268
+ }, k = "context", A = new O(), j = class e {
269
+ constructor() {}
270
+ static getInstance() {
271
+ return this._instance ||= new e(), this._instance;
272
+ }
273
+ setGlobalContextManager(e) {
274
+ return p(k, e, x.instance());
275
+ }
276
+ active() {
277
+ return this._getContextManager().active();
278
+ }
279
+ with(e, t, n, ...r) {
280
+ return this._getContextManager().with(e, t, n, ...r);
281
+ }
282
+ bind(e, t) {
283
+ return this._getContextManager().bind(e, t);
284
+ }
285
+ _getContextManager() {
286
+ return m(k) || A;
287
+ }
288
+ disable() {
289
+ this._getContextManager().disable(), h(k, x.instance());
290
+ }
291
+ }, M;
292
+ (function(e) {
293
+ e[e.UNSET = 0] = "UNSET", e[e.OK = 1] = "OK", e[e.ERROR = 2] = "ERROR";
294
+ })(M ||= {});
295
+ //#endregion
296
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/context-api.js
297
+ var N = j.getInstance(), P = class {
298
+ inject(e, t) {}
299
+ extract(e, t) {
300
+ return e;
301
+ }
302
+ fields() {
303
+ return [];
304
+ }
305
+ }, F = w("OpenTelemetry Baggage Key");
306
+ function I(e) {
307
+ return e.getValue(F) || void 0;
308
+ }
309
+ function L() {
310
+ return I(j.getInstance().active());
311
+ }
312
+ function R(e, t) {
313
+ return e.setValue(F, t);
314
+ }
315
+ function z(e) {
316
+ return e.deleteValue(F);
317
+ }
318
+ //#endregion
319
+ //#region ../../node_modules/.pnpm/@opentelemetry+api@1.9.1/node_modules/@opentelemetry/api/build/esm/api/propagation.js
320
+ var B = "propagation", V = new P(), H = class e {
321
+ constructor() {
322
+ this.createBaggage = C, this.getBaggage = I, this.getActiveBaggage = L, this.setBaggage = R, this.deleteBaggage = z;
323
+ }
324
+ static getInstance() {
325
+ return this._instance ||= new e(), this._instance;
326
+ }
327
+ setGlobalPropagator(e) {
328
+ return p(B, e, x.instance());
329
+ }
330
+ inject(e, t, n = D) {
331
+ return this._getGlobalPropagator().inject(e, t, n);
332
+ }
333
+ extract(e, t, n = E) {
334
+ return this._getGlobalPropagator().extract(e, t, n);
335
+ }
336
+ fields() {
337
+ return this._getGlobalPropagator().fields();
338
+ }
339
+ disable() {
340
+ h(B, x.instance());
341
+ }
342
+ _getGlobalPropagator() {
343
+ return m(B) || V;
344
+ }
345
+ }.getInstance(), U = [
346
+ "bench",
347
+ "debug",
348
+ "prod"
349
+ ], W = (e) => (t) => U.indexOf(t) >= U.indexOf(e), G = class t {
350
+ meta = e.NOOP;
351
+ otelTracer;
352
+ filter;
353
+ constructor(e, t = W("debug")) {
354
+ this.otelTracer = e, this.filter = t;
355
+ }
356
+ child(e) {
357
+ let n = new t(this.otelTracer, this.filter);
358
+ return n.meta = e, n;
359
+ }
360
+ debug(e, t) {
361
+ return this.trace(e, "debug", t);
362
+ }
363
+ bench(e, t) {
364
+ return this.trace(e, "bench", t);
365
+ }
366
+ prod(e, t) {
367
+ return this.trace(e, "prod", t);
368
+ }
369
+ trace(e, t, n) {
370
+ let r = this.meta.noop || !this.filter(t) || this.otelTracer == null;
371
+ if (n == null) {
372
+ if (r) return () => {};
373
+ let t = new K(e, this.otelTracer.startSpan(e));
374
+ return t.start(), () => t.end();
375
+ }
376
+ return r ? n(new q(e)) : this.otelTracer.startActiveSpan(e, (t) => n(new K(e, t)));
377
+ }
378
+ propagate(e) {
379
+ if (this.meta.noop) return;
380
+ let t = N.active();
381
+ H.inject(t, e, { set: (e, t, n) => {
382
+ e[t] = n;
383
+ } });
384
+ }
385
+ static NOOP = new t();
386
+ }, K = class {
387
+ key;
388
+ otel;
389
+ constructor(e, t) {
390
+ this.key = e, this.otel = t;
391
+ }
392
+ set(e, t) {
393
+ this.otel.setAttribute(e, t);
394
+ }
395
+ recordError(e) {
396
+ e != null && (this.otel.recordException(e), this.otel.setStatus({ code: M.ERROR }));
397
+ }
398
+ start() {
399
+ performance.mark(`alamos.trace.start.${this.key}`);
400
+ }
401
+ end() {
402
+ try {
403
+ performance.mark(`alamos.trace.end.${this.key}`);
404
+ let e = performance.measure(`alamos.trace.duration.${this.key}`, `alamos.trace.start.${this.key}`, `alamos.trace.end.${this.key}`);
405
+ this.set("duration", e.duration), this.otel.end();
406
+ } catch (e) {
407
+ console.error(e);
408
+ }
409
+ }
410
+ }, q = class {
411
+ key;
412
+ constructor(e) {
413
+ this.key = e;
414
+ }
415
+ set() {}
416
+ recordError(e) {}
417
+ }, J = class t {
418
+ meta;
419
+ T;
420
+ L;
421
+ constructor({ key: t = "", serviceName: n = "", logger: r = i.NOOP, tracer: a = G.NOOP, noop: o = !1, __meta: s }) {
422
+ this.meta = s ?? new e(t, t, n, o), this.T = a.child(this.meta), this.L = r.child(this.meta);
423
+ }
424
+ child(e) {
425
+ return new t({
426
+ __meta: this.meta.child(e),
427
+ tracer: this.T,
428
+ logger: this.L
429
+ });
430
+ }
431
+ static NOOP = new t({ noop: !0 });
432
+ }, Y = J.NOOP;
433
+ //#endregion
434
+ export { K as a, x as c, h as d, t as f, n as h, G as i, m as l, r as m, Y as n, j as o, i as p, q as r, w as s, J as t, p as u };
@@ -0,0 +1 @@
1
+ var e=class e{_noop=!1;key;path;serviceName;constructor(e,t,n=``,r=!1){this.key=e,this.path=t,this.serviceName=n,this._noop=r}child(t){return new e(t,this.extendPath(t),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new e(``,``,``)},t=[`debug`,`info`,`warn`,`error`],n=e=>{let n=t.indexOf(e);return({level:e})=>t.indexOf(e)>=n},r=e=>{let{include:t,exclude:n}=e;return({path:e})=>!(t!=null&&!t.some(t=>e.startsWith(t))||n!=null&&n.some(t=>e.startsWith(t)))},i=class t{meta=e.NOOP;filters;constructor(e={}){let{filters:t=[]}=e;this.filters=t}filter(e){return!this.meta.noop&&this.filters.every(t=>t({key:this.meta.key,path:this.meta.path,level:e}))}child(e){let n=new t({filters:this.filters});return n.meta=e,n}debug(e,t,n=!1){!this.filter(`debug`)&&!n||(t==null?console.log(`%cDEBUG`,`color: #8c00f0;`,this.meta.path,e):console.log(`%cDEBUG`,`color: #8c00f0;`,this.meta.path,e,a(t)))}info(e,t,n=!1){!this.filter(`info`)&&!n||(t==null?console.log(`%cINFO`,`color: #005eff;`,this.meta.path,e):console.log(`%cINFO`,`color: #005eff;`,this.meta.path,e,a(t)))}warn(e,t,n=!1){!this.filter(`warn`)&&!n||(t==null?console.warn(`WARN`,this.meta.path,e):console.warn(`WARN`,this.meta.path,e,a(t)))}error(e,t,n=!1){!this.filter(`error`)&&!n||(t==null?console.error(`ERROR`,this.meta.path,e):console.error(`ERROR`,this.meta.path,e,a(t)))}static NOOP=new t},a=e=>typeof e==`function`?e():e,o=`1.9.1`,s=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function c(e){let t=new Set([e]),n=new Set,r=e.match(s);if(!r)return()=>!1;let i={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(i.prerelease!=null)return function(t){return t===e};function a(e){return n.add(e),!1}function o(e){return t.add(e),!0}return function(e){if(t.has(e))return!0;if(n.has(e))return!1;let r=e.match(s);if(!r)return a(e);let c={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};return c.prerelease!=null||i.major!==c.major?a(e):i.major===0?i.minor===c.minor&&i.patch<=c.patch?o(e):a(e):i.minor<=c.minor?o(e):a(e)}}var l=c(o),u=o.split(`.`)[0],d=Symbol.for(`opentelemetry.js.api.${u}`),f=typeof globalThis==`object`?globalThis:typeof self==`object`?self:typeof window==`object`?window:typeof global==`object`?global:{};function p(e,t,n,r=!1){let i=f[d]=f[d]??{version:o};if(!r&&i[e]){let t=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(t.stack||t.message),!1}if(i.version!==`1.9.1`){let t=Error(`@opentelemetry/api: Registration of version v${i.version} for ${e} does not match previously registered API v${o}`);return n.error(t.stack||t.message),!1}return i[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${o}.`),!0}function m(e){let t=f[d]?.version;if(!(!t||!l(t)))return f[d]?.[e]}function h(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${o}.`);let n=f[d];n&&delete n[e]}var g=class{constructor(e){this._namespace=e.namespace||`DiagComponentLogger`}debug(...e){return _(`debug`,this._namespace,e)}error(...e){return _(`error`,this._namespace,e)}info(...e){return _(`info`,this._namespace,e)}warn(...e){return _(`warn`,this._namespace,e)}verbose(...e){return _(`verbose`,this._namespace,e)}};function _(e,t,n){let r=m(`diag`);if(r)return r[e](t,...n)}var v;(function(e){e[e.NONE=0]=`NONE`,e[e.ERROR=30]=`ERROR`,e[e.WARN=50]=`WARN`,e[e.INFO=60]=`INFO`,e[e.DEBUG=70]=`DEBUG`,e[e.VERBOSE=80]=`VERBOSE`,e[e.ALL=9999]=`ALL`})(v||={});function y(e,t){e<v.NONE?e=v.NONE:e>v.ALL&&(e=v.ALL),t||={};function n(n,r){let i=t[n];return typeof i==`function`&&e>=r?i.bind(t):function(){}}return{error:n(`error`,v.ERROR),warn:n(`warn`,v.WARN),info:n(`info`,v.INFO),debug:n(`debug`,v.DEBUG),verbose:n(`verbose`,v.VERBOSE)}}var b=`diag`,x=class e{static instance(){return this._instance||=new e,this._instance}constructor(){function e(e){return function(...t){let n=m(`diag`);if(n)return n[e](...t)}}let t=this;t.setLogger=(e,n={logLevel:v.INFO})=>{if(e===t){let e=Error(`Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation`);return t.error(e.stack??e.message),!1}typeof n==`number`&&(n={logLevel:n});let r=m(`diag`),i=y(n.logLevel??v.INFO,e);if(r&&!n.suppressOverrideMessage){let e=Error().stack??`<failed to generate stacktrace>`;r.warn(`Current logger will be overwritten from ${e}`),i.warn(`Current logger will overwrite one already registered from ${e}`)}return p(`diag`,i,t,!0)},t.disable=()=>{h(b,t)},t.createComponentLogger=e=>new g(e),t.verbose=e(`verbose`),t.debug=e(`debug`),t.info=e(`info`),t.warn=e(`warn`),t.error=e(`error`)}},S=class e{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(t,n){let r=new e(this._entries);return r._entries.set(t,n),r}removeEntry(t){let n=new e(this._entries);return n._entries.delete(t),n}removeEntries(...t){let n=new e(this._entries);for(let e of t)n._entries.delete(e);return n}clear(){return new e}};x.instance();function C(e={}){return new S(new Map(Object.entries(e)))}function w(e){return Symbol.for(e)}var T=new class e{constructor(t){let n=this;n._currentContext=t?new Map(t):new Map,n.getValue=e=>n._currentContext.get(e),n.setValue=(t,r)=>{let i=new e(n._currentContext);return i._currentContext.set(t,r),i},n.deleteValue=t=>{let r=new e(n._currentContext);return r._currentContext.delete(t),r}}},E={get(e,t){if(e!=null)return e[t]},keys(e){return e==null?[]:Object.keys(e)}},D={set(e,t,n){e!=null&&(e[t]=n)}},O=class{active(){return T}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}},k=`context`,A=new O,j=class e{constructor(){}static getInstance(){return this._instance||=new e,this._instance}setGlobalContextManager(e){return p(k,e,x.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return m(k)||A}disable(){this._getContextManager().disable(),h(k,x.instance())}},M;(function(e){e[e.UNSET=0]=`UNSET`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`})(M||={});var N=j.getInstance(),P=class{inject(e,t){}extract(e,t){return e}fields(){return[]}},F=w(`OpenTelemetry Baggage Key`);function I(e){return e.getValue(F)||void 0}function L(){return I(j.getInstance().active())}function R(e,t){return e.setValue(F,t)}function z(e){return e.deleteValue(F)}var B=`propagation`,V=new P,H=class e{constructor(){this.createBaggage=C,this.getBaggage=I,this.getActiveBaggage=L,this.setBaggage=R,this.deleteBaggage=z}static getInstance(){return this._instance||=new e,this._instance}setGlobalPropagator(e){return p(B,e,x.instance())}inject(e,t,n=D){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=E){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){h(B,x.instance())}_getGlobalPropagator(){return m(B)||V}}.getInstance(),U=[`bench`,`debug`,`prod`],W=e=>t=>U.indexOf(t)>=U.indexOf(e),G=class t{meta=e.NOOP;otelTracer;filter;constructor(e,t=W(`debug`)){this.otelTracer=e,this.filter=t}child(e){let n=new t(this.otelTracer,this.filter);return n.meta=e,n}debug(e,t){return this.trace(e,`debug`,t)}bench(e,t){return this.trace(e,`bench`,t)}prod(e,t){return this.trace(e,`prod`,t)}trace(e,t,n){let r=this.meta.noop||!this.filter(t)||this.otelTracer==null;if(n==null){if(r)return()=>{};let t=new K(e,this.otelTracer.startSpan(e));return t.start(),()=>t.end()}return r?n(new q(e)):this.otelTracer.startActiveSpan(e,t=>n(new K(e,t)))}propagate(e){if(this.meta.noop)return;let t=N.active();H.inject(t,e,{set:(e,t,n)=>{e[t]=n}})}static NOOP=new t},K=class{key;otel;constructor(e,t){this.key=e,this.otel=t}set(e,t){this.otel.setAttribute(e,t)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:M.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);let e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set(`duration`,e.duration),this.otel.end()}catch(e){console.error(e)}}},q=class{key;constructor(e){this.key=e}set(){}recordError(e){}},J=class t{meta;T;L;constructor({key:t=``,serviceName:n=``,logger:r=i.NOOP,tracer:a=G.NOOP,noop:o=!1,__meta:s}){this.meta=s??new e(t,t,n,o),this.T=a.child(this.meta),this.L=r.child(this.meta)}child(e){return new t({__meta:this.meta.child(e),tracer:this.T,logger:this.L})}static NOOP=new t({noop:!0})},Y=J.NOOP;Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return p}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/alamos",
3
- "version": "0.53.0",
3
+ "version": "0.55.0",
4
4
  "type": "module",
5
5
  "description": "Distributed instrumentation for Synnax",
6
6
  "repository": "https://github.com/synnaxlabs/synnax/tree/main/freighter/ts",
@@ -15,29 +15,29 @@
15
15
  "control systems"
16
16
  ],
17
17
  "dependencies": {
18
- "@opentelemetry/api": "^1.9.0",
19
- "@synnaxlabs/x": "^0.53.0"
18
+ "@opentelemetry/api": "^1.9.1",
19
+ "@synnaxlabs/x": "^0.55.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/node": "^25.1.0",
23
- "@vitest/coverage-v8": "^3.2.4",
24
- "eslint": "^9.39.2",
22
+ "@types/node": "^25.6.0",
23
+ "@vitest/coverage-v8": "^4.1.4",
24
+ "eslint": "^10.2.1",
25
25
  "madge": "^8.0.0",
26
- "typescript": "^5.9.3",
27
- "vite": "^7.3.1",
28
- "vitest": "^3.2.4",
29
- "@synnaxlabs/eslint-config": "^0.0.0",
26
+ "typescript": "^6.0.3",
27
+ "vite": "^8.0.8",
28
+ "vitest": "^4.1.4",
30
29
  "@synnaxlabs/tsconfig": "^0.0.0",
30
+ "@synnaxlabs/eslint-config": "^0.0.0",
31
31
  "@synnaxlabs/vite-plugin": "^0.0.0"
32
32
  },
33
- "main": "dist/index.js",
34
- "module": "dist/index.js",
33
+ "main": "dist/alamos.cjs",
34
+ "module": "dist/alamos.js",
35
35
  "types": "dist/src/index.d.ts",
36
36
  "exports": {
37
37
  ".": {
38
38
  "types": "./dist/src/index.d.ts",
39
- "import": "./dist/index.js",
40
- "require": "./dist/index.cjs"
39
+ "import": "./dist/alamos.js",
40
+ "require": "./dist/alamos.cjs"
41
41
  },
42
42
  "./dev": {
43
43
  "types": "./dist/src/dev/index.d.ts",
package/tsconfig.json CHANGED
@@ -1,10 +1,5 @@
1
1
  {
2
2
  "extends": "@synnaxlabs/tsconfig/base.json",
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "paths": {
6
- "@/*": ["src/*"]
7
- }
8
- },
3
+ "compilerOptions": { "types": ["node"], "paths": { "@/*": ["./src/*"] } },
9
4
  "include": ["src/**/*.ts", "eslint.config.ts"]
10
5
  }
package/vite.config.ts CHANGED
@@ -7,6 +7,8 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
+ /// <reference types="vitest/config" />
11
+
10
12
  import { lib } from "@synnaxlabs/vite-plugin";
11
13
  import path from "path";
12
14
  import { defineConfig } from "vite";
@@ -22,4 +24,11 @@ export default defineConfig({
22
24
  },
23
25
  },
24
26
  },
27
+ test: {
28
+ exclude: ["**/node_modules/**", "**/dist/**"],
29
+ coverage: {
30
+ include: ["src/**/*.ts", "src/**/*.tsx"],
31
+ exclude: ["src/**/*.spec.ts", "src/**/*.spec.tsx", "src/**/*.bench.ts"],
32
+ },
33
+ },
25
34
  });
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./instrumentation-BUpiX8Rz.cjs"),o=Object.freeze(Object.defineProperty({__proto__:null,Instrumentation:e.Instrumentation,LOG_LEVELS:e.LOG_LEVELS,Logger:e.Logger,NOOP:e.NOOP,NoopSpan:e.NoopSpan,Tracer:e.Tracer,_Span:e._Span,logLevelKeyFiler:e.logLevelKeyFiler,logThresholdFilter:e.logThresholdFilter},Symbol.toStringTag,{value:"Module"}));exports.Instrumentation=e.Instrumentation;exports.LOG_LEVELS=e.LOG_LEVELS;exports.Logger=e.Logger;exports.NOOP=e.NOOP;exports.NoopSpan=e.NoopSpan;exports.Tracer=e.Tracer;exports._Span=e._Span;exports.logLevelKeyFiler=e.logLevelKeyFiler;exports.logThresholdFilter=e.logThresholdFilter;exports.alamos=o;
package/dist/index.js DELETED
@@ -1,25 +0,0 @@
1
- import { I as e, L as a, a as o, N as r, b as l, T as s, _ as t, l as n, c as p } from "./instrumentation-BvrhwRHI.js";
2
- const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
- __proto__: null,
4
- Instrumentation: e,
5
- LOG_LEVELS: a,
6
- Logger: o,
7
- NOOP: r,
8
- NoopSpan: l,
9
- Tracer: s,
10
- _Span: t,
11
- logLevelKeyFiler: n,
12
- logThresholdFilter: p
13
- }, Symbol.toStringTag, { value: "Module" }));
14
- export {
15
- e as Instrumentation,
16
- a as LOG_LEVELS,
17
- o as Logger,
18
- r as NOOP,
19
- l as NoopSpan,
20
- s as Tracer,
21
- t as _Span,
22
- g as alamos,
23
- n as logLevelKeyFiler,
24
- p as logThresholdFilter
25
- };
@@ -1 +0,0 @@
1
- "use strict";class h{_noop=!1;key;path;serviceName;constructor(e,t,n="",o=!1){this.key=e,this.path=t,this.serviceName=n,this._noop=o}child(e){return new h(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}static NOOP=new h("","","")}const P=["debug","info","warn","error"],K=r=>{const e=P.indexOf(r);return({level:t})=>P.indexOf(t)>=e},V=r=>{const{include:e,exclude:t}=r;return({path:n})=>!(e!=null&&!e.some(o=>n.startsWith(o))||t!=null&&t.some(o=>n.startsWith(o)))};class y{meta=h.NOOP;filters;constructor(e={}){const{filters:t=[]}=e;this.filters=t}filter(e){return!this.meta.noop&&this.filters.every(t=>t({key:this.meta.key,path:this.meta.path,level:e}))}child(e){const t=new y({filters:this.filters});return t.meta=e,t}debug(e,t,n=!1){!this.filter("debug")&&!n||(t==null?console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e):console.log("%cDEBUG","color: #8c00f0;",this.meta.path,e,O(t)))}info(e,t,n=!1){!this.filter("info")&&!n||(t==null?console.log("%cINFO","color: #005eff;",this.meta.path,e):console.log("%cINFO","color: #005eff;",this.meta.path,e,O(t)))}warn(e,t,n=!1){!this.filter("warn")&&!n||(t==null?console.warn("WARN",this.meta.path,e):console.warn("WARN",this.meta.path,e,O(t)))}error(e,t,n=!1){!this.filter("error")&&!n||(t==null?console.error("ERROR",this.meta.path,e):console.error("ERROR",this.meta.path,e,O(t)))}static NOOP=new y}const O=r=>typeof r=="function"?r():r;var k=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},p="1.9.0",M=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function U(r){var e=new Set([r]),t=new Set,n=r.match(M);if(!n)return function(){return!1};var o={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(o.prerelease!=null)return function(s){return s===r};function a(u){return t.add(u),!1}function i(u){return e.add(u),!0}return function(s){if(e.has(s))return!0;if(t.has(s))return!1;var l=s.match(M);if(!l)return a(s);var f={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};return f.prerelease!=null||o.major!==f.major?a(s):o.major===0?o.minor===f.minor&&o.patch<=f.patch?i(s):a(s):o.minor<=f.minor?i(s):a(s)}}var W=U(p),X=p.split(".")[0],m=Symbol.for("opentelemetry.js.api."+X),b=k;function E(r,e,t,n){var o;n===void 0&&(n=!1);var a=b[m]=(o=b[m])!==null&&o!==void 0?o:{version:p};if(!n&&a[r]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+r);return t.error(i.stack||i.message),!1}if(a.version!==p){var i=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+r+" does not match previously registered API v"+p);return t.error(i.stack||i.message),!1}return a[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+p+"."),!0}function g(r){var e,t,n=(e=b[m])===null||e===void 0?void 0:e.version;if(!(!n||!W(n)))return(t=b[m])===null||t===void 0?void 0:t[r]}function A(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+p+".");var t=b[m];t&&delete t[r]}var Y=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,a=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(u){i={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return a},D=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,a;n<o;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return r.concat(a||Array.prototype.slice.call(e))},q=(function(){function r(e){this._namespace=e.namespace||"DiagComponentLogger"}return r.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v("debug",this._namespace,e)},r.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v("error",this._namespace,e)},r.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v("info",this._namespace,e)},r.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v("warn",this._namespace,e)},r.prototype.verbose=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return v("verbose",this._namespace,e)},r})();function v(r,e,t){var n=g("diag");if(n)return t.unshift(e),n[r].apply(n,D([],Y(t),!1))}var c;(function(r){r[r.NONE=0]="NONE",r[r.ERROR=30]="ERROR",r[r.WARN=50]="WARN",r[r.INFO=60]="INFO",r[r.DEBUG=70]="DEBUG",r[r.VERBOSE=80]="VERBOSE",r[r.ALL=9999]="ALL"})(c||(c={}));function z(r,e){r<c.NONE?r=c.NONE:r>c.ALL&&(r=c.ALL),e=e||{};function t(n,o){var a=e[n];return typeof a=="function"&&r>=o?a.bind(e):function(){}}return{error:t("error",c.ERROR),warn:t("warn",c.WARN),info:t("info",c.INFO),debug:t("debug",c.DEBUG),verbose:t("verbose",c.VERBOSE)}}var H=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,a=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(u){i={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return a},J=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,a;n<o;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return r.concat(a||Array.prototype.slice.call(e))},Q="diag",d=(function(){function r(){function e(o){return function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];var u=g("diag");if(u)return u[o].apply(u,J([],H(a),!1))}}var t=this,n=function(o,a){var i,u,s;if(a===void 0&&(a={logLevel:c.INFO}),o===t){var l=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return t.error((i=l.stack)!==null&&i!==void 0?i:l.message),!1}typeof a=="number"&&(a={logLevel:a});var f=g("diag"),B=z((u=a.logLevel)!==null&&u!==void 0?u:c.INFO,o);if(f&&!a.suppressOverrideMessage){var G=(s=new Error().stack)!==null&&s!==void 0?s:"<failed to generate stacktrace>";f.warn("Current logger will be overwritten from "+G),B.warn("Current logger will overwrite one already registered from "+G)}return E("diag",B,t,!0)};t.setLogger=n,t.disable=function(){A(Q,t)},t.createComponentLogger=function(o){return new q(o)},t.verbose=e("verbose"),t.debug=e("debug"),t.info=e("info"),t.warn=e("warn"),t.error=e("error")}return r.instance=function(){return this._instance||(this._instance=new r),this._instance},r})(),Z=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,a=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(u){i={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return a},L=function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ee=(function(){function r(e){this._entries=e?new Map(e):new Map}return r.prototype.getEntry=function(e){var t=this._entries.get(e);if(t)return Object.assign({},t)},r.prototype.getAllEntries=function(){return Array.from(this._entries.entries()).map(function(e){var t=Z(e,2),n=t[0],o=t[1];return[n,o]})},r.prototype.setEntry=function(e,t){var n=new r(this._entries);return n._entries.set(e,t),n},r.prototype.removeEntry=function(e){var t=new r(this._entries);return t._entries.delete(e),t},r.prototype.removeEntries=function(){for(var e,t,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var a=new r(this._entries);try{for(var i=L(n),u=i.next();!u.done;u=i.next()){var s=u.value;a._entries.delete(s)}}catch(l){e={error:l}}finally{try{u&&!u.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return a},r.prototype.clear=function(){return new r},r})();d.instance();function te(r){return r===void 0&&(r={}),new ee(new Map(Object.entries(r)))}function j(r){return Symbol.for(r)}var re=(function(){function r(e){var t=this;t._currentContext=e?new Map(e):new Map,t.getValue=function(n){return t._currentContext.get(n)},t.setValue=function(n,o){var a=new r(t._currentContext);return a._currentContext.set(n,o),a},t.deleteValue=function(n){var o=new r(t._currentContext);return o._currentContext.delete(n),o}}return r})(),ne=new re,ae={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},oe={set:function(r,e,t){r!=null&&(r[e]=t)}},ie=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,a=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(u){i={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return a},ue=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,a;n<o;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return r.concat(a||Array.prototype.slice.call(e))},se=(function(){function r(){}return r.prototype.active=function(){return ne},r.prototype.with=function(e,t,n){for(var o=[],a=3;a<arguments.length;a++)o[a-3]=arguments[a];return t.call.apply(t,ue([n],ie(o),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r})(),ce=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),o,a=[],i;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)a.push(o.value)}catch(u){i={error:u}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return a},le=function(r,e,t){if(t||arguments.length===2)for(var n=0,o=e.length,a;n<o;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return r.concat(a||Array.prototype.slice.call(e))},N="context",fe=new se,I=(function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return E(N,e,d.instance())},r.prototype.active=function(){return this._getContextManager().active()},r.prototype.with=function(e,t,n){for(var o,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];return(o=this._getContextManager()).with.apply(o,le([e,t,n],ce(a),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return g(N)||fe},r.prototype.disable=function(){this._getContextManager().disable(),A(N,d.instance())},r})(),R;(function(r){r[r.UNSET=0]="UNSET",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR"})(R||(R={}));var pe=I.getInstance(),he=(function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r})(),C=j("OpenTelemetry Baggage Key");function $(r){return r.getValue(C)||void 0}function ge(){return $(I.getInstance().active())}function de(r,e){return r.setValue(C,e)}function ve(r){return r.deleteValue(C)}var x="propagation",ye=new he,me=(function(){function r(){this.createBaggage=te,this.getBaggage=$,this.getActiveBaggage=ge,this.setBaggage=de,this.deleteBaggage=ve}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return E(x,e,d.instance())},r.prototype.inject=function(e,t,n){return n===void 0&&(n=oe),this._getGlobalPropagator().inject(e,t,n)},r.prototype.extract=function(e,t,n){return n===void 0&&(n=ae),this._getGlobalPropagator().extract(e,t,n)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){A(x,d.instance())},r.prototype._getGlobalPropagator=function(){return g(x)||ye},r})(),be=me.getInstance();const S=["bench","debug","prod"],_e=r=>e=>S.indexOf(e)>=S.indexOf(r);class _{meta=h.NOOP;otelTracer;filter;constructor(e,t=_e("debug")){this.otelTracer=e,this.filter=t}child(e){const t=new _(this.otelTracer,this.filter);return t.meta=e,t}debug(e,t){return this.trace(e,"debug",t)}bench(e,t){return this.trace(e,"bench",t)}prod(e,t){return this.trace(e,"prod",t)}trace(e,t,n){const o=this.meta.noop||!this.filter(t)||this.otelTracer==null;if(n==null){if(o)return()=>{};const a=new T(e,this.otelTracer.startSpan(e));return a.start(),()=>a.end()}return o?n(new F(e)):this.otelTracer.startActiveSpan(e,a=>{const i=new T(e,a);return n(i)})}propagate(e){if(this.meta.noop)return;const t=pe.active();be.inject(t,e,{set:(n,o,a)=>{n[o]=a}})}static NOOP=new _}class T{key;otel;constructor(e,t){this.key=e,this.otel=t}set(e,t){this.otel.setAttribute(e,t)}recordError(e){e!=null&&(this.otel.recordException(e),this.otel.setStatus({code:R.ERROR}))}start(){performance.mark(`alamos.trace.start.${this.key}`)}end(){try{performance.mark(`alamos.trace.end.${this.key}`);const e=performance.measure(`alamos.trace.duration.${this.key}`,`alamos.trace.start.${this.key}`,`alamos.trace.end.${this.key}`);this.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class F{key;constructor(e){this.key=e}set(){}recordError(e){}}class w{meta;T;L;constructor({key:e="",serviceName:t="",logger:n=y.NOOP,tracer:o=_.NOOP,noop:a=!1,__meta:i}){this.meta=i??new h(e,e,t,a),this.T=o.child(this.meta),this.L=n.child(this.meta)}child(e){const t=this.meta.child(e);return new w({__meta:t,tracer:this.T,logger:this.L})}static NOOP=new w({noop:!0})}const we=w.NOOP;exports.ContextAPI=I;exports.DiagAPI=d;exports.Instrumentation=w;exports.LOG_LEVELS=P;exports.Logger=y;exports.NOOP=we;exports.NoopSpan=F;exports.Tracer=_;exports._Span=T;exports.createContextKey=j;exports.getGlobal=g;exports.logLevelKeyFiler=V;exports.logThresholdFilter=K;exports.registerGlobal=E;exports.unregisterGlobal=A;