@synnaxlabs/alamos 0.42.3 → 0.44.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 +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/{instrumentation-1jARg32o.js → instrumentation-Bmq0SwpZ.js} +255 -260
- package/dist/instrumentation-CGaKhn8G.cjs +1 -0
- package/dist/log.d.ts +2 -2
- package/dist/log.d.ts.map +1 -1
- package/dist/trace.d.ts +8 -8
- package/dist/trace.d.ts.map +1 -1
- package/eslint.config.js +1 -1
- package/package.json +11 -13
- package/src/log.ts +3 -3
- 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-CGaKhn8G.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?.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-Bmq0SwpZ.js";
|
|
2
2
|
var f;
|
|
3
3
|
(function(t) {
|
|
4
4
|
t[t.NONE = 0] = "NONE", t[t.SAMPLED = 1] = "SAMPLED";
|
|
@@ -75,7 +75,7 @@ var c = T.getInstance(), x = (
|
|
|
75
75
|
}
|
|
76
76
|
return t.prototype.startSpan = function(e, r, n) {
|
|
77
77
|
n === void 0 && (n = c.active());
|
|
78
|
-
var a = !!
|
|
78
|
+
var a = !!r?.root;
|
|
79
79
|
if (a)
|
|
80
80
|
return new i();
|
|
81
81
|
var o = n && A(n);
|
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-CGaKhn8G.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-Bmq0SwpZ.js";
|
|
2
2
|
const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
Instrumentation: e,
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
u(this, "path");
|
|
9
|
-
u(this, "serviceName");
|
|
10
|
-
this.key = e, this.path = t, this.serviceName = n, this._noop = a;
|
|
1
|
+
class h {
|
|
2
|
+
_noop = !1;
|
|
3
|
+
key;
|
|
4
|
+
path;
|
|
5
|
+
serviceName;
|
|
6
|
+
constructor(e, t, n = "", o = !1) {
|
|
7
|
+
this.key = e, this.path = t, this.serviceName = n, this._noop = o;
|
|
11
8
|
}
|
|
12
9
|
child(e) {
|
|
13
|
-
return new
|
|
10
|
+
return new h(e, this.extendPath(e), this.serviceName, this.noop);
|
|
14
11
|
}
|
|
15
12
|
extendPath(e) {
|
|
16
13
|
return `${this.path}.${e}`;
|
|
@@ -18,19 +15,19 @@ const g = class g {
|
|
|
18
15
|
get noop() {
|
|
19
16
|
return this._noop;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, Re = (r) => {
|
|
18
|
+
static NOOP = new h("", "", "");
|
|
19
|
+
}
|
|
20
|
+
const I = ["debug", "info", "warn", "error"], be = (r) => {
|
|
21
|
+
const e = I.indexOf(r);
|
|
22
|
+
return ({ level: t }) => I.indexOf(t) >= e;
|
|
23
|
+
}, _e = (r) => {
|
|
28
24
|
const { include: e, exclude: t } = r;
|
|
29
|
-
return ({ path: n }) => !(e != null && !e.some((
|
|
30
|
-
}
|
|
25
|
+
return ({ path: n }) => !(e != null && !e.some((o) => n.startsWith(o)) || t != null && t.some((o) => n.startsWith(o)));
|
|
26
|
+
};
|
|
27
|
+
class _ {
|
|
28
|
+
meta = h.NOOP;
|
|
29
|
+
filters;
|
|
31
30
|
constructor(e = {}) {
|
|
32
|
-
u(this, "meta", b.NOOP);
|
|
33
|
-
u(this, "filters");
|
|
34
31
|
const { filters: t = [] } = e;
|
|
35
32
|
this.filters = t;
|
|
36
33
|
}
|
|
@@ -44,113 +41,112 @@ const j = ["debug", "info", "warn", "error"], Pe = (r) => {
|
|
|
44
41
|
);
|
|
45
42
|
}
|
|
46
43
|
child(e) {
|
|
47
|
-
const t = new
|
|
44
|
+
const t = new _({ filters: this.filters });
|
|
48
45
|
return t.meta = e, t;
|
|
49
46
|
}
|
|
50
47
|
debug(e, t, n = !1) {
|
|
51
|
-
!this.filter("debug") && !n || (t == null ? console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e) : console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e,
|
|
48
|
+
!this.filter("debug") && !n || (t == null ? console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e) : console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e, b(t)));
|
|
52
49
|
}
|
|
53
50
|
info(e, t, n = !1) {
|
|
54
|
-
!this.filter("info") && !n || (t == null ? console.log("%cINFO", "color: #005eff;", this.meta.path, e) : console.log("%cINFO", "color: #005eff;", this.meta.path, e,
|
|
51
|
+
!this.filter("info") && !n || (t == null ? console.log("%cINFO", "color: #005eff;", this.meta.path, e) : console.log("%cINFO", "color: #005eff;", this.meta.path, e, b(t)));
|
|
55
52
|
}
|
|
56
53
|
warn(e, t, n = !1) {
|
|
57
|
-
!this.filter("warn") && !n || (t == null ? console.warn("WARN", this.meta.path, e) : console.warn("WARN", this.meta.path, e,
|
|
54
|
+
!this.filter("warn") && !n || (t == null ? console.warn("WARN", this.meta.path, e) : console.warn("WARN", this.meta.path, e, b(t)));
|
|
58
55
|
}
|
|
59
56
|
error(e, t, n = !1) {
|
|
60
|
-
!this.filter("error") && !n || (t == null ? console.error("ERROR", this.meta.path, e) : console.error("ERROR", this.meta.path, e,
|
|
57
|
+
!this.filter("error") && !n || (t == null ? console.error("ERROR", this.meta.path, e) : console.error("ERROR", this.meta.path, e, b(t)));
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var e = /* @__PURE__ */ new Set([r]), t = /* @__PURE__ */ new Set(), n = r.match($);
|
|
59
|
+
static NOOP = new _();
|
|
60
|
+
}
|
|
61
|
+
const b = (r) => typeof r == "function" ? r() : r;
|
|
62
|
+
var $ = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {}, p = "1.9.0", B = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
63
|
+
function F(r) {
|
|
64
|
+
var e = /* @__PURE__ */ new Set([r]), t = /* @__PURE__ */ new Set(), n = r.match(B);
|
|
69
65
|
if (!n)
|
|
70
66
|
return function() {
|
|
71
67
|
return !1;
|
|
72
68
|
};
|
|
73
|
-
var
|
|
69
|
+
var o = {
|
|
74
70
|
major: +n[1],
|
|
75
71
|
minor: +n[2],
|
|
76
72
|
patch: +n[3],
|
|
77
73
|
prerelease: n[4]
|
|
78
74
|
};
|
|
79
|
-
if (
|
|
80
|
-
return function(
|
|
81
|
-
return
|
|
75
|
+
if (o.prerelease != null)
|
|
76
|
+
return function(u) {
|
|
77
|
+
return u === r;
|
|
82
78
|
};
|
|
83
|
-
function
|
|
79
|
+
function a(s) {
|
|
84
80
|
return t.add(s), !1;
|
|
85
81
|
}
|
|
86
82
|
function i(s) {
|
|
87
83
|
return e.add(s), !0;
|
|
88
84
|
}
|
|
89
|
-
return function(
|
|
90
|
-
if (e.has(
|
|
85
|
+
return function(u) {
|
|
86
|
+
if (e.has(u))
|
|
91
87
|
return !0;
|
|
92
|
-
if (t.has(
|
|
88
|
+
if (t.has(u))
|
|
93
89
|
return !1;
|
|
94
|
-
var
|
|
95
|
-
if (!
|
|
96
|
-
return
|
|
97
|
-
var
|
|
98
|
-
major: +
|
|
99
|
-
minor: +
|
|
100
|
-
patch: +
|
|
101
|
-
prerelease:
|
|
90
|
+
var l = u.match(B);
|
|
91
|
+
if (!l)
|
|
92
|
+
return a(u);
|
|
93
|
+
var f = {
|
|
94
|
+
major: +l[1],
|
|
95
|
+
minor: +l[2],
|
|
96
|
+
patch: +l[3],
|
|
97
|
+
prerelease: l[4]
|
|
102
98
|
};
|
|
103
|
-
return
|
|
99
|
+
return f.prerelease != null || o.major !== f.major ? a(u) : o.major === 0 ? o.minor === f.minor && o.patch <= f.patch ? i(u) : a(u) : o.minor <= f.minor ? i(u) : a(u);
|
|
104
100
|
};
|
|
105
101
|
}
|
|
106
|
-
var
|
|
107
|
-
function
|
|
108
|
-
var
|
|
102
|
+
var V = F(p), k = p.split(".")[0], g = Symbol.for("opentelemetry.js.api." + k), v = $;
|
|
103
|
+
function x(r, e, t, n) {
|
|
104
|
+
var o;
|
|
109
105
|
n === void 0 && (n = !1);
|
|
110
|
-
var
|
|
111
|
-
version:
|
|
106
|
+
var a = v[g] = (o = v[g]) !== null && o !== void 0 ? o : {
|
|
107
|
+
version: p
|
|
112
108
|
};
|
|
113
|
-
if (!n &&
|
|
109
|
+
if (!n && a[r]) {
|
|
114
110
|
var i = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + r);
|
|
115
111
|
return t.error(i.stack || i.message), !1;
|
|
116
112
|
}
|
|
117
|
-
if (
|
|
118
|
-
var i = new Error("@opentelemetry/api: Registration of version v" +
|
|
113
|
+
if (a.version !== p) {
|
|
114
|
+
var i = new Error("@opentelemetry/api: Registration of version v" + a.version + " for " + r + " does not match previously registered API v" + p);
|
|
119
115
|
return t.error(i.stack || i.message), !1;
|
|
120
116
|
}
|
|
121
|
-
return
|
|
117
|
+
return a[r] = e, t.debug("@opentelemetry/api: Registered a global for " + r + " v" + p + "."), !0;
|
|
122
118
|
}
|
|
123
|
-
function
|
|
124
|
-
var e, t, n = (e =
|
|
125
|
-
if (!(!n || !
|
|
126
|
-
return (t =
|
|
119
|
+
function y(r) {
|
|
120
|
+
var e, t, n = (e = v[g]) === null || e === void 0 ? void 0 : e.version;
|
|
121
|
+
if (!(!n || !V(n)))
|
|
122
|
+
return (t = v[g]) === null || t === void 0 ? void 0 : t[r];
|
|
127
123
|
}
|
|
128
|
-
function
|
|
129
|
-
e.debug("@opentelemetry/api: Unregistering a global for " + r + " v" +
|
|
130
|
-
var t =
|
|
124
|
+
function P(r, e) {
|
|
125
|
+
e.debug("@opentelemetry/api: Unregistering a global for " + r + " v" + p + ".");
|
|
126
|
+
var t = v[g];
|
|
131
127
|
t && delete t[r];
|
|
132
128
|
}
|
|
133
|
-
var
|
|
129
|
+
var K = function(r, e) {
|
|
134
130
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
135
131
|
if (!t) return r;
|
|
136
|
-
var n = t.call(r),
|
|
132
|
+
var n = t.call(r), o, a = [], i;
|
|
137
133
|
try {
|
|
138
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
134
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
139
135
|
} catch (s) {
|
|
140
136
|
i = { error: s };
|
|
141
137
|
} finally {
|
|
142
138
|
try {
|
|
143
|
-
|
|
139
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
144
140
|
} finally {
|
|
145
141
|
if (i) throw i.error;
|
|
146
142
|
}
|
|
147
143
|
}
|
|
148
|
-
return
|
|
149
|
-
},
|
|
150
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
151
|
-
(
|
|
152
|
-
return r.concat(
|
|
153
|
-
},
|
|
144
|
+
return a;
|
|
145
|
+
}, U = function(r, e, t) {
|
|
146
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
147
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
148
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
149
|
+
}, W = (
|
|
154
150
|
/** @class */
|
|
155
151
|
function() {
|
|
156
152
|
function r(e) {
|
|
@@ -180,105 +176,105 @@ var z = function(r, e) {
|
|
|
180
176
|
}()
|
|
181
177
|
);
|
|
182
178
|
function d(r, e, t) {
|
|
183
|
-
var n =
|
|
179
|
+
var n = y("diag");
|
|
184
180
|
if (n)
|
|
185
|
-
return t.unshift(e), n[r].apply(n,
|
|
181
|
+
return t.unshift(e), n[r].apply(n, U([], K(t), !1));
|
|
186
182
|
}
|
|
187
|
-
var
|
|
183
|
+
var c;
|
|
188
184
|
(function(r) {
|
|
189
185
|
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";
|
|
190
|
-
})(
|
|
191
|
-
function
|
|
192
|
-
r <
|
|
193
|
-
function t(n,
|
|
194
|
-
var
|
|
195
|
-
return typeof
|
|
186
|
+
})(c || (c = {}));
|
|
187
|
+
function X(r, e) {
|
|
188
|
+
r < c.NONE ? r = c.NONE : r > c.ALL && (r = c.ALL), e = e || {};
|
|
189
|
+
function t(n, o) {
|
|
190
|
+
var a = e[n];
|
|
191
|
+
return typeof a == "function" && r >= o ? a.bind(e) : function() {
|
|
196
192
|
};
|
|
197
193
|
}
|
|
198
194
|
return {
|
|
199
|
-
error: t("error",
|
|
200
|
-
warn: t("warn",
|
|
201
|
-
info: t("info",
|
|
202
|
-
debug: t("debug",
|
|
203
|
-
verbose: t("verbose",
|
|
195
|
+
error: t("error", c.ERROR),
|
|
196
|
+
warn: t("warn", c.WARN),
|
|
197
|
+
info: t("info", c.INFO),
|
|
198
|
+
debug: t("debug", c.DEBUG),
|
|
199
|
+
verbose: t("verbose", c.VERBOSE)
|
|
204
200
|
};
|
|
205
201
|
}
|
|
206
|
-
var
|
|
202
|
+
var Y = function(r, e) {
|
|
207
203
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
208
204
|
if (!t) return r;
|
|
209
|
-
var n = t.call(r),
|
|
205
|
+
var n = t.call(r), o, a = [], i;
|
|
210
206
|
try {
|
|
211
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
207
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
212
208
|
} catch (s) {
|
|
213
209
|
i = { error: s };
|
|
214
210
|
} finally {
|
|
215
211
|
try {
|
|
216
|
-
|
|
212
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
217
213
|
} finally {
|
|
218
214
|
if (i) throw i.error;
|
|
219
215
|
}
|
|
220
216
|
}
|
|
221
|
-
return
|
|
222
|
-
},
|
|
223
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
224
|
-
(
|
|
225
|
-
return r.concat(
|
|
226
|
-
},
|
|
217
|
+
return a;
|
|
218
|
+
}, D = function(r, e, t) {
|
|
219
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
220
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
221
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
222
|
+
}, q = "diag", m = (
|
|
227
223
|
/** @class */
|
|
228
224
|
function() {
|
|
229
225
|
function r() {
|
|
230
|
-
function e(
|
|
226
|
+
function e(o) {
|
|
231
227
|
return function() {
|
|
232
|
-
for (var
|
|
233
|
-
|
|
234
|
-
var s =
|
|
228
|
+
for (var a = [], i = 0; i < arguments.length; i++)
|
|
229
|
+
a[i] = arguments[i];
|
|
230
|
+
var s = y("diag");
|
|
235
231
|
if (s)
|
|
236
|
-
return s[
|
|
232
|
+
return s[o].apply(s, D([], Y(a), !1));
|
|
237
233
|
};
|
|
238
234
|
}
|
|
239
|
-
var t = this, n = function(
|
|
240
|
-
var i, s,
|
|
241
|
-
if (
|
|
242
|
-
var
|
|
243
|
-
return t.error((i =
|
|
235
|
+
var t = this, n = function(o, a) {
|
|
236
|
+
var i, s, u;
|
|
237
|
+
if (a === void 0 && (a = { logLevel: c.INFO }), o === t) {
|
|
238
|
+
var l = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
239
|
+
return t.error((i = l.stack) !== null && i !== void 0 ? i : l.message), !1;
|
|
244
240
|
}
|
|
245
|
-
typeof
|
|
246
|
-
logLevel:
|
|
241
|
+
typeof a == "number" && (a = {
|
|
242
|
+
logLevel: a
|
|
247
243
|
});
|
|
248
|
-
var
|
|
249
|
-
if (
|
|
250
|
-
var
|
|
251
|
-
|
|
244
|
+
var f = y("diag"), T = X((s = a.logLevel) !== null && s !== void 0 ? s : c.INFO, o);
|
|
245
|
+
if (f && !a.suppressOverrideMessage) {
|
|
246
|
+
var C = (u = new Error().stack) !== null && u !== void 0 ? u : "<failed to generate stacktrace>";
|
|
247
|
+
f.warn("Current logger will be overwritten from " + C), T.warn("Current logger will overwrite one already registered from " + C);
|
|
252
248
|
}
|
|
253
|
-
return
|
|
249
|
+
return x("diag", T, t, !0);
|
|
254
250
|
};
|
|
255
251
|
t.setLogger = n, t.disable = function() {
|
|
256
|
-
|
|
257
|
-
}, t.createComponentLogger = function(
|
|
258
|
-
return new
|
|
252
|
+
P(q, t);
|
|
253
|
+
}, t.createComponentLogger = function(o) {
|
|
254
|
+
return new W(o);
|
|
259
255
|
}, t.verbose = e("verbose"), t.debug = e("debug"), t.info = e("info"), t.warn = e("warn"), t.error = e("error");
|
|
260
256
|
}
|
|
261
257
|
return r.instance = function() {
|
|
262
258
|
return this._instance || (this._instance = new r()), this._instance;
|
|
263
259
|
}, r;
|
|
264
260
|
}()
|
|
265
|
-
),
|
|
261
|
+
), z = function(r, e) {
|
|
266
262
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
267
263
|
if (!t) return r;
|
|
268
|
-
var n = t.call(r),
|
|
264
|
+
var n = t.call(r), o, a = [], i;
|
|
269
265
|
try {
|
|
270
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
266
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
271
267
|
} catch (s) {
|
|
272
268
|
i = { error: s };
|
|
273
269
|
} finally {
|
|
274
270
|
try {
|
|
275
|
-
|
|
271
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
276
272
|
} finally {
|
|
277
273
|
if (i) throw i.error;
|
|
278
274
|
}
|
|
279
275
|
}
|
|
280
|
-
return
|
|
281
|
-
},
|
|
276
|
+
return a;
|
|
277
|
+
}, H = function(r) {
|
|
282
278
|
var e = typeof Symbol == "function" && Symbol.iterator, t = e && r[e], n = 0;
|
|
283
279
|
if (t) return t.call(r);
|
|
284
280
|
if (r && typeof r.length == "number") return {
|
|
@@ -287,7 +283,7 @@ var Z = function(r, e) {
|
|
|
287
283
|
}
|
|
288
284
|
};
|
|
289
285
|
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
290
|
-
},
|
|
286
|
+
}, J = (
|
|
291
287
|
/** @class */
|
|
292
288
|
function() {
|
|
293
289
|
function r(e) {
|
|
@@ -299,8 +295,8 @@ var Z = function(r, e) {
|
|
|
299
295
|
return Object.assign({}, t);
|
|
300
296
|
}, r.prototype.getAllEntries = function() {
|
|
301
297
|
return Array.from(this._entries.entries()).map(function(e) {
|
|
302
|
-
var t =
|
|
303
|
-
return [n,
|
|
298
|
+
var t = z(e, 2), n = t[0], o = t[1];
|
|
299
|
+
return [n, o];
|
|
304
300
|
});
|
|
305
301
|
}, r.prototype.setEntry = function(e, t) {
|
|
306
302
|
var n = new r(this._entries);
|
|
@@ -309,16 +305,16 @@ var Z = function(r, e) {
|
|
|
309
305
|
var t = new r(this._entries);
|
|
310
306
|
return t._entries.delete(e), t;
|
|
311
307
|
}, r.prototype.removeEntries = function() {
|
|
312
|
-
for (var e, t, n = [],
|
|
313
|
-
n[
|
|
314
|
-
var
|
|
308
|
+
for (var e, t, n = [], o = 0; o < arguments.length; o++)
|
|
309
|
+
n[o] = arguments[o];
|
|
310
|
+
var a = new r(this._entries);
|
|
315
311
|
try {
|
|
316
|
-
for (var i =
|
|
317
|
-
var
|
|
318
|
-
|
|
312
|
+
for (var i = H(n), s = i.next(); !s.done; s = i.next()) {
|
|
313
|
+
var u = s.value;
|
|
314
|
+
a._entries.delete(u);
|
|
319
315
|
}
|
|
320
|
-
} catch (
|
|
321
|
-
e = { error:
|
|
316
|
+
} catch (l) {
|
|
317
|
+
e = { error: l };
|
|
322
318
|
} finally {
|
|
323
319
|
try {
|
|
324
320
|
s && !s.done && (t = i.return) && t.call(i);
|
|
@@ -326,37 +322,37 @@ var Z = function(r, e) {
|
|
|
326
322
|
if (e) throw e.error;
|
|
327
323
|
}
|
|
328
324
|
}
|
|
329
|
-
return
|
|
325
|
+
return a;
|
|
330
326
|
}, r.prototype.clear = function() {
|
|
331
327
|
return new r();
|
|
332
328
|
}, r;
|
|
333
329
|
}()
|
|
334
330
|
);
|
|
335
|
-
|
|
336
|
-
function
|
|
337
|
-
return r === void 0 && (r = {}), new
|
|
331
|
+
m.instance();
|
|
332
|
+
function Q(r) {
|
|
333
|
+
return r === void 0 && (r = {}), new J(new Map(Object.entries(r)));
|
|
338
334
|
}
|
|
339
|
-
function
|
|
335
|
+
function Z(r) {
|
|
340
336
|
return Symbol.for(r);
|
|
341
337
|
}
|
|
342
|
-
var
|
|
338
|
+
var L = (
|
|
343
339
|
/** @class */
|
|
344
340
|
/* @__PURE__ */ function() {
|
|
345
341
|
function r(e) {
|
|
346
342
|
var t = this;
|
|
347
343
|
t._currentContext = e ? new Map(e) : /* @__PURE__ */ new Map(), t.getValue = function(n) {
|
|
348
344
|
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) {
|
|
345
|
+
}, t.setValue = function(n, o) {
|
|
353
346
|
var a = new r(t._currentContext);
|
|
354
|
-
return a._currentContext.
|
|
347
|
+
return a._currentContext.set(n, o), a;
|
|
348
|
+
}, t.deleteValue = function(n) {
|
|
349
|
+
var o = new r(t._currentContext);
|
|
350
|
+
return o._currentContext.delete(n), o;
|
|
355
351
|
};
|
|
356
352
|
}
|
|
357
353
|
return r;
|
|
358
354
|
}()
|
|
359
|
-
),
|
|
355
|
+
), ee = new L(), te = {
|
|
360
356
|
get: function(r, e) {
|
|
361
357
|
if (r != null)
|
|
362
358
|
return r[e];
|
|
@@ -364,41 +360,41 @@ var ie = (
|
|
|
364
360
|
keys: function(r) {
|
|
365
361
|
return r == null ? [] : Object.keys(r);
|
|
366
362
|
}
|
|
367
|
-
},
|
|
363
|
+
}, re = {
|
|
368
364
|
set: function(r, e, t) {
|
|
369
365
|
r != null && (r[e] = t);
|
|
370
366
|
}
|
|
371
|
-
},
|
|
367
|
+
}, ne = function(r, e) {
|
|
372
368
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
373
369
|
if (!t) return r;
|
|
374
|
-
var n = t.call(r),
|
|
370
|
+
var n = t.call(r), o, a = [], i;
|
|
375
371
|
try {
|
|
376
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
372
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
377
373
|
} catch (s) {
|
|
378
374
|
i = { error: s };
|
|
379
375
|
} finally {
|
|
380
376
|
try {
|
|
381
|
-
|
|
377
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
382
378
|
} finally {
|
|
383
379
|
if (i) throw i.error;
|
|
384
380
|
}
|
|
385
381
|
}
|
|
386
|
-
return
|
|
387
|
-
},
|
|
388
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
389
|
-
(
|
|
390
|
-
return r.concat(
|
|
391
|
-
},
|
|
382
|
+
return a;
|
|
383
|
+
}, ae = function(r, e, t) {
|
|
384
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
385
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
386
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
387
|
+
}, oe = (
|
|
392
388
|
/** @class */
|
|
393
389
|
function() {
|
|
394
390
|
function r() {
|
|
395
391
|
}
|
|
396
392
|
return r.prototype.active = function() {
|
|
397
|
-
return
|
|
393
|
+
return ee;
|
|
398
394
|
}, r.prototype.with = function(e, t, n) {
|
|
399
|
-
for (var
|
|
400
|
-
a
|
|
401
|
-
return t.call.apply(t,
|
|
395
|
+
for (var o = [], a = 3; a < arguments.length; a++)
|
|
396
|
+
o[a - 3] = arguments[a];
|
|
397
|
+
return t.call.apply(t, ae([n], ne(o), !1));
|
|
402
398
|
}, r.prototype.bind = function(e, t) {
|
|
403
399
|
return t;
|
|
404
400
|
}, r.prototype.enable = function() {
|
|
@@ -407,27 +403,27 @@ var ie = (
|
|
|
407
403
|
return this;
|
|
408
404
|
}, r;
|
|
409
405
|
}()
|
|
410
|
-
),
|
|
406
|
+
), ie = function(r, e) {
|
|
411
407
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
412
408
|
if (!t) return r;
|
|
413
|
-
var n = t.call(r),
|
|
409
|
+
var n = t.call(r), o, a = [], i;
|
|
414
410
|
try {
|
|
415
|
-
for (; (e === void 0 || e-- > 0) && !(
|
|
411
|
+
for (; (e === void 0 || e-- > 0) && !(o = n.next()).done; ) a.push(o.value);
|
|
416
412
|
} catch (s) {
|
|
417
413
|
i = { error: s };
|
|
418
414
|
} finally {
|
|
419
415
|
try {
|
|
420
|
-
|
|
416
|
+
o && !o.done && (t = n.return) && t.call(n);
|
|
421
417
|
} finally {
|
|
422
418
|
if (i) throw i.error;
|
|
423
419
|
}
|
|
424
420
|
}
|
|
425
|
-
return
|
|
426
|
-
},
|
|
427
|
-
if (t || arguments.length === 2) for (var n = 0,
|
|
428
|
-
(
|
|
429
|
-
return r.concat(
|
|
430
|
-
},
|
|
421
|
+
return a;
|
|
422
|
+
}, se = function(r, e, t) {
|
|
423
|
+
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
424
|
+
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
425
|
+
return r.concat(a || Array.prototype.slice.call(e));
|
|
426
|
+
}, E = "context", ue = new oe(), G = (
|
|
431
427
|
/** @class */
|
|
432
428
|
function() {
|
|
433
429
|
function r() {
|
|
@@ -435,26 +431,26 @@ var ie = (
|
|
|
435
431
|
return r.getInstance = function() {
|
|
436
432
|
return this._instance || (this._instance = new r()), this._instance;
|
|
437
433
|
}, r.prototype.setGlobalContextManager = function(e) {
|
|
438
|
-
return
|
|
434
|
+
return x(E, e, m.instance());
|
|
439
435
|
}, r.prototype.active = function() {
|
|
440
436
|
return this._getContextManager().active();
|
|
441
437
|
}, r.prototype.with = function(e, t, n) {
|
|
442
|
-
for (var
|
|
443
|
-
|
|
444
|
-
return (
|
|
438
|
+
for (var o, a = [], i = 3; i < arguments.length; i++)
|
|
439
|
+
a[i - 3] = arguments[i];
|
|
440
|
+
return (o = this._getContextManager()).with.apply(o, se([e, t, n], ie(a), !1));
|
|
445
441
|
}, r.prototype.bind = function(e, t) {
|
|
446
442
|
return this._getContextManager().bind(e, t);
|
|
447
443
|
}, r.prototype._getContextManager = function() {
|
|
448
|
-
return
|
|
444
|
+
return y(E) || ue;
|
|
449
445
|
}, r.prototype.disable = function() {
|
|
450
|
-
this._getContextManager().disable(),
|
|
446
|
+
this._getContextManager().disable(), P(E, m.instance());
|
|
451
447
|
}, r;
|
|
452
448
|
}()
|
|
453
|
-
),
|
|
449
|
+
), N;
|
|
454
450
|
(function(r) {
|
|
455
451
|
r[r.UNSET = 0] = "UNSET", r[r.OK = 1] = "OK", r[r.ERROR = 2] = "ERROR";
|
|
456
|
-
})(
|
|
457
|
-
var
|
|
452
|
+
})(N || (N = {}));
|
|
453
|
+
var ce = G.getInstance(), le = (
|
|
458
454
|
/** @class */
|
|
459
455
|
function() {
|
|
460
456
|
function r() {
|
|
@@ -466,51 +462,52 @@ var ve = K.getInstance(), ye = (
|
|
|
466
462
|
return [];
|
|
467
463
|
}, r;
|
|
468
464
|
}()
|
|
469
|
-
),
|
|
470
|
-
function
|
|
471
|
-
return r.getValue(
|
|
465
|
+
), R = Z("OpenTelemetry Baggage Key");
|
|
466
|
+
function j(r) {
|
|
467
|
+
return r.getValue(R) || void 0;
|
|
472
468
|
}
|
|
473
|
-
function
|
|
474
|
-
return
|
|
469
|
+
function fe() {
|
|
470
|
+
return j(G.getInstance().active());
|
|
475
471
|
}
|
|
476
|
-
function
|
|
477
|
-
return r.setValue(
|
|
472
|
+
function pe(r, e) {
|
|
473
|
+
return r.setValue(R, e);
|
|
478
474
|
}
|
|
479
|
-
function
|
|
480
|
-
return r.deleteValue(
|
|
475
|
+
function he(r) {
|
|
476
|
+
return r.deleteValue(R);
|
|
481
477
|
}
|
|
482
|
-
var
|
|
478
|
+
var A = "propagation", de = new le(), ge = (
|
|
483
479
|
/** @class */
|
|
484
480
|
function() {
|
|
485
481
|
function r() {
|
|
486
|
-
this.createBaggage =
|
|
482
|
+
this.createBaggage = Q, this.getBaggage = j, this.getActiveBaggage = fe, this.setBaggage = pe, this.deleteBaggage = he;
|
|
487
483
|
}
|
|
488
484
|
return r.getInstance = function() {
|
|
489
485
|
return this._instance || (this._instance = new r()), this._instance;
|
|
490
486
|
}, r.prototype.setGlobalPropagator = function(e) {
|
|
491
|
-
return
|
|
487
|
+
return x(A, e, m.instance());
|
|
492
488
|
}, r.prototype.inject = function(e, t, n) {
|
|
493
|
-
return n === void 0 && (n =
|
|
489
|
+
return n === void 0 && (n = re), this._getGlobalPropagator().inject(e, t, n);
|
|
494
490
|
}, r.prototype.extract = function(e, t, n) {
|
|
495
|
-
return n === void 0 && (n =
|
|
491
|
+
return n === void 0 && (n = te), this._getGlobalPropagator().extract(e, t, n);
|
|
496
492
|
}, r.prototype.fields = function() {
|
|
497
493
|
return this._getGlobalPropagator().fields();
|
|
498
494
|
}, r.prototype.disable = function() {
|
|
499
|
-
|
|
495
|
+
P(A, m.instance());
|
|
500
496
|
}, r.prototype._getGlobalPropagator = function() {
|
|
501
|
-
return
|
|
497
|
+
return y(A) || de;
|
|
502
498
|
}, r;
|
|
503
499
|
}()
|
|
504
|
-
),
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
500
|
+
), ve = ge.getInstance();
|
|
501
|
+
const M = ["bench", "debug", "prod"], ye = (r) => (e) => M.indexOf(e) >= M.indexOf(r);
|
|
502
|
+
class w {
|
|
503
|
+
meta = h.NOOP;
|
|
504
|
+
otelTracer;
|
|
505
|
+
filter;
|
|
506
|
+
constructor(e, t = ye("debug")) {
|
|
510
507
|
this.otelTracer = e, this.filter = t;
|
|
511
508
|
}
|
|
512
509
|
child(e) {
|
|
513
|
-
const t = new
|
|
510
|
+
const t = new w(this.otelTracer, this.filter);
|
|
514
511
|
return t.meta = e, t;
|
|
515
512
|
}
|
|
516
513
|
/**
|
|
@@ -560,49 +557,48 @@ const F = ["bench", "debug", "prod"], Ae = (r) => (e) => F.indexOf(e) >= F.index
|
|
|
560
557
|
* rejects the provided span or the Tracer is noop, a NoopSpan is returned.
|
|
561
558
|
*/
|
|
562
559
|
trace(e, t, n) {
|
|
560
|
+
const o = this.meta.noop || !this.filter(t) || this.otelTracer == null;
|
|
563
561
|
if (n == null) {
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
const a = new V(e, this.otelTracer.startSpan(e));
|
|
562
|
+
if (o) return () => {
|
|
563
|
+
};
|
|
564
|
+
const a = new S(e, this.otelTracer.startSpan(e));
|
|
568
565
|
return a.start(), () => a.end();
|
|
569
566
|
}
|
|
570
|
-
return
|
|
571
|
-
const
|
|
572
|
-
return n(
|
|
567
|
+
return o ? n(new me(e)) : this.otelTracer.startActiveSpan(e, (a) => {
|
|
568
|
+
const i = new S(e, a);
|
|
569
|
+
return n(i);
|
|
573
570
|
});
|
|
574
571
|
}
|
|
575
572
|
/**
|
|
576
|
-
* Injects metadata about the current trace into the provided carrier. This
|
|
577
|
-
*
|
|
578
|
-
*
|
|
573
|
+
* Injects metadata about the current trace into the provided carrier. This metadata
|
|
574
|
+
* can be parsed on the other side of a network or IPC request to allow the trace to
|
|
575
|
+
* propagate across services.
|
|
579
576
|
*
|
|
580
577
|
* @param carrier - The carrier to inject the metadata into.
|
|
581
578
|
*/
|
|
582
579
|
propagate(e) {
|
|
583
580
|
if (this.meta.noop) return;
|
|
584
|
-
const t =
|
|
585
|
-
|
|
586
|
-
set: (n,
|
|
587
|
-
n[
|
|
581
|
+
const t = ce.active();
|
|
582
|
+
ve.inject(t, e, {
|
|
583
|
+
set: (n, o, a) => {
|
|
584
|
+
n[o] = a;
|
|
588
585
|
}
|
|
589
586
|
});
|
|
590
587
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
588
|
+
/** Tracer implementation that does nothing */
|
|
589
|
+
static NOOP = new w();
|
|
590
|
+
}
|
|
591
|
+
class S {
|
|
592
|
+
key;
|
|
593
|
+
otel;
|
|
596
594
|
constructor(e, t) {
|
|
597
|
-
u(this, "key");
|
|
598
|
-
u(this, "otel");
|
|
599
595
|
this.key = e, this.otel = t;
|
|
600
596
|
}
|
|
601
597
|
set(e, t) {
|
|
602
598
|
this.otel.setAttribute(e, t);
|
|
603
599
|
}
|
|
604
600
|
recordError(e) {
|
|
605
|
-
e != null && (this.otel.recordException(e), this.otel.setStatus({ code:
|
|
601
|
+
e != null && (this.otel.recordException(e), this.otel.setStatus({ code: N.ERROR }));
|
|
606
602
|
}
|
|
607
603
|
start() {
|
|
608
604
|
performance.mark(`alamos.trace.start.${this.key}`);
|
|
@@ -615,15 +611,15 @@ class V {
|
|
|
615
611
|
`alamos.trace.start.${this.key}`,
|
|
616
612
|
`alamos.trace.end.${this.key}`
|
|
617
613
|
);
|
|
618
|
-
this.set("duration", e.duration), this.
|
|
614
|
+
this.set("duration", e.duration), this.otel.end();
|
|
619
615
|
} catch (e) {
|
|
620
616
|
console.error(e);
|
|
621
617
|
}
|
|
622
618
|
}
|
|
623
619
|
}
|
|
624
|
-
class
|
|
620
|
+
class me {
|
|
621
|
+
key;
|
|
625
622
|
constructor(e) {
|
|
626
|
-
u(this, "key");
|
|
627
623
|
this.key = e;
|
|
628
624
|
}
|
|
629
625
|
set() {
|
|
@@ -631,42 +627,41 @@ class Ne {
|
|
|
631
627
|
recordError(e) {
|
|
632
628
|
}
|
|
633
629
|
}
|
|
634
|
-
|
|
630
|
+
class O {
|
|
631
|
+
meta;
|
|
632
|
+
T;
|
|
633
|
+
L;
|
|
635
634
|
constructor({
|
|
636
635
|
key: e = "",
|
|
637
636
|
serviceName: t = "",
|
|
638
|
-
logger: n =
|
|
639
|
-
tracer:
|
|
640
|
-
noop:
|
|
637
|
+
logger: n = _.NOOP,
|
|
638
|
+
tracer: o = w.NOOP,
|
|
639
|
+
noop: a = !1,
|
|
641
640
|
__meta: i
|
|
642
641
|
}) {
|
|
643
|
-
|
|
644
|
-
u(this, "T");
|
|
645
|
-
u(this, "L");
|
|
646
|
-
this.meta = i ?? new b(e, e, t, o), this.T = a.child(this.meta), this.L = n.child(this.meta);
|
|
642
|
+
this.meta = i ?? new h(e, e, t, a), this.T = o.child(this.meta), this.L = n.child(this.meta);
|
|
647
643
|
}
|
|
648
644
|
child(e) {
|
|
649
645
|
const t = this.meta.child(e);
|
|
650
|
-
return new
|
|
646
|
+
return new O({ __meta: t, tracer: this.T, logger: this.L });
|
|
651
647
|
}
|
|
652
|
-
};
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
const Te = C.NOOP;
|
|
648
|
+
static NOOP = new O({ noop: !0 });
|
|
649
|
+
}
|
|
650
|
+
const we = O.NOOP;
|
|
656
651
|
export {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
T,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
652
|
+
G as C,
|
|
653
|
+
m as D,
|
|
654
|
+
O as I,
|
|
655
|
+
I as L,
|
|
656
|
+
we as N,
|
|
657
|
+
w as T,
|
|
658
|
+
S as _,
|
|
659
|
+
_ as a,
|
|
660
|
+
me as b,
|
|
661
|
+
be as c,
|
|
662
|
+
Z as d,
|
|
663
|
+
y as g,
|
|
664
|
+
_e as l,
|
|
665
|
+
x as r,
|
|
666
|
+
P as u
|
|
672
667
|
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
package/dist/log.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { record } from '@synnaxlabs/x';
|
|
2
2
|
import { Meta } from './meta';
|
|
3
3
|
export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
4
4
|
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
@@ -7,7 +7,7 @@ export interface LogLevelFilterProps {
|
|
|
7
7
|
path: string;
|
|
8
8
|
level: LogLevel;
|
|
9
9
|
}
|
|
10
|
-
type KV =
|
|
10
|
+
type KV = record.Unknown | (() => record.Unknown);
|
|
11
11
|
/**
|
|
12
12
|
* LogLevelFilter is a function that returns true if the log at the given
|
|
13
13
|
* level should be emitted.
|
package/dist/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,eAAO,MAAM,UAAU,6CAA8C,CAAC;AACtE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED,KAAK,EAAE,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AAElD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC;AAErE,eAAO,MAAM,kBAAkB,GAAI,QAAQ,QAAQ,KAAG,cAGrD,CAAC;AAEF,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,KAAG,cAOhE,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,IAAI,CAAa;IACvB,OAAO,EAAE,cAAc,EAAE,CAAC;gBAEd,CAAC,GAAE,WAAgB;IAK/B,OAAO,CAAC,MAAM;IAad,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAMzB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IAMzD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IAMxD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IAMxD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,GAAE,OAAe,GAAG,IAAI;IAMzD,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAgB;CACrC"}
|
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.44.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.44.0"
|
|
23
20
|
},
|
|
24
21
|
"devDependencies": {
|
|
25
|
-
"eslint": "^9.
|
|
22
|
+
"eslint": "^9.30.1",
|
|
26
23
|
"madge": "^8.0.0",
|
|
27
24
|
"typescript": "^5.8.3",
|
|
28
|
-
"vite": "^
|
|
29
|
-
"vitest": "^3.
|
|
30
|
-
"@synnaxlabs/tsconfig": "0.0
|
|
31
|
-
"@synnaxlabs/vite-plugin": "0.0
|
|
32
|
-
"eslint-config-synnaxlabs": "0.0
|
|
25
|
+
"vite": "^7.0.4",
|
|
26
|
+
"vitest": "^3.2.4",
|
|
27
|
+
"@synnaxlabs/tsconfig": "^0.43.0",
|
|
28
|
+
"@synnaxlabs/vite-plugin": "^0.43.0",
|
|
29
|
+
"eslint-config-synnaxlabs": "^0.43.0"
|
|
33
30
|
},
|
|
34
31
|
"main": "dist/index.js",
|
|
35
32
|
"module": "dist/index.js",
|
|
@@ -46,11 +43,12 @@
|
|
|
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",
|
|
52
|
-
"lint": "eslint
|
|
53
|
-
"fix": "eslint --
|
|
50
|
+
"lint": "eslint",
|
|
51
|
+
"fix": "eslint --fix",
|
|
54
52
|
"madge": "madge --circular src"
|
|
55
53
|
}
|
|
56
54
|
}
|
package/src/log.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
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
|
-
import { type
|
|
10
|
+
import { type record } from "@synnaxlabs/x";
|
|
11
11
|
|
|
12
12
|
import { Meta } from "@/meta";
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ export interface LogLevelFilterProps {
|
|
|
20
20
|
level: LogLevel;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
type KV =
|
|
23
|
+
type KV = record.Unknown | (() => record.Unknown);
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* LogLevelFilter is a function that returns true if the log at the given
|
|
@@ -105,4 +105,4 @@ export class Logger {
|
|
|
105
105
|
static readonly NOOP = new Logger();
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const parseKV = (kv: KV):
|
|
108
|
+
const parseKV = (kv: KV): record.Unknown => (typeof kv === "function" ? kv() : kv);
|
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;
|