@synnaxlabs/alamos 0.42.3 → 0.43.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.
- package/.vscode/settings.json +2 -2
- package/dist/dev.cjs +1 -1
- package/dist/dev.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{instrumentation-1jARg32o.js → instrumentation-fXoCOVPg.js} +102 -102
- package/dist/instrumentation-lwMkPABv.cjs +1 -0
- package/dist/trace.d.ts +8 -8
- package/dist/trace.d.ts.map +1 -1
- package/eslint.config.js +1 -1
- package/package.json +8 -10
- package/src/trace.ts +12 -17
- package/tsconfig.json +1 -1
- package/dist/instrumentation-DeyQj3IK.cjs +0 -1
package/.vscode/settings.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
"vitest.disableWorkspaceWarning": true
|
|
3
|
+
}
|
package/dist/dev.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./instrumentation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./instrumentation-lwMkPABv.cjs");var v;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(v||(v={}));var T="0000000000000000",S="00000000000000000000000000000000",N={traceId:S,spanId:T,traceFlags:v.NONE},u=function(){function t(e){e===void 0&&(e=N),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t}(),d=o.createContextKey("OpenTelemetry Context Key SPAN");function l(t){return t.getValue(d)||void 0}function m(){return l(o.ContextAPI.getInstance().active())}function g(t,e){return t.setValue(d,e)}function D(t){return t.deleteValue(d)}function E(t,e){return g(t,new u(e))}function P(t){var e;return(e=l(t))===null||e===void 0?void 0:e.spanContext()}var w=/^([0-9a-f]{32})$/i,C=/^[0-9a-f]{16}$/i;function R(t){return w.test(t)&&t!==S}function b(t){return C.test(t)&&t!==T}function A(t){return R(t.traceId)&&b(t.spanId)}function V(t){return new u(t)}var p=o.ContextAPI.getInstance(),I=function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=p.active());var i=!!(r!=null&&r.root);if(i)return new u;var a=n&&P(n);return O(a)&&A(a)?new u(a):new u},t.prototype.startActiveSpan=function(e,r,n,i){var a,c,s;if(!(arguments.length<2)){arguments.length===2?s=r:arguments.length===3?(a=r,s=n):(a=r,c=n,s=i);var _=c??p.active(),h=this.startSpan(e,a,_),x=g(_,h);return p.with(x,s,void 0,h)}},t}();function O(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var L=new I,k=function(){function t(e,r,n,i){this._provider=e,this.name=r,this.version=n,this.options=i}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,i){var a=this._getTracer();return Reflect.apply(a.startActiveSpan,a,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):L},t}(),G=function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new I},t}(),M=new G,y=function(){function t(){}return t.prototype.getTracer=function(e,r,n){var i;return(i=this.getDelegateTracer(e,r,n))!==null&&i!==void 0?i:new k(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:M},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var i;return(i=this._delegate)===null||i===void 0?void 0:i.getTracer(e,r,n)},t}(),f="trace",K=function(){function t(){this._proxyTracerProvider=new y,this.wrapSpanContext=V,this.isSpanContextValid=A,this.deleteSpan=D,this.getSpan=l,this.getActiveSpan=m,this.getSpanContext=P,this.setSpan=g,this.setSpanContext=E}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=o.registerGlobal(f,this._proxyTracerProvider,o.DiagAPI.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return o.getGlobal(f)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){o.unregisterGlobal(f,o.DiagAPI.instance()),this._proxyTracerProvider=new y},t}(),X=K.getInstance();const $=()=>{const t="synnax";return new o.Instrumentation({key:"",serviceName:t,logger:new o.Logger,tracer:new o.Tracer(X.getTracerProvider().getTracer("synnax"))})};exports.instrumentation=$;
|
package/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as m, C as T, r as D, D as h, g as E, u as w, I as C, T as R, a as V } from "./instrumentation-
|
|
1
|
+
import { d as m, C as T, r as D, D as h, g as E, u as w, I as C, T as R, a as V } from "./instrumentation-fXoCOVPg.js";
|
|
2
2
|
var f;
|
|
3
3
|
(function(t) {
|
|
4
4
|
t[t.NONE = 0] = "NONE", t[t.SAMPLED = 1] = "SAMPLED";
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./instrumentation-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./instrumentation-lwMkPABv.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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-fXoCOVPg.js";
|
|
2
2
|
const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
Instrumentation: e,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var W = (r, e, t) => e in r ?
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var W = (r, e, t) => e in r ? U(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
3
|
var u = (r, e, t) => W(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
const g = class g {
|
|
5
|
-
constructor(e, t, n = "",
|
|
5
|
+
constructor(e, t, n = "", o = !1) {
|
|
6
6
|
u(this, "_noop", !1);
|
|
7
7
|
u(this, "key");
|
|
8
8
|
u(this, "path");
|
|
9
9
|
u(this, "serviceName");
|
|
10
|
-
this.key = e, this.path = t, this.serviceName = n, this._noop =
|
|
10
|
+
this.key = e, this.path = t, this.serviceName = n, this._noop = o;
|
|
11
11
|
}
|
|
12
12
|
child(e) {
|
|
13
13
|
return new g(e, this.extendPath(e), this.serviceName, this.noop);
|
|
@@ -26,7 +26,7 @@ const j = ["debug", "info", "warn", "error"], Pe = (r) => {
|
|
|
26
26
|
return ({ level: t }) => j.indexOf(t) >= e;
|
|
27
27
|
}, Re = (r) => {
|
|
28
28
|
const { include: e, exclude: t } = r;
|
|
29
|
-
return ({ path: n }) => !(e != null && !e.some((
|
|
29
|
+
return ({ path: n }) => !(e != null && !e.some((o) => n.startsWith(o)) || t != null && t.some((o) => n.startsWith(o)));
|
|
30
30
|
}, v = class v {
|
|
31
31
|
constructor(e = {}) {
|
|
32
32
|
u(this, "meta", b.NOOP);
|
|
@@ -70,17 +70,17 @@ function Y(r) {
|
|
|
70
70
|
return function() {
|
|
71
71
|
return !1;
|
|
72
72
|
};
|
|
73
|
-
var
|
|
73
|
+
var o = {
|
|
74
74
|
major: +n[1],
|
|
75
75
|
minor: +n[2],
|
|
76
76
|
patch: +n[3],
|
|
77
77
|
prerelease: n[4]
|
|
78
78
|
};
|
|
79
|
-
if (
|
|
79
|
+
if (o.prerelease != null)
|
|
80
80
|
return function(c) {
|
|
81
81
|
return c === r;
|
|
82
82
|
};
|
|
83
|
-
function
|
|
83
|
+
function a(s) {
|
|
84
84
|
return t.add(s), !1;
|
|
85
85
|
}
|
|
86
86
|
function i(s) {
|
|
@@ -93,32 +93,32 @@ function Y(r) {
|
|
|
93
93
|
return !1;
|
|
94
94
|
var f = c.match($);
|
|
95
95
|
if (!f)
|
|
96
|
-
return
|
|
96
|
+
return a(c);
|
|
97
97
|
var p = {
|
|
98
98
|
major: +f[1],
|
|
99
99
|
minor: +f[2],
|
|
100
100
|
patch: +f[3],
|
|
101
101
|
prerelease: f[4]
|
|
102
102
|
};
|
|
103
|
-
return p.prerelease != null ||
|
|
103
|
+
return p.prerelease != null || o.major !== p.major ? a(c) : o.major === 0 ? o.minor === p.minor && o.patch <= p.patch ? i(c) : a(c) : o.minor <= p.minor ? i(c) : a(c);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
var D = Y(h), q = h.split(".")[0], w = Symbol.for("opentelemetry.js.api." + q), _ = X;
|
|
107
107
|
function B(r, e, t, n) {
|
|
108
|
-
var
|
|
108
|
+
var o;
|
|
109
109
|
n === void 0 && (n = !1);
|
|
110
|
-
var
|
|
110
|
+
var a = _[w] = (o = _[w]) !== null && o !== void 0 ? o : {
|
|
111
111
|
version: h
|
|
112
112
|
};
|
|
113
|
-
if (!n &&
|
|
113
|
+
if (!n && a[r]) {
|
|
114
114
|
var i = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + r);
|
|
115
115
|
return t.error(i.stack || i.message), !1;
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
118
|
-
var i = new Error("@opentelemetry/api: Registration of version v" +
|
|
117
|
+
if (a.version !== h) {
|
|
118
|
+
var i = new Error("@opentelemetry/api: Registration of version v" + a.version + " for " + r + " does not match previously registered API v" + h);
|
|
119
119
|
return t.error(i.stack || i.message), !1;
|
|
120
120
|
}
|
|
121
|
-
return
|
|
121
|
+
return a[r] = e, t.debug("@opentelemetry/api: Registered a global for " + r + " v" + h + "."), !0;
|
|
122
122
|
}
|
|
123
123
|
function O(r) {
|
|
124
124
|
var e, t, n = (e = _[w]) === null || e === void 0 ? void 0 : e.version;
|
|
@@ -133,23 +133,23 @@ function I(r, e) {
|
|
|
133
133
|
var z = function(r, e) {
|
|
134
134
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
135
135
|
if (!t) return r;
|
|
136
|
-
var n = t.call(r),
|
|
136
|
+
var n = t.call(r), o, a = [], i;
|
|
137
137
|
try {
|
|
138
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
138
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
139
139
|
} catch (s) {
|
|
140
140
|
i = { error: s };
|
|
141
141
|
} finally {
|
|
142
142
|
try {
|
|
143
|
-
|
|
143
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
144
144
|
} finally {
|
|
145
145
|
if (i) throw i.error;
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
return
|
|
148
|
+
return a;
|
|
149
149
|
}, H = function(r, e, t) {
|
|
150
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
151
|
-
(
|
|
152
|
-
return r.concat(
|
|
150
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
151
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
152
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
153
153
|
}, J = (
|
|
154
154
|
/** @class */
|
|
155
155
|
function() {
|
|
@@ -190,9 +190,9 @@ var l;
|
|
|
190
190
|
})(l || (l = {}));
|
|
191
191
|
function Q(r, e) {
|
|
192
192
|
r < l.NONE ? r = l.NONE : r > l.ALL && (r = l.ALL), e = e || {};
|
|
193
|
-
function t(n,
|
|
194
|
-
var
|
|
195
|
-
return typeof
|
|
193
|
+
function t(n, o) {
|
|
194
|
+
var a = e[n];
|
|
195
|
+
return typeof a == "function" && r >= o ? a.bind(e) : function() {
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
return {
|
|
@@ -206,47 +206,47 @@ function Q(r, e) {
|
|
|
206
206
|
var Z = function(r, e) {
|
|
207
207
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
208
208
|
if (!t) return r;
|
|
209
|
-
var n = t.call(r),
|
|
209
|
+
var n = t.call(r), o, a = [], i;
|
|
210
210
|
try {
|
|
211
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
211
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
212
212
|
} catch (s) {
|
|
213
213
|
i = { error: s };
|
|
214
214
|
} finally {
|
|
215
215
|
try {
|
|
216
|
-
|
|
216
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
217
217
|
} finally {
|
|
218
218
|
if (i) throw i.error;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
return
|
|
221
|
+
return a;
|
|
222
222
|
}, L = function(r, e, t) {
|
|
223
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
224
|
-
(
|
|
225
|
-
return r.concat(
|
|
223
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
224
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
225
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
226
226
|
}, ee = "diag", E = (
|
|
227
227
|
/** @class */
|
|
228
228
|
function() {
|
|
229
229
|
function r() {
|
|
230
|
-
function e(
|
|
230
|
+
function e(o) {
|
|
231
231
|
return function() {
|
|
232
|
-
for (var
|
|
233
|
-
|
|
232
|
+
for (var a = [], i = 0; i < arguments.length; i++)
|
|
233
|
+
a[i] = arguments[i];
|
|
234
234
|
var s = O("diag");
|
|
235
235
|
if (s)
|
|
236
|
-
return s[
|
|
236
|
+
return s[o].apply(s, L([], Z(a), !1));
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
-
var t = this, n = function(
|
|
239
|
+
var t = this, n = function(o, a) {
|
|
240
240
|
var i, s, c;
|
|
241
|
-
if (
|
|
241
|
+
if (a === void 0 && (a = { logLevel: l.INFO }), o === t) {
|
|
242
242
|
var f = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
243
243
|
return t.error((i = f.stack) !== null && i !== void 0 ? i : f.message), !1;
|
|
244
244
|
}
|
|
245
|
-
typeof
|
|
246
|
-
logLevel:
|
|
245
|
+
typeof a == "number" && (a = {
|
|
246
|
+
logLevel: a
|
|
247
247
|
});
|
|
248
|
-
var p = O("diag"), S = Q((s =
|
|
249
|
-
if (p && !
|
|
248
|
+
var p = O("diag"), S = Q((s = a.logLevel) !== null && s !== void 0 ? s : l.INFO, o);
|
|
249
|
+
if (p && !a.suppressOverrideMessage) {
|
|
250
250
|
var G = (c = new Error().stack) !== null && c !== void 0 ? c : "<failed to generate stacktrace>";
|
|
251
251
|
p.warn("Current logger will be overwritten from " + G), S.warn("Current logger will overwrite one already registered from " + G);
|
|
252
252
|
}
|
|
@@ -254,8 +254,8 @@ var Z = function(r, e) {
|
|
|
254
254
|
};
|
|
255
255
|
t.setLogger = n, t.disable = function() {
|
|
256
256
|
I(ee, t);
|
|
257
|
-
}, t.createComponentLogger = function(
|
|
258
|
-
return new J(
|
|
257
|
+
}, t.createComponentLogger = function(o) {
|
|
258
|
+
return new J(o);
|
|
259
259
|
}, t.verbose = e("verbose"), t.debug = e("debug"), t.info = e("info"), t.warn = e("warn"), t.error = e("error");
|
|
260
260
|
}
|
|
261
261
|
return r.instance = function() {
|
|
@@ -265,19 +265,19 @@ var Z = function(r, e) {
|
|
|
265
265
|
), te = function(r, e) {
|
|
266
266
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
267
267
|
if (!t) return r;
|
|
268
|
-
var n = t.call(r),
|
|
268
|
+
var n = t.call(r), o, a = [], i;
|
|
269
269
|
try {
|
|
270
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
270
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
271
271
|
} catch (s) {
|
|
272
272
|
i = { error: s };
|
|
273
273
|
} finally {
|
|
274
274
|
try {
|
|
275
|
-
|
|
275
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
276
276
|
} finally {
|
|
277
277
|
if (i) throw i.error;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
return
|
|
280
|
+
return a;
|
|
281
281
|
}, re = function(r) {
|
|
282
282
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && r[e], n = 0;
|
|
283
283
|
if (t) return t.call(r);
|
|
@@ -299,8 +299,8 @@ var Z = function(r, e) {
|
|
|
299
299
|
return Object.assign({}, t);
|
|
300
300
|
}, r.prototype.getAllEntries = function() {
|
|
301
301
|
return Array.from(this._entries.entries()).map(function(e) {
|
|
302
|
-
var t = te(e, 2), n = t[0],
|
|
303
|
-
return [n,
|
|
302
|
+
var t = te(e, 2), n = t[0], o = t[1];
|
|
303
|
+
return [n, o];
|
|
304
304
|
});
|
|
305
305
|
}, r.prototype.setEntry = function(e, t) {
|
|
306
306
|
var n = new r(this._entries);
|
|
@@ -309,13 +309,13 @@ var Z = function(r, e) {
|
|
|
309
309
|
var t = new r(this._entries);
|
|
310
310
|
return t._entries.delete(e), t;
|
|
311
311
|
}, r.prototype.removeEntries = function() {
|
|
312
|
-
for (var e, t, n = [],
|
|
313
|
-
n[
|
|
314
|
-
var
|
|
312
|
+
for (var e, t, n = [], o = 0; o < arguments.length; o++)
|
|
313
|
+
n[o] = arguments[o];
|
|
314
|
+
var a = new r(this._entries);
|
|
315
315
|
try {
|
|
316
316
|
for (var i = re(n), s = i.next(); !s.done; s = i.next()) {
|
|
317
317
|
var c = s.value;
|
|
318
|
-
|
|
318
|
+
a._entries.delete(c);
|
|
319
319
|
}
|
|
320
320
|
} catch (f) {
|
|
321
321
|
e = { error: f };
|
|
@@ -326,7 +326,7 @@ var Z = function(r, e) {
|
|
|
326
326
|
if (e) throw e.error;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
|
-
return
|
|
329
|
+
return a;
|
|
330
330
|
}, r.prototype.clear = function() {
|
|
331
331
|
return new r();
|
|
332
332
|
}, r;
|
|
@@ -346,12 +346,12 @@ var ie = (
|
|
|
346
346
|
var t = this;
|
|
347
347
|
t._currentContext = e ? new Map(e) : /* @__PURE__ */ new Map(), t.getValue = function(n) {
|
|
348
348
|
return t._currentContext.get(n);
|
|
349
|
-
}, t.setValue = function(n,
|
|
350
|
-
var o = new r(t._currentContext);
|
|
351
|
-
return o._currentContext.set(n, a), o;
|
|
352
|
-
}, t.deleteValue = function(n) {
|
|
349
|
+
}, t.setValue = function(n, o) {
|
|
353
350
|
var a = new r(t._currentContext);
|
|
354
|
-
return a._currentContext.
|
|
351
|
+
return a._currentContext.set(n, o), a;
|
|
352
|
+
}, t.deleteValue = function(n) {
|
|
353
|
+
var o = new r(t._currentContext);
|
|
354
|
+
return o._currentContext.delete(n), o;
|
|
355
355
|
};
|
|
356
356
|
}
|
|
357
357
|
return r;
|
|
@@ -371,23 +371,23 @@ var ie = (
|
|
|
371
371
|
}, le = function(r, e) {
|
|
372
372
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
373
373
|
if (!t) return r;
|
|
374
|
-
var n = t.call(r),
|
|
374
|
+
var n = t.call(r), o, a = [], i;
|
|
375
375
|
try {
|
|
376
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
376
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
377
377
|
} catch (s) {
|
|
378
378
|
i = { error: s };
|
|
379
379
|
} finally {
|
|
380
380
|
try {
|
|
381
|
-
|
|
381
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
382
382
|
} finally {
|
|
383
383
|
if (i) throw i.error;
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
return
|
|
386
|
+
return a;
|
|
387
387
|
}, fe = function(r, e, t) {
|
|
388
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
389
|
-
(
|
|
390
|
-
return r.concat(
|
|
388
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
389
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
390
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
391
391
|
}, pe = (
|
|
392
392
|
/** @class */
|
|
393
393
|
function() {
|
|
@@ -396,9 +396,9 @@ var ie = (
|
|
|
396
396
|
return r.prototype.active = function() {
|
|
397
397
|
return se;
|
|
398
398
|
}, r.prototype.with = function(e, t, n) {
|
|
399
|
-
for (var
|
|
400
|
-
a
|
|
401
|
-
return t.call.apply(t, fe([n], le(
|
|
399
|
+
for (var o = [], a = 3; a < arguments.length; a++)
|
|
400
|
+
o[a - 3] = arguments[a];
|
|
401
|
+
return t.call.apply(t, fe([n], le(o), !1));
|
|
402
402
|
}, r.prototype.bind = function(e, t) {
|
|
403
403
|
return t;
|
|
404
404
|
}, r.prototype.enable = function() {
|
|
@@ -410,24 +410,24 @@ var ie = (
|
|
|
410
410
|
), he = function(r, e) {
|
|
411
411
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
412
412
|
if (!t) return r;
|
|
413
|
-
var n = t.call(r),
|
|
413
|
+
var n = t.call(r), o, a = [], i;
|
|
414
414
|
try {
|
|
415
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
415
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
416
416
|
} catch (s) {
|
|
417
417
|
i = { error: s };
|
|
418
418
|
} finally {
|
|
419
419
|
try {
|
|
420
|
-
|
|
420
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
421
421
|
} finally {
|
|
422
422
|
if (i) throw i.error;
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
|
-
return
|
|
425
|
+
return a;
|
|
426
426
|
}, de = function(r, e, t) {
|
|
427
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
428
|
-
(
|
|
429
|
-
return r.concat(
|
|
430
|
-
}, N = "context", ge = new pe(),
|
|
427
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
428
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
429
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
430
|
+
}, N = "context", ge = new pe(), k = (
|
|
431
431
|
/** @class */
|
|
432
432
|
function() {
|
|
433
433
|
function r() {
|
|
@@ -439,9 +439,9 @@ var ie = (
|
|
|
439
439
|
}, r.prototype.active = function() {
|
|
440
440
|
return this._getContextManager().active();
|
|
441
441
|
}, r.prototype.with = function(e, t, n) {
|
|
442
|
-
for (var
|
|
443
|
-
|
|
444
|
-
return (
|
|
442
|
+
for (var o, a = [], i = 3; i < arguments.length; i++)
|
|
443
|
+
a[i - 3] = arguments[i];
|
|
444
|
+
return (o = this._getContextManager()).with.apply(o, de([e, t, n], he(a), !1));
|
|
445
445
|
}, r.prototype.bind = function(e, t) {
|
|
446
446
|
return this._getContextManager().bind(e, t);
|
|
447
447
|
}, r.prototype._getContextManager = function() {
|
|
@@ -454,7 +454,7 @@ var ie = (
|
|
|
454
454
|
(function(r) {
|
|
455
455
|
r[r.UNSET = 0] = "UNSET", r[r.OK = 1] = "OK", r[r.ERROR = 2] = "ERROR";
|
|
456
456
|
})(R || (R = {}));
|
|
457
|
-
var ve =
|
|
457
|
+
var ve = k.getInstance(), ye = (
|
|
458
458
|
/** @class */
|
|
459
459
|
function() {
|
|
460
460
|
function r() {
|
|
@@ -467,11 +467,11 @@ var ve = K.getInstance(), ye = (
|
|
|
467
467
|
}, r;
|
|
468
468
|
}()
|
|
469
469
|
), M = oe("OpenTelemetry Baggage Key");
|
|
470
|
-
function
|
|
470
|
+
function K(r) {
|
|
471
471
|
return r.getValue(M) || void 0;
|
|
472
472
|
}
|
|
473
473
|
function me() {
|
|
474
|
-
return
|
|
474
|
+
return K(k.getInstance().active());
|
|
475
475
|
}
|
|
476
476
|
function be(r, e) {
|
|
477
477
|
return r.setValue(M, e);
|
|
@@ -483,7 +483,7 @@ var x = "propagation", _e = new ye(), Oe = (
|
|
|
483
483
|
/** @class */
|
|
484
484
|
function() {
|
|
485
485
|
function r() {
|
|
486
|
-
this.createBaggage = ae, this.getBaggage =
|
|
486
|
+
this.createBaggage = ae, this.getBaggage = K, this.getActiveBaggage = me, this.setBaggage = be, this.deleteBaggage = we;
|
|
487
487
|
}
|
|
488
488
|
return r.getInstance = function() {
|
|
489
489
|
return this._instance || (this._instance = new r()), this._instance;
|
|
@@ -560,22 +560,22 @@ const F = ["bench", "debug", "prod"], Ae = (r) => (e) => F.indexOf(e) >= F.index
|
|
|
560
560
|
* rejects the provided span or the Tracer is noop, a NoopSpan is returned.
|
|
561
561
|
*/
|
|
562
562
|
trace(e, t, n) {
|
|
563
|
+
const o = this.meta.noop || !this.filter(t) || this.otelTracer == null;
|
|
563
564
|
if (n == null) {
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
};
|
|
565
|
+
if (o) return () => {
|
|
566
|
+
};
|
|
567
567
|
const a = new V(e, this.otelTracer.startSpan(e));
|
|
568
568
|
return a.start(), () => a.end();
|
|
569
569
|
}
|
|
570
|
-
return
|
|
571
|
-
const
|
|
572
|
-
return n(
|
|
570
|
+
return o ? n(new Ne(e)) : this.otelTracer.startActiveSpan(e, (a) => {
|
|
571
|
+
const i = new V(e, a);
|
|
572
|
+
return n(i);
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
575
|
/**
|
|
576
|
-
* Injects metadata about the current trace into the provided carrier. This
|
|
577
|
-
*
|
|
578
|
-
*
|
|
576
|
+
* Injects metadata about the current trace into the provided carrier. This metadata
|
|
577
|
+
* can be parsed on the other side of a network or IPC request to allow the trace to
|
|
578
|
+
* propagate across services.
|
|
579
579
|
*
|
|
580
580
|
* @param carrier - The carrier to inject the metadata into.
|
|
581
581
|
*/
|
|
@@ -583,8 +583,8 @@ const F = ["bench", "debug", "prod"], Ae = (r) => (e) => F.indexOf(e) >= F.index
|
|
|
583
583
|
if (this.meta.noop) return;
|
|
584
584
|
const t = ve.active();
|
|
585
585
|
Ee.inject(t, e, {
|
|
586
|
-
set: (n,
|
|
587
|
-
n[
|
|
586
|
+
set: (n, o, a) => {
|
|
587
|
+
n[o] = a;
|
|
588
588
|
}
|
|
589
589
|
});
|
|
590
590
|
}
|
|
@@ -615,7 +615,7 @@ class V {
|
|
|
615
615
|
`alamos.trace.start.${this.key}`,
|
|
616
616
|
`alamos.trace.end.${this.key}`
|
|
617
617
|
);
|
|
618
|
-
this.set("duration", e.duration), this.
|
|
618
|
+
this.set("duration", e.duration), this.otel.end();
|
|
619
619
|
} catch (e) {
|
|
620
620
|
console.error(e);
|
|
621
621
|
}
|
|
@@ -636,14 +636,14 @@ const m = class m {
|
|
|
636
636
|
key: e = "",
|
|
637
637
|
serviceName: t = "",
|
|
638
638
|
logger: n = P.NOOP,
|
|
639
|
-
tracer:
|
|
640
|
-
noop:
|
|
639
|
+
tracer: o = T.NOOP,
|
|
640
|
+
noop: a = !1,
|
|
641
641
|
__meta: i
|
|
642
642
|
}) {
|
|
643
643
|
u(this, "meta");
|
|
644
644
|
u(this, "T");
|
|
645
645
|
u(this, "L");
|
|
646
|
-
this.meta = i ?? new b(e, e, t,
|
|
646
|
+
this.meta = i ?? new b(e, e, t, a), this.T = o.child(this.meta), this.L = n.child(this.meta);
|
|
647
647
|
}
|
|
648
648
|
child(e) {
|
|
649
649
|
const t = this.meta.child(e);
|
|
@@ -654,7 +654,7 @@ u(m, "NOOP", new m({ noop: !0 }));
|
|
|
654
654
|
let C = m;
|
|
655
655
|
const Te = C.NOOP;
|
|
656
656
|
export {
|
|
657
|
-
|
|
657
|
+
k as C,
|
|
658
658
|
E as D,
|
|
659
659
|
C as I,
|
|
660
660
|
j as L,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var X=Object.defineProperty;var Y=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>Y(r,typeof e!="symbol"?e+"":e,t);const y=class y{constructor(e,t,n="",o=!1){s(this,"_noop",!1);s(this,"key");s(this,"path");s(this,"serviceName");this.key=e,this.path=t,this.serviceName=n,this._noop=o}child(e){return new y(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};s(y,"NOOP",new y("","",""));let w=y;const B=["debug","info","warn","error"],D=r=>{const e=B.indexOf(r);return({level:t})=>B.indexOf(t)>=e},q=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)))},m=class m{constructor(e={}){s(this,"meta",w.NOOP);s(this,"filters");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 m({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,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)))}};s(m,"NOOP",new m);let N=m;const A=r=>typeof r=="function"?r():r;var z=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},h="1.9.0",K=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function H(r){var e=new Set([r]),t=new Set,n=r.match(K);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(c){return c===r};function a(u){return t.add(u),!1}function i(u){return e.add(u),!0}return function(c){if(e.has(c))return!0;if(t.has(c))return!1;var f=c.match(K);if(!f)return a(c);var p={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return p.prerelease!=null||o.major!==p.major?a(c):o.major===0?o.minor===p.minor&&o.patch<=p.patch?i(c):a(c):o.minor<=p.minor?i(c):a(c)}}var J=H(h),Q=h.split(".")[0],O=Symbol.for("opentelemetry.js.api."+Q),E=z;function R(r,e,t,n){var o;n===void 0&&(n=!1);var a=E[O]=(o=E[O])!==null&&o!==void 0?o:{version:h};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!==h){var i=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+r+" does not match previously registered API v"+h);return t.error(i.stack||i.message),!1}return a[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+h+"."),!0}function g(r){var e,t,n=(e=E[O])===null||e===void 0?void 0:e.version;if(!(!n||!J(n)))return(t=E[O])===null||t===void 0?void 0:t[r]}function T(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+h+".");var t=E[O];t&&delete t[r]}var 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,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))},ee=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,L([],Z(t),!1))}var l;(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"})(l||(l={}));function te(r,e){r<l.NONE?r=l.NONE:r>l.ALL&&(r=l.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",l.ERROR),warn:t("warn",l.WARN),info:t("info",l.INFO),debug:t("debug",l.DEBUG),verbose:t("verbose",l.VERBOSE)}}var re=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},ne=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))},ae="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,ne([],re(a),!1))}}var t=this,n=function(o,a){var i,u,c;if(a===void 0&&(a={logLevel:l.INFO}),o===t){var f=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=f.stack)!==null&&i!==void 0?i:f.message),!1}typeof a=="number"&&(a={logLevel:a});var p=g("diag"),$=te((u=a.logLevel)!==null&&u!==void 0?u:l.INFO,o);if(p&&!a.suppressOverrideMessage){var F=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";p.warn("Current logger will be overwritten from "+F),$.warn("Current logger will overwrite one already registered from "+F)}return R("diag",$,t,!0)};t.setLogger=n,t.disable=function(){T(ae,t)},t.createComponentLogger=function(o){return new ee(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}(),oe=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},ie=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.")},ue=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=oe(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=ie(n),u=i.next();!u.done;u=i.next()){var c=u.value;a._entries.delete(c)}}catch(f){e={error:f}}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 se(r){return r===void 0&&(r={}),new ue(new Map(Object.entries(r)))}function k(r){return Symbol.for(r)}var ce=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}(),le=new ce,fe={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},pe={set:function(r,e,t){r!=null&&(r[e]=t)}},he=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},ge=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))},de=function(){function r(){}return r.prototype.active=function(){return le},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,ge([n],he(o),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r}(),ve=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},ye=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))},C="context",me=new de,M=function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return R(C,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,ye([e,t,n],ve(a),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return g(C)||me},r.prototype.disable=function(){this._getContextManager().disable(),T(C,d.instance())},r}(),G;(function(r){r[r.UNSET=0]="UNSET",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR"})(G||(G={}));var be=M.getInstance(),_e=function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r}(),j=k("OpenTelemetry Baggage Key");function U(r){return r.getValue(j)||void 0}function we(){return U(M.getInstance().active())}function Oe(r,e){return r.setValue(j,e)}function Ee(r){return r.deleteValue(j)}var I="propagation",Ae=new _e,Ne=function(){function r(){this.createBaggage=se,this.getBaggage=U,this.getActiveBaggage=we,this.setBaggage=Oe,this.deleteBaggage=Ee}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return R(I,e,d.instance())},r.prototype.inject=function(e,t,n){return n===void 0&&(n=pe),this._getGlobalPropagator().inject(e,t,n)},r.prototype.extract=function(e,t,n){return n===void 0&&(n=fe),this._getGlobalPropagator().extract(e,t,n)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){T(I,d.instance())},r.prototype._getGlobalPropagator=function(){return g(I)||Ae},r}(),xe=Ne.getInstance();const V=["bench","debug","prod"],Pe=r=>e=>V.indexOf(e)>=V.indexOf(r),b=class b{constructor(e,t=Pe("debug")){s(this,"meta",w.NOOP);s(this,"otelTracer");s(this,"filter");this.otelTracer=e,this.filter=t}child(e){const t=new b(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 S(e,this.otelTracer.startSpan(e));return a.start(),()=>a.end()}return o?n(new W(e)):this.otelTracer.startActiveSpan(e,a=>{const i=new S(e,a);return n(i)})}propagate(e){if(this.meta.noop)return;const t=be.active();xe.inject(t,e,{set:(n,o,a)=>{n[o]=a}})}};s(b,"NOOP",new b);let x=b;class S{constructor(e,t){s(this,"key");s(this,"otel");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:G.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 W{constructor(e){s(this,"key");this.key=e}set(){}recordError(e){}}const _=class _{constructor({key:e="",serviceName:t="",logger:n=N.NOOP,tracer:o=x.NOOP,noop:a=!1,__meta:i}){s(this,"meta");s(this,"T");s(this,"L");this.meta=i??new w(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 _({__meta:t,tracer:this.T,logger:this.L})}};s(_,"NOOP",new _({noop:!0}));let P=_;const Re=P.NOOP;exports.ContextAPI=M;exports.DiagAPI=d;exports.Instrumentation=P;exports.LOG_LEVELS=B;exports.Logger=N;exports.NOOP=Re;exports.NoopSpan=W;exports.Tracer=x;exports._Span=S;exports.createContextKey=k;exports.getGlobal=g;exports.logLevelKeyFiler=q;exports.logThresholdFilter=D;exports.registerGlobal=R;exports.unregisterGlobal=T;
|
package/dist/trace.d.ts
CHANGED
|
@@ -17,18 +17,18 @@ export declare class Tracer {
|
|
|
17
17
|
constructor(tracer?: OtelTracer, filter?: EnvironmentFilter);
|
|
18
18
|
child(meta: Meta): Tracer;
|
|
19
19
|
debug(key: string): Destructor;
|
|
20
|
-
debug<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
20
|
+
debug<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
21
21
|
bench(key: string): Destructor;
|
|
22
|
-
bench<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
22
|
+
bench<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
23
23
|
prod(key: string): Destructor;
|
|
24
|
-
prod<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
25
|
-
trace<F extends SpanF>(key: string, env: Environment, f?: F): ReturnType<F> | Destructor;
|
|
24
|
+
prod<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
26
25
|
trace(key: string, env: Environment): Destructor;
|
|
27
|
-
trace<F extends SpanF>(key: string, env: Environment, f: F): ReturnType<F
|
|
26
|
+
trace<F extends SpanF>(key: string, env: Environment, f: F): ReturnType<F>;
|
|
27
|
+
trace<F extends SpanF>(key: string, env: Environment, f?: F): ReturnType<F> | Destructor;
|
|
28
28
|
/**
|
|
29
|
-
* Injects metadata about the current trace into the provided carrier. This
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* Injects metadata about the current trace into the provided carrier. This metadata
|
|
30
|
+
* can be parsed on the other side of a network or IPC request to allow the trace to
|
|
31
|
+
* propagate across services.
|
|
32
32
|
*
|
|
33
33
|
* @param carrier - The carrier to inject the metadata into.
|
|
34
34
|
*/
|
package/dist/trace.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,IAAI,IAAI,QAAQ,EAErB,KAAK,MAAM,IAAI,UAAU,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gFAAgF;AAChF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7C,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;AAE5C;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAGzC,MAAM,CAAC,EAAE,UAAU,EACnB,MAAM,GAAE,iBAA+C;IAMzD,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAMzB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAC9B,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,IAAI,IAAI,QAAQ,EAErB,KAAK,MAAM,IAAI,UAAU,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAEvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,gFAAgF;AAChF,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7C,kDAAkD;AAClD,MAAM,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;AAE5C;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;gBAGzC,MAAM,CAAC,EAAE,UAAU,EACnB,MAAM,GAAE,iBAA+C;IAMzD,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAMzB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAC9B,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAexD,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAC9B,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAexD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAC7B,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAevD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,UAAU;IAChD,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC1E,KAAK,CAAC,CAAC,SAAS,KAAK,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,WAAW,EAChB,CAAC,CAAC,EAAE,CAAC,GACJ,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU;IAiC7B;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAUjC,8CAA8C;IAC9C,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAgB;CACrC;AAED,qEAAqE;AACrE,MAAM,WAAW,IAAI;IACnB;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACnD;AAED,qBAAa,KAAM,YAAW,IAAI;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAW;gBAEpB,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ;IAKvC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI;IAI7C,WAAW,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;IAMvC,KAAK,IAAI,IAAI;IAIb,GAAG,IAAI,IAAI;CAcZ;AAED,4CAA4C;AAC5C,qBAAa,QAAS,YAAW,IAAI;IACnC,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,EAAE,MAAM;IAIvB,GAAG,IAAI,IAAI;IAEX,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI;CACpC"}
|
package/eslint.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/alamos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Distributed instrumentation for Synnax",
|
|
6
6
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/freighter/ts",
|
|
@@ -14,22 +14,19 @@
|
|
|
14
14
|
"telemetry",
|
|
15
15
|
"control systems"
|
|
16
16
|
],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=18"
|
|
19
|
-
},
|
|
20
17
|
"dependencies": {
|
|
21
18
|
"@opentelemetry/api": "^1.9.0",
|
|
22
|
-
"@synnaxlabs/x": "0.
|
|
19
|
+
"@synnaxlabs/x": "0.43.0"
|
|
23
20
|
},
|
|
24
21
|
"devDependencies": {
|
|
25
|
-
"eslint": "^9.
|
|
22
|
+
"eslint": "^9.28.0",
|
|
26
23
|
"madge": "^8.0.0",
|
|
27
24
|
"typescript": "^5.8.3",
|
|
28
|
-
"vite": "^6.
|
|
29
|
-
"vitest": "^3.
|
|
25
|
+
"vite": "^6.3.5",
|
|
26
|
+
"vitest": "^3.2.3",
|
|
30
27
|
"@synnaxlabs/tsconfig": "0.0.2",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
28
|
+
"eslint-config-synnaxlabs": "0.43.0",
|
|
29
|
+
"@synnaxlabs/vite-plugin": "0.43.0"
|
|
33
30
|
},
|
|
34
31
|
"main": "dist/index.js",
|
|
35
32
|
"module": "dist/index.js",
|
|
@@ -46,6 +43,7 @@
|
|
|
46
43
|
}
|
|
47
44
|
},
|
|
48
45
|
"scripts": {
|
|
46
|
+
"check-types": "tsc --noEmit",
|
|
49
47
|
"build": "tsc --noEmit && vite build",
|
|
50
48
|
"watch": "tsc --noEmit && vite build --watch",
|
|
51
49
|
"test": "vitest",
|
package/src/trace.ts
CHANGED
|
@@ -54,7 +54,7 @@ export class Tracer {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
debug(key: string): Destructor;
|
|
57
|
-
debug<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
57
|
+
debug<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Starts a new span in the debug environment. If a span already exists in the
|
|
@@ -70,7 +70,7 @@ export class Tracer {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
bench(key: string): Destructor;
|
|
73
|
-
bench<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
73
|
+
bench<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Starts a new span in the bench environment. If a span already exists in the
|
|
@@ -86,7 +86,7 @@ export class Tracer {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
prod(key: string): Destructor;
|
|
89
|
-
prod<F extends SpanF>(key: string, f: F): ReturnType<F
|
|
89
|
+
prod<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Starts a new span in the prod environment. If a span already exists in the
|
|
@@ -100,16 +100,13 @@ export class Tracer {
|
|
|
100
100
|
prod<F extends SpanF>(key: string, f?: F): ReturnType<F> | Destructor {
|
|
101
101
|
return this.trace(key, "prod", f);
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
key: string,
|
|
105
|
-
env: Environment,
|
|
106
|
-
f?: F,
|
|
107
|
-
): ReturnType<F> | Destructor;
|
|
103
|
+
|
|
108
104
|
trace(key: string, env: Environment): Destructor;
|
|
105
|
+
trace<F extends SpanF>(key: string, env: Environment, f: F): ReturnType<F>;
|
|
109
106
|
trace<F extends SpanF>(
|
|
110
107
|
key: string,
|
|
111
108
|
env: Environment,
|
|
112
|
-
f
|
|
109
|
+
f?: F,
|
|
113
110
|
): ReturnType<F> | Destructor;
|
|
114
111
|
|
|
115
112
|
/**
|
|
@@ -127,16 +124,15 @@ export class Tracer {
|
|
|
127
124
|
env: Environment,
|
|
128
125
|
f?: F,
|
|
129
126
|
): ReturnType<F> | Destructor {
|
|
127
|
+
const skip = this.meta.noop || !this.filter(env) || this.otelTracer == null;
|
|
130
128
|
if (f == null) {
|
|
131
|
-
if (
|
|
132
|
-
return () => {};
|
|
129
|
+
if (skip) return () => {};
|
|
133
130
|
const span = new _Span(key, this.otelTracer.startSpan(key));
|
|
134
131
|
span.start();
|
|
135
132
|
return () => span.end();
|
|
136
133
|
}
|
|
137
134
|
|
|
138
|
-
if (
|
|
139
|
-
return f(new NoopSpan(key)) as ReturnType<F>;
|
|
135
|
+
if (skip) return f(new NoopSpan(key)) as ReturnType<F>;
|
|
140
136
|
return this.otelTracer.startActiveSpan(key, (otelSpan) => {
|
|
141
137
|
const span = new _Span(key, otelSpan);
|
|
142
138
|
const result = f(span);
|
|
@@ -145,9 +141,9 @@ export class Tracer {
|
|
|
145
141
|
}
|
|
146
142
|
|
|
147
143
|
/**
|
|
148
|
-
* Injects metadata about the current trace into the provided carrier. This
|
|
149
|
-
*
|
|
150
|
-
*
|
|
144
|
+
* Injects metadata about the current trace into the provided carrier. This metadata
|
|
145
|
+
* can be parsed on the other side of a network or IPC request to allow the trace to
|
|
146
|
+
* propagate across services.
|
|
151
147
|
*
|
|
152
148
|
* @param carrier - The carrier to inject the metadata into.
|
|
153
149
|
*/
|
|
@@ -218,7 +214,6 @@ export class _Span implements Span {
|
|
|
218
214
|
`alamos.trace.end.${this.key}`,
|
|
219
215
|
);
|
|
220
216
|
this.set("duration", duration.duration);
|
|
221
|
-
this.set("duration", duration.duration);
|
|
222
217
|
this.otel.end();
|
|
223
218
|
} catch (e) {
|
|
224
219
|
console.error(e);
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var X=Object.defineProperty;var Y=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>Y(r,typeof e!="symbol"?e+"":e,t);const y=class y{constructor(e,t,n="",a=!1){s(this,"_noop",!1);s(this,"key");s(this,"path");s(this,"serviceName");this.key=e,this.path=t,this.serviceName=n,this._noop=a}child(e){return new y(e,this.extendPath(e),this.serviceName,this.noop)}extendPath(e){return`${this.path}.${e}`}get noop(){return this._noop}};s(y,"NOOP",new y("","",""));let w=y;const B=["debug","info","warn","error"],D=r=>{const e=B.indexOf(r);return({level:t})=>B.indexOf(t)>=e},q=r=>{const{include:e,exclude:t}=r;return({path:n})=>!(e!=null&&!e.some(a=>n.startsWith(a))||t!=null&&t.some(a=>n.startsWith(a)))},m=class m{constructor(e={}){s(this,"meta",w.NOOP);s(this,"filters");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 m({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,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)))}};s(m,"NOOP",new m);let N=m;const A=r=>typeof r=="function"?r():r;var z=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},h="1.9.0",K=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function H(r){var e=new Set([r]),t=new Set,n=r.match(K);if(!n)return function(){return!1};var a={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(a.prerelease!=null)return function(l){return l===r};function o(u){return t.add(u),!1}function i(u){return e.add(u),!0}return function(l){if(e.has(l))return!0;if(t.has(l))return!1;var f=l.match(K);if(!f)return o(l);var p={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return p.prerelease!=null||a.major!==p.major?o(l):a.major===0?a.minor===p.minor&&a.patch<=p.patch?i(l):o(l):a.minor<=p.minor?i(l):o(l)}}var J=H(h),Q=h.split(".")[0],O=Symbol.for("opentelemetry.js.api."+Q),E=z;function R(r,e,t,n){var a;n===void 0&&(n=!1);var o=E[O]=(a=E[O])!==null&&a!==void 0?a:{version:h};if(!n&&o[r]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+r);return t.error(i.stack||i.message),!1}if(o.version!==h){var i=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+r+" does not match previously registered API v"+h);return t.error(i.stack||i.message),!1}return o[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+h+"."),!0}function d(r){var e,t,n=(e=E[O])===null||e===void 0?void 0:e.version;if(!(!n||!J(n)))return(t=E[O])===null||t===void 0?void 0:t[r]}function T(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+h+".");var t=E[O];t&&delete t[r]}var Z=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,o=[],i;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(u){i={error:u}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},L=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,o;n<a;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},ee=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=d("diag");if(n)return t.unshift(e),n[r].apply(n,L([],Z(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 te(r,e){r<c.NONE?r=c.NONE:r>c.ALL&&(r=c.ALL),e=e||{};function t(n,a){var o=e[n];return typeof o=="function"&&r>=a?o.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 re=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,o=[],i;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(u){i={error:u}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},ne=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,o;n<a;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},ae="diag",g=function(){function r(){function e(a){return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var u=d("diag");if(u)return u[a].apply(u,ne([],re(o),!1))}}var t=this,n=function(a,o){var i,u,l;if(o===void 0&&(o={logLevel:c.INFO}),a===t){var f=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=f.stack)!==null&&i!==void 0?i:f.message),!1}typeof o=="number"&&(o={logLevel:o});var p=d("diag"),$=te((u=o.logLevel)!==null&&u!==void 0?u:c.INFO,a);if(p&&!o.suppressOverrideMessage){var F=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";p.warn("Current logger will be overwritten from "+F),$.warn("Current logger will overwrite one already registered from "+F)}return R("diag",$,t,!0)};t.setLogger=n,t.disable=function(){T(ae,t)},t.createComponentLogger=function(a){return new ee(a)},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}(),oe=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,o=[],i;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(u){i={error:u}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},ie=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.")},ue=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=oe(e,2),n=t[0],a=t[1];return[n,a]})},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=[],a=0;a<arguments.length;a++)n[a]=arguments[a];var o=new r(this._entries);try{for(var i=ie(n),u=i.next();!u.done;u=i.next()){var l=u.value;o._entries.delete(l)}}catch(f){e={error:f}}finally{try{u&&!u.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}return o},r.prototype.clear=function(){return new r},r}();g.instance();function se(r){return r===void 0&&(r={}),new ue(new Map(Object.entries(r)))}function U(r){return Symbol.for(r)}var le=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,a){var o=new r(t._currentContext);return o._currentContext.set(n,a),o},t.deleteValue=function(n){var a=new r(t._currentContext);return a._currentContext.delete(n),a}}return r}(),ce=new le,fe={get:function(r,e){if(r!=null)return r[e]},keys:function(r){return r==null?[]:Object.keys(r)}},pe={set:function(r,e,t){r!=null&&(r[e]=t)}},he=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,o=[],i;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(u){i={error:u}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},de=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,o;n<a;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},ge=function(){function r(){}return r.prototype.active=function(){return ce},r.prototype.with=function(e,t,n){for(var a=[],o=3;o<arguments.length;o++)a[o-3]=arguments[o];return t.call.apply(t,de([n],he(a),!1))},r.prototype.bind=function(e,t){return t},r.prototype.enable=function(){return this},r.prototype.disable=function(){return this},r}(),ve=function(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),a,o=[],i;try{for(;(e===void 0||e-- >0)&&!(a=n.next()).done;)o.push(a.value)}catch(u){i={error:u}}finally{try{a&&!a.done&&(t=n.return)&&t.call(n)}finally{if(i)throw i.error}}return o},ye=function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,o;n<a;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},C="context",me=new ge,M=function(){function r(){}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalContextManager=function(e){return R(C,e,g.instance())},r.prototype.active=function(){return this._getContextManager().active()},r.prototype.with=function(e,t,n){for(var a,o=[],i=3;i<arguments.length;i++)o[i-3]=arguments[i];return(a=this._getContextManager()).with.apply(a,ye([e,t,n],ve(o),!1))},r.prototype.bind=function(e,t){return this._getContextManager().bind(e,t)},r.prototype._getContextManager=function(){return d(C)||me},r.prototype.disable=function(){this._getContextManager().disable(),T(C,g.instance())},r}(),G;(function(r){r[r.UNSET=0]="UNSET",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR"})(G||(G={}));var be=M.getInstance(),_e=function(){function r(){}return r.prototype.inject=function(e,t){},r.prototype.extract=function(e,t){return e},r.prototype.fields=function(){return[]},r}(),j=U("OpenTelemetry Baggage Key");function k(r){return r.getValue(j)||void 0}function we(){return k(M.getInstance().active())}function Oe(r,e){return r.setValue(j,e)}function Ee(r){return r.deleteValue(j)}var I="propagation",Ae=new _e,Ne=function(){function r(){this.createBaggage=se,this.getBaggage=k,this.getActiveBaggage=we,this.setBaggage=Oe,this.deleteBaggage=Ee}return r.getInstance=function(){return this._instance||(this._instance=new r),this._instance},r.prototype.setGlobalPropagator=function(e){return R(I,e,g.instance())},r.prototype.inject=function(e,t,n){return n===void 0&&(n=pe),this._getGlobalPropagator().inject(e,t,n)},r.prototype.extract=function(e,t,n){return n===void 0&&(n=fe),this._getGlobalPropagator().extract(e,t,n)},r.prototype.fields=function(){return this._getGlobalPropagator().fields()},r.prototype.disable=function(){T(I,g.instance())},r.prototype._getGlobalPropagator=function(){return d(I)||Ae},r}(),xe=Ne.getInstance();const V=["bench","debug","prod"],Pe=r=>e=>V.indexOf(e)>=V.indexOf(r),b=class b{constructor(e,t=Pe("debug")){s(this,"meta",w.NOOP);s(this,"otelTracer");s(this,"filter");this.otelTracer=e,this.filter=t}child(e){const t=new b(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){if(n==null){if(this.meta.noop||!this.filter(t)||this.otelTracer==null)return()=>{};const a=new S(e,this.otelTracer.startSpan(e));return a.start(),()=>a.end()}return this.meta.noop||!this.filter(t)||this.otelTracer==null?n(new W(e)):this.otelTracer.startActiveSpan(e,a=>{const o=new S(e,a);return n(o)})}propagate(e){if(this.meta.noop)return;const t=be.active();xe.inject(t,e,{set:(n,a,o)=>{n[a]=o}})}};s(b,"NOOP",new b);let x=b;class S{constructor(e,t){s(this,"key");s(this,"otel");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:G.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.set("duration",e.duration),this.otel.end()}catch(e){console.error(e)}}}class W{constructor(e){s(this,"key");this.key=e}set(){}recordError(e){}}const _=class _{constructor({key:e="",serviceName:t="",logger:n=N.NOOP,tracer:a=x.NOOP,noop:o=!1,__meta:i}){s(this,"meta");s(this,"T");s(this,"L");this.meta=i??new w(e,e,t,o),this.T=a.child(this.meta),this.L=n.child(this.meta)}child(e){const t=this.meta.child(e);return new _({__meta:t,tracer:this.T,logger:this.L})}};s(_,"NOOP",new _({noop:!0}));let P=_;const Re=P.NOOP;exports.ContextAPI=M;exports.DiagAPI=g;exports.Instrumentation=P;exports.LOG_LEVELS=B;exports.Logger=N;exports.NOOP=Re;exports.NoopSpan=W;exports.Tracer=x;exports._Span=S;exports.createContextKey=U;exports.getGlobal=d;exports.logLevelKeyFiler=q;exports.logThresholdFilter=D;exports.registerGlobal=R;exports.unregisterGlobal=T;
|