@synnaxlabs/alamos 0.40.0 → 0.42.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/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-CBvwb_K0.js → instrumentation-1jARg32o.js} +168 -145
- package/dist/{instrumentation-CoYi8Yfu.cjs → instrumentation-DeyQj3IK.cjs} +1 -1
- package/dist/instrumentation.d.ts.map +1 -1
- package/dist/trace.d.ts +15 -44
- package/dist/trace.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/instrumentation.ts +0 -1
- package/src/trace.ts +64 -12
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-DeyQj3IK.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-1jARg32o.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-DeyQj3IK.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-1jARg32o.js";
|
|
2
2
|
const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
Instrumentation: e,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var W = (r, e, t) => e in r ?
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var W = (r, e, t) => e in r ? k(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var u = (r, e, t) => W(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const g = class g {
|
|
5
5
|
constructor(e, t, n = "", a = !1) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
u(this, "_noop", !1);
|
|
7
|
+
u(this, "key");
|
|
8
|
+
u(this, "path");
|
|
9
|
+
u(this, "serviceName");
|
|
10
10
|
this.key = e, this.path = t, this.serviceName = n, this._noop = a;
|
|
11
11
|
}
|
|
12
12
|
child(e) {
|
|
13
|
-
return new
|
|
13
|
+
return new g(e, this.extendPath(e), this.serviceName, this.noop);
|
|
14
14
|
}
|
|
15
15
|
extendPath(e) {
|
|
16
16
|
return `${this.path}.${e}`;
|
|
@@ -19,18 +19,18 @@ const d = class d {
|
|
|
19
19
|
return this._noop;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
let b =
|
|
24
|
-
const
|
|
25
|
-
const e =
|
|
26
|
-
return ({ level: t }) =>
|
|
22
|
+
u(g, "NOOP", new g("", "", ""));
|
|
23
|
+
let b = g;
|
|
24
|
+
const j = ["debug", "info", "warn", "error"], Pe = (r) => {
|
|
25
|
+
const e = j.indexOf(r);
|
|
26
|
+
return ({ level: t }) => j.indexOf(t) >= e;
|
|
27
27
|
}, Re = (r) => {
|
|
28
28
|
const { include: e, exclude: t } = r;
|
|
29
29
|
return ({ path: n }) => !(e != null && !e.some((a) => n.startsWith(a)) || t != null && t.some((a) => n.startsWith(a)));
|
|
30
30
|
}, v = class v {
|
|
31
31
|
constructor(e = {}) {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
u(this, "meta", b.NOOP);
|
|
33
|
+
u(this, "filters");
|
|
34
34
|
const { filters: t = [] } = e;
|
|
35
35
|
this.filters = t;
|
|
36
36
|
}
|
|
@@ -60,12 +60,12 @@ const S = ["debug", "info", "warn", "error"], Pe = (r) => {
|
|
|
60
60
|
!this.filter("error") && !n || (t == null ? console.error("ERROR", this.meta.path, e) : console.error("ERROR", this.meta.path, e, A(t)));
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
u(v, "NOOP", new v());
|
|
64
64
|
let P = v;
|
|
65
65
|
const A = (r) => typeof r == "function" ? r() : r;
|
|
66
|
-
var X = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {},
|
|
66
|
+
var X = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {}, h = "1.9.0", $ = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
67
67
|
function Y(r) {
|
|
68
|
-
var e = /* @__PURE__ */ new Set([r]), t = /* @__PURE__ */ new Set(), n = r.match(
|
|
68
|
+
var e = /* @__PURE__ */ new Set([r]), t = /* @__PURE__ */ new Set(), n = r.match($);
|
|
69
69
|
if (!n)
|
|
70
70
|
return function() {
|
|
71
71
|
return !1;
|
|
@@ -80,18 +80,18 @@ function Y(r) {
|
|
|
80
80
|
return function(c) {
|
|
81
81
|
return c === r;
|
|
82
82
|
};
|
|
83
|
-
function o(
|
|
84
|
-
return t.add(
|
|
83
|
+
function o(s) {
|
|
84
|
+
return t.add(s), !1;
|
|
85
85
|
}
|
|
86
|
-
function i(
|
|
87
|
-
return e.add(
|
|
86
|
+
function i(s) {
|
|
87
|
+
return e.add(s), !0;
|
|
88
88
|
}
|
|
89
89
|
return function(c) {
|
|
90
90
|
if (e.has(c))
|
|
91
91
|
return !0;
|
|
92
92
|
if (t.has(c))
|
|
93
93
|
return !1;
|
|
94
|
-
var f = c.match(
|
|
94
|
+
var f = c.match($);
|
|
95
95
|
if (!f)
|
|
96
96
|
return o(c);
|
|
97
97
|
var p = {
|
|
@@ -103,41 +103,41 @@ function Y(r) {
|
|
|
103
103
|
return p.prerelease != null || a.major !== p.major ? o(c) : a.major === 0 ? a.minor === p.minor && a.patch <= p.patch ? i(c) : o(c) : a.minor <= p.minor ? i(c) : o(c);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
var
|
|
107
|
-
function
|
|
106
|
+
var D = Y(h), q = h.split(".")[0], w = Symbol.for("opentelemetry.js.api." + q), _ = X;
|
|
107
|
+
function B(r, e, t, n) {
|
|
108
108
|
var a;
|
|
109
109
|
n === void 0 && (n = !1);
|
|
110
|
-
var o = w
|
|
111
|
-
version:
|
|
110
|
+
var o = _[w] = (a = _[w]) !== null && a !== void 0 ? a : {
|
|
111
|
+
version: h
|
|
112
112
|
};
|
|
113
113
|
if (!n && o[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 (o.version !==
|
|
118
|
-
var i = new Error("@opentelemetry/api: Registration of version v" + o.version + " for " + r + " does not match previously registered API v" +
|
|
117
|
+
if (o.version !== h) {
|
|
118
|
+
var i = new Error("@opentelemetry/api: Registration of version v" + o.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 o[r] = e, t.debug("@opentelemetry/api: Registered a global for " + r + " v" +
|
|
121
|
+
return o[r] = e, t.debug("@opentelemetry/api: Registered a global for " + r + " v" + h + "."), !0;
|
|
122
122
|
}
|
|
123
123
|
function O(r) {
|
|
124
|
-
var e, t, n = (e = w
|
|
125
|
-
if (!(!n || !
|
|
126
|
-
return (t = w
|
|
124
|
+
var e, t, n = (e = _[w]) === null || e === void 0 ? void 0 : e.version;
|
|
125
|
+
if (!(!n || !D(n)))
|
|
126
|
+
return (t = _[w]) === null || t === void 0 ? void 0 : t[r];
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
e.debug("@opentelemetry/api: Unregistering a global for " + r + " v" +
|
|
130
|
-
var t = w
|
|
128
|
+
function I(r, e) {
|
|
129
|
+
e.debug("@opentelemetry/api: Unregistering a global for " + r + " v" + h + ".");
|
|
130
|
+
var t = _[w];
|
|
131
131
|
t && delete t[r];
|
|
132
132
|
}
|
|
133
|
-
var
|
|
133
|
+
var z = function(r, e) {
|
|
134
134
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
135
135
|
if (!t) return r;
|
|
136
136
|
var n = t.call(r), a, o = [], i;
|
|
137
137
|
try {
|
|
138
138
|
for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) o.push(a.value);
|
|
139
|
-
} catch (
|
|
140
|
-
i = { error:
|
|
139
|
+
} catch (s) {
|
|
140
|
+
i = { error: s };
|
|
141
141
|
} finally {
|
|
142
142
|
try {
|
|
143
143
|
a && !a.done && (t = n.return) && t.call(n);
|
|
@@ -146,11 +146,11 @@ var q = function(r, e) {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
return o;
|
|
149
|
-
},
|
|
149
|
+
}, H = function(r, e, t) {
|
|
150
150
|
if (t || arguments.length === 2) for (var n = 0, a = e.length, o; n < a; n++)
|
|
151
151
|
(o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
|
|
152
152
|
return r.concat(o || Array.prototype.slice.call(e));
|
|
153
|
-
},
|
|
153
|
+
}, J = (
|
|
154
154
|
/** @class */
|
|
155
155
|
function() {
|
|
156
156
|
function r(e) {
|
|
@@ -159,36 +159,36 @@ var q = function(r, e) {
|
|
|
159
159
|
return r.prototype.debug = function() {
|
|
160
160
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
161
161
|
e[t] = arguments[t];
|
|
162
|
-
return
|
|
162
|
+
return d("debug", this._namespace, e);
|
|
163
163
|
}, r.prototype.error = function() {
|
|
164
164
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
165
165
|
e[t] = arguments[t];
|
|
166
|
-
return
|
|
166
|
+
return d("error", this._namespace, e);
|
|
167
167
|
}, r.prototype.info = function() {
|
|
168
168
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
169
169
|
e[t] = arguments[t];
|
|
170
|
-
return
|
|
170
|
+
return d("info", this._namespace, e);
|
|
171
171
|
}, r.prototype.warn = function() {
|
|
172
172
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
173
173
|
e[t] = arguments[t];
|
|
174
|
-
return
|
|
174
|
+
return d("warn", this._namespace, e);
|
|
175
175
|
}, r.prototype.verbose = function() {
|
|
176
176
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
177
177
|
e[t] = arguments[t];
|
|
178
|
-
return
|
|
178
|
+
return d("verbose", this._namespace, e);
|
|
179
179
|
}, r;
|
|
180
180
|
}()
|
|
181
181
|
);
|
|
182
|
-
function
|
|
182
|
+
function d(r, e, t) {
|
|
183
183
|
var n = O("diag");
|
|
184
184
|
if (n)
|
|
185
|
-
return t.unshift(e), n[r].apply(n,
|
|
185
|
+
return t.unshift(e), n[r].apply(n, H([], z(t), !1));
|
|
186
186
|
}
|
|
187
187
|
var l;
|
|
188
188
|
(function(r) {
|
|
189
189
|
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
190
|
})(l || (l = {}));
|
|
191
|
-
function
|
|
191
|
+
function Q(r, e) {
|
|
192
192
|
r < l.NONE ? r = l.NONE : r > l.ALL && (r = l.ALL), e = e || {};
|
|
193
193
|
function t(n, a) {
|
|
194
194
|
var o = e[n];
|
|
@@ -203,14 +203,14 @@ function J(r, e) {
|
|
|
203
203
|
verbose: t("verbose", l.VERBOSE)
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
var
|
|
206
|
+
var Z = function(r, e) {
|
|
207
207
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
208
208
|
if (!t) return r;
|
|
209
209
|
var n = t.call(r), a, o = [], i;
|
|
210
210
|
try {
|
|
211
211
|
for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) o.push(a.value);
|
|
212
|
-
} catch (
|
|
213
|
-
i = { error:
|
|
212
|
+
} catch (s) {
|
|
213
|
+
i = { error: s };
|
|
214
214
|
} finally {
|
|
215
215
|
try {
|
|
216
216
|
a && !a.done && (t = n.return) && t.call(n);
|
|
@@ -219,11 +219,11 @@ var Q = function(r, e) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
return o;
|
|
222
|
-
},
|
|
222
|
+
}, L = function(r, e, t) {
|
|
223
223
|
if (t || arguments.length === 2) for (var n = 0, a = e.length, o; n < a; n++)
|
|
224
224
|
(o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
|
|
225
225
|
return r.concat(o || Array.prototype.slice.call(e));
|
|
226
|
-
},
|
|
226
|
+
}, ee = "diag", E = (
|
|
227
227
|
/** @class */
|
|
228
228
|
function() {
|
|
229
229
|
function r() {
|
|
@@ -231,13 +231,13 @@ var Q = function(r, e) {
|
|
|
231
231
|
return function() {
|
|
232
232
|
for (var o = [], i = 0; i < arguments.length; i++)
|
|
233
233
|
o[i] = arguments[i];
|
|
234
|
-
var
|
|
235
|
-
if (
|
|
236
|
-
return
|
|
234
|
+
var s = O("diag");
|
|
235
|
+
if (s)
|
|
236
|
+
return s[a].apply(s, L([], Z(o), !1));
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
var t = this, n = function(a, o) {
|
|
240
|
-
var i,
|
|
240
|
+
var i, s, c;
|
|
241
241
|
if (o === void 0 && (o = { logLevel: l.INFO }), a === 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;
|
|
@@ -245,31 +245,31 @@ var Q = function(r, e) {
|
|
|
245
245
|
typeof o == "number" && (o = {
|
|
246
246
|
logLevel: o
|
|
247
247
|
});
|
|
248
|
-
var p = O("diag"),
|
|
248
|
+
var p = O("diag"), S = Q((s = o.logLevel) !== null && s !== void 0 ? s : l.INFO, a);
|
|
249
249
|
if (p && !o.suppressOverrideMessage) {
|
|
250
|
-
var
|
|
251
|
-
p.warn("Current logger will be overwritten from " +
|
|
250
|
+
var G = (c = new Error().stack) !== null && c !== void 0 ? c : "<failed to generate stacktrace>";
|
|
251
|
+
p.warn("Current logger will be overwritten from " + G), S.warn("Current logger will overwrite one already registered from " + G);
|
|
252
252
|
}
|
|
253
|
-
return
|
|
253
|
+
return B("diag", S, t, !0);
|
|
254
254
|
};
|
|
255
255
|
t.setLogger = n, t.disable = function() {
|
|
256
|
-
|
|
256
|
+
I(ee, t);
|
|
257
257
|
}, t.createComponentLogger = function(a) {
|
|
258
|
-
return new
|
|
258
|
+
return new J(a);
|
|
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() {
|
|
262
262
|
return this._instance || (this._instance = new r()), this._instance;
|
|
263
263
|
}, r;
|
|
264
264
|
}()
|
|
265
|
-
),
|
|
265
|
+
), te = function(r, e) {
|
|
266
266
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
267
267
|
if (!t) return r;
|
|
268
268
|
var n = t.call(r), a, o = [], i;
|
|
269
269
|
try {
|
|
270
270
|
for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) o.push(a.value);
|
|
271
|
-
} catch (
|
|
272
|
-
i = { error:
|
|
271
|
+
} catch (s) {
|
|
272
|
+
i = { error: s };
|
|
273
273
|
} finally {
|
|
274
274
|
try {
|
|
275
275
|
a && !a.done && (t = n.return) && t.call(n);
|
|
@@ -278,7 +278,7 @@ var Q = function(r, e) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
return o;
|
|
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);
|
|
284
284
|
if (r && typeof r.length == "number") return {
|
|
@@ -287,7 +287,7 @@ var Q = function(r, e) {
|
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
289
|
throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
290
|
-
},
|
|
290
|
+
}, ne = (
|
|
291
291
|
/** @class */
|
|
292
292
|
function() {
|
|
293
293
|
function r(e) {
|
|
@@ -299,7 +299,7 @@ var Q = 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 =
|
|
302
|
+
var t = te(e, 2), n = t[0], a = t[1];
|
|
303
303
|
return [n, a];
|
|
304
304
|
});
|
|
305
305
|
}, r.prototype.setEntry = function(e, t) {
|
|
@@ -313,15 +313,15 @@ var Q = function(r, e) {
|
|
|
313
313
|
n[a] = arguments[a];
|
|
314
314
|
var o = new r(this._entries);
|
|
315
315
|
try {
|
|
316
|
-
for (var i =
|
|
317
|
-
var c =
|
|
316
|
+
for (var i = re(n), s = i.next(); !s.done; s = i.next()) {
|
|
317
|
+
var c = s.value;
|
|
318
318
|
o._entries.delete(c);
|
|
319
319
|
}
|
|
320
320
|
} catch (f) {
|
|
321
321
|
e = { error: f };
|
|
322
322
|
} finally {
|
|
323
323
|
try {
|
|
324
|
-
|
|
324
|
+
s && !s.done && (t = i.return) && t.call(i);
|
|
325
325
|
} finally {
|
|
326
326
|
if (e) throw e.error;
|
|
327
327
|
}
|
|
@@ -333,13 +333,13 @@ var Q = function(r, e) {
|
|
|
333
333
|
}()
|
|
334
334
|
);
|
|
335
335
|
E.instance();
|
|
336
|
-
function ne(r) {
|
|
337
|
-
return r === void 0 && (r = {}), new re(new Map(Object.entries(r)));
|
|
338
|
-
}
|
|
339
336
|
function ae(r) {
|
|
337
|
+
return r === void 0 && (r = {}), new ne(new Map(Object.entries(r)));
|
|
338
|
+
}
|
|
339
|
+
function oe(r) {
|
|
340
340
|
return Symbol.for(r);
|
|
341
341
|
}
|
|
342
|
-
var
|
|
342
|
+
var ie = (
|
|
343
343
|
/** @class */
|
|
344
344
|
/* @__PURE__ */ function() {
|
|
345
345
|
function r(e) {
|
|
@@ -356,7 +356,7 @@ var oe = (
|
|
|
356
356
|
}
|
|
357
357
|
return r;
|
|
358
358
|
}()
|
|
359
|
-
),
|
|
359
|
+
), se = new ie(), ue = {
|
|
360
360
|
get: function(r, e) {
|
|
361
361
|
if (r != null)
|
|
362
362
|
return r[e];
|
|
@@ -364,18 +364,18 @@ var oe = (
|
|
|
364
364
|
keys: function(r) {
|
|
365
365
|
return r == null ? [] : Object.keys(r);
|
|
366
366
|
}
|
|
367
|
-
},
|
|
367
|
+
}, ce = {
|
|
368
368
|
set: function(r, e, t) {
|
|
369
369
|
r != null && (r[e] = t);
|
|
370
370
|
}
|
|
371
|
-
},
|
|
371
|
+
}, le = function(r, e) {
|
|
372
372
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
373
373
|
if (!t) return r;
|
|
374
374
|
var n = t.call(r), a, o = [], i;
|
|
375
375
|
try {
|
|
376
376
|
for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) o.push(a.value);
|
|
377
|
-
} catch (
|
|
378
|
-
i = { error:
|
|
377
|
+
} catch (s) {
|
|
378
|
+
i = { error: s };
|
|
379
379
|
} finally {
|
|
380
380
|
try {
|
|
381
381
|
a && !a.done && (t = n.return) && t.call(n);
|
|
@@ -384,21 +384,21 @@ var oe = (
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
return o;
|
|
387
|
-
},
|
|
387
|
+
}, fe = function(r, e, t) {
|
|
388
388
|
if (t || arguments.length === 2) for (var n = 0, a = e.length, o; n < a; n++)
|
|
389
389
|
(o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
|
|
390
390
|
return r.concat(o || Array.prototype.slice.call(e));
|
|
391
|
-
},
|
|
391
|
+
}, pe = (
|
|
392
392
|
/** @class */
|
|
393
393
|
function() {
|
|
394
394
|
function r() {
|
|
395
395
|
}
|
|
396
396
|
return r.prototype.active = function() {
|
|
397
|
-
return
|
|
397
|
+
return se;
|
|
398
398
|
}, r.prototype.with = function(e, t, n) {
|
|
399
399
|
for (var a = [], o = 3; o < arguments.length; o++)
|
|
400
400
|
a[o - 3] = arguments[o];
|
|
401
|
-
return t.call.apply(t,
|
|
401
|
+
return t.call.apply(t, fe([n], le(a), !1));
|
|
402
402
|
}, r.prototype.bind = function(e, t) {
|
|
403
403
|
return t;
|
|
404
404
|
}, r.prototype.enable = function() {
|
|
@@ -407,14 +407,14 @@ var oe = (
|
|
|
407
407
|
return this;
|
|
408
408
|
}, r;
|
|
409
409
|
}()
|
|
410
|
-
),
|
|
410
|
+
), he = function(r, e) {
|
|
411
411
|
var t = typeof Symbol == "function" && r[Symbol.iterator];
|
|
412
412
|
if (!t) return r;
|
|
413
413
|
var n = t.call(r), a, o = [], i;
|
|
414
414
|
try {
|
|
415
415
|
for (; (e === void 0 || e-- > 0) && !(a = n.next()).done; ) o.push(a.value);
|
|
416
|
-
} catch (
|
|
417
|
-
i = { error:
|
|
416
|
+
} catch (s) {
|
|
417
|
+
i = { error: s };
|
|
418
418
|
} finally {
|
|
419
419
|
try {
|
|
420
420
|
a && !a.done && (t = n.return) && t.call(n);
|
|
@@ -423,11 +423,11 @@ var oe = (
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
return o;
|
|
426
|
-
},
|
|
426
|
+
}, de = function(r, e, t) {
|
|
427
427
|
if (t || arguments.length === 2) for (var n = 0, a = e.length, o; n < a; n++)
|
|
428
428
|
(o || !(n in e)) && (o || (o = Array.prototype.slice.call(e, 0, n)), o[n] = e[n]);
|
|
429
429
|
return r.concat(o || Array.prototype.slice.call(e));
|
|
430
|
-
}, N = "context",
|
|
430
|
+
}, N = "context", ge = new pe(), K = (
|
|
431
431
|
/** @class */
|
|
432
432
|
function() {
|
|
433
433
|
function r() {
|
|
@@ -435,26 +435,26 @@ var oe = (
|
|
|
435
435
|
return r.getInstance = function() {
|
|
436
436
|
return this._instance || (this._instance = new r()), this._instance;
|
|
437
437
|
}, r.prototype.setGlobalContextManager = function(e) {
|
|
438
|
-
return
|
|
438
|
+
return B(N, e, E.instance());
|
|
439
439
|
}, r.prototype.active = function() {
|
|
440
440
|
return this._getContextManager().active();
|
|
441
441
|
}, r.prototype.with = function(e, t, n) {
|
|
442
442
|
for (var a, o = [], i = 3; i < arguments.length; i++)
|
|
443
443
|
o[i - 3] = arguments[i];
|
|
444
|
-
return (a = this._getContextManager()).with.apply(a,
|
|
444
|
+
return (a = this._getContextManager()).with.apply(a, de([e, t, n], he(o), !1));
|
|
445
445
|
}, r.prototype.bind = function(e, t) {
|
|
446
446
|
return this._getContextManager().bind(e, t);
|
|
447
447
|
}, r.prototype._getContextManager = function() {
|
|
448
|
-
return O(N) ||
|
|
448
|
+
return O(N) || ge;
|
|
449
449
|
}, r.prototype.disable = function() {
|
|
450
|
-
this._getContextManager().disable(),
|
|
450
|
+
this._getContextManager().disable(), I(N, E.instance());
|
|
451
451
|
}, r;
|
|
452
452
|
}()
|
|
453
453
|
), R;
|
|
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
|
|
457
|
+
var ve = K.getInstance(), ye = (
|
|
458
458
|
/** @class */
|
|
459
459
|
function() {
|
|
460
460
|
function r() {
|
|
@@ -466,51 +466,51 @@ var de = V.getInstance(), ve = (
|
|
|
466
466
|
return [];
|
|
467
467
|
}, r;
|
|
468
468
|
}()
|
|
469
|
-
), M =
|
|
470
|
-
function
|
|
469
|
+
), M = oe("OpenTelemetry Baggage Key");
|
|
470
|
+
function U(r) {
|
|
471
471
|
return r.getValue(M) || void 0;
|
|
472
472
|
}
|
|
473
|
-
function
|
|
474
|
-
return K
|
|
473
|
+
function me() {
|
|
474
|
+
return U(K.getInstance().active());
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function be(r, e) {
|
|
477
477
|
return r.setValue(M, e);
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function we(r) {
|
|
480
480
|
return r.deleteValue(M);
|
|
481
481
|
}
|
|
482
|
-
var x = "propagation", _e = new
|
|
482
|
+
var x = "propagation", _e = new ye(), Oe = (
|
|
483
483
|
/** @class */
|
|
484
484
|
function() {
|
|
485
485
|
function r() {
|
|
486
|
-
this.createBaggage =
|
|
486
|
+
this.createBaggage = ae, this.getBaggage = U, 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;
|
|
490
490
|
}, r.prototype.setGlobalPropagator = function(e) {
|
|
491
|
-
return
|
|
491
|
+
return B(x, e, E.instance());
|
|
492
492
|
}, r.prototype.inject = function(e, t, n) {
|
|
493
|
-
return n === void 0 && (n =
|
|
493
|
+
return n === void 0 && (n = ce), this._getGlobalPropagator().inject(e, t, n);
|
|
494
494
|
}, r.prototype.extract = function(e, t, n) {
|
|
495
495
|
return n === void 0 && (n = ue), this._getGlobalPropagator().extract(e, t, n);
|
|
496
496
|
}, r.prototype.fields = function() {
|
|
497
497
|
return this._getGlobalPropagator().fields();
|
|
498
498
|
}, r.prototype.disable = function() {
|
|
499
|
-
|
|
499
|
+
I(x, E.instance());
|
|
500
500
|
}, r.prototype._getGlobalPropagator = function() {
|
|
501
501
|
return O(x) || _e;
|
|
502
502
|
}, r;
|
|
503
503
|
}()
|
|
504
|
-
),
|
|
505
|
-
const
|
|
506
|
-
constructor(e, t =
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
this.
|
|
504
|
+
), Ee = Oe.getInstance();
|
|
505
|
+
const F = ["bench", "debug", "prod"], Ae = (r) => (e) => F.indexOf(e) >= F.indexOf(r), y = class y {
|
|
506
|
+
constructor(e, t = Ae("debug")) {
|
|
507
|
+
u(this, "meta", b.NOOP);
|
|
508
|
+
u(this, "otelTracer");
|
|
509
|
+
u(this, "filter");
|
|
510
|
+
this.otelTracer = e, this.filter = t;
|
|
511
511
|
}
|
|
512
512
|
child(e) {
|
|
513
|
-
const t = new y(this.
|
|
513
|
+
const t = new y(this.otelTracer, this.filter);
|
|
514
514
|
return t.meta = e, t;
|
|
515
515
|
}
|
|
516
516
|
/**
|
|
@@ -560,22 +560,29 @@ const $ = ["bench", "debug", "prod"], Ee = (r) => (e) => $.indexOf(e) >= $.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
|
-
|
|
564
|
-
|
|
565
|
-
|
|
563
|
+
if (n == null) {
|
|
564
|
+
if (this.meta.noop || !this.filter(t) || this.otelTracer == null)
|
|
565
|
+
return () => {
|
|
566
|
+
};
|
|
567
|
+
const a = new V(e, this.otelTracer.startSpan(e));
|
|
568
|
+
return a.start(), () => a.end();
|
|
569
|
+
}
|
|
570
|
+
return this.meta.noop || !this.filter(t) || this.otelTracer == null ? n(new Ne(e)) : this.otelTracer.startActiveSpan(e, (a) => {
|
|
571
|
+
const o = new V(e, a);
|
|
572
|
+
return n(o);
|
|
566
573
|
});
|
|
567
574
|
}
|
|
568
575
|
/**
|
|
569
576
|
* Injects metadata about the current trace into the provided carrier. This
|
|
570
|
-
* metadata can be
|
|
571
|
-
* allow the trace to
|
|
577
|
+
* metadata can be parsed on teh other side of a network or IPC request to
|
|
578
|
+
* allow the trace to propagate across services.
|
|
572
579
|
*
|
|
573
580
|
* @param carrier - The carrier to inject the metadata into.
|
|
574
581
|
*/
|
|
575
582
|
propagate(e) {
|
|
576
583
|
if (this.meta.noop) return;
|
|
577
|
-
const t =
|
|
578
|
-
|
|
584
|
+
const t = ve.active();
|
|
585
|
+
Ee.inject(t, e, {
|
|
579
586
|
set: (n, a, o) => {
|
|
580
587
|
n[a] = o;
|
|
581
588
|
}
|
|
@@ -583,12 +590,12 @@ const $ = ["bench", "debug", "prod"], Ee = (r) => (e) => $.indexOf(e) >= $.index
|
|
|
583
590
|
}
|
|
584
591
|
};
|
|
585
592
|
/** Tracer implementation that does nothing */
|
|
586
|
-
|
|
587
|
-
let
|
|
588
|
-
class
|
|
593
|
+
u(y, "NOOP", new y());
|
|
594
|
+
let T = y;
|
|
595
|
+
class V {
|
|
589
596
|
constructor(e, t) {
|
|
590
|
-
|
|
591
|
-
|
|
597
|
+
u(this, "key");
|
|
598
|
+
u(this, "otel");
|
|
592
599
|
this.key = e, this.otel = t;
|
|
593
600
|
}
|
|
594
601
|
set(e, t) {
|
|
@@ -597,10 +604,26 @@ class Ae {
|
|
|
597
604
|
recordError(e) {
|
|
598
605
|
e != null && (this.otel.recordException(e), this.otel.setStatus({ code: R.ERROR }));
|
|
599
606
|
}
|
|
607
|
+
start() {
|
|
608
|
+
performance.mark(`alamos.trace.start.${this.key}`);
|
|
609
|
+
}
|
|
610
|
+
end() {
|
|
611
|
+
try {
|
|
612
|
+
performance.mark(`alamos.trace.end.${this.key}`);
|
|
613
|
+
const e = performance.measure(
|
|
614
|
+
`alamos.trace.duration.${this.key}`,
|
|
615
|
+
`alamos.trace.start.${this.key}`,
|
|
616
|
+
`alamos.trace.end.${this.key}`
|
|
617
|
+
);
|
|
618
|
+
this.set("duration", e.duration), this.set("duration", e.duration), this.otel.end();
|
|
619
|
+
} catch (e) {
|
|
620
|
+
console.error(e);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
600
623
|
}
|
|
601
624
|
class Ne {
|
|
602
625
|
constructor(e) {
|
|
603
|
-
|
|
626
|
+
u(this, "key");
|
|
604
627
|
this.key = e;
|
|
605
628
|
}
|
|
606
629
|
set() {
|
|
@@ -613,13 +636,13 @@ const m = class m {
|
|
|
613
636
|
key: e = "",
|
|
614
637
|
serviceName: t = "",
|
|
615
638
|
logger: n = P.NOOP,
|
|
616
|
-
tracer: a =
|
|
639
|
+
tracer: a = T.NOOP,
|
|
617
640
|
noop: o = !1,
|
|
618
641
|
__meta: i
|
|
619
642
|
}) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
643
|
+
u(this, "meta");
|
|
644
|
+
u(this, "T");
|
|
645
|
+
u(this, "L");
|
|
623
646
|
this.meta = i ?? new b(e, e, t, o), this.T = a.child(this.meta), this.L = n.child(this.meta);
|
|
624
647
|
}
|
|
625
648
|
child(e) {
|
|
@@ -627,23 +650,23 @@ const m = class m {
|
|
|
627
650
|
return new m({ __meta: t, tracer: this.T, logger: this.L });
|
|
628
651
|
}
|
|
629
652
|
};
|
|
630
|
-
|
|
631
|
-
let
|
|
632
|
-
const
|
|
653
|
+
u(m, "NOOP", new m({ noop: !0 }));
|
|
654
|
+
let C = m;
|
|
655
|
+
const Te = C.NOOP;
|
|
633
656
|
export {
|
|
634
|
-
|
|
657
|
+
K as C,
|
|
635
658
|
E as D,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
659
|
+
C as I,
|
|
660
|
+
j as L,
|
|
661
|
+
Te as N,
|
|
662
|
+
T,
|
|
663
|
+
V as _,
|
|
641
664
|
P as a,
|
|
642
665
|
Ne as b,
|
|
643
666
|
Pe as c,
|
|
644
|
-
|
|
667
|
+
oe as d,
|
|
645
668
|
O as g,
|
|
646
669
|
Re as l,
|
|
647
|
-
|
|
648
|
-
|
|
670
|
+
B as r,
|
|
671
|
+
I as u
|
|
649
672
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var k=(r,e,t)=>e in r?Y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var s=(r,e,t)=>k(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 T=["debug","info","warn","error"],D=r=>{const e=T.indexOf(r);return({level:t})=>T.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:{},g="1.9.0",$=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function H(r){var e=new Set([r]),t=new Set,n=r.match($);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(c){return c===r};function o(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($);if(!f)return o(c);var p={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return p.prerelease!=null||a.major!==p.major?o(c):a.major===0?a.minor===p.minor&&a.patch<=p.patch?i(c):o(c):a.minor<=p.minor?i(c):o(c)}}var J=H(g),Q=g.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:g};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!==g){var i=new Error("@opentelemetry/api: Registration of version v"+o.version+" for "+r+" does not match previously registered API v"+g);return t.error(i.stack||i.message),!1}return o[r]=e,t.debug("@opentelemetry/api: Registered a global for "+r+" v"+g+"."),!0}function h(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 C(r,e){e.debug("@opentelemetry/api: Unregistering a global for "+r+" v"+g+".");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=h("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,a){var o=e[n];return typeof o=="function"&&r>=a?o.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),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",d=function(){function r(){function e(a){return function(){for(var o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];var u=h("diag");if(u)return u[a].apply(u,ne([],re(o),!1))}}var t=this,n=function(a,o){var i,u,c;if(o===void 0&&(o={logLevel:l.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=h("diag"),j=te((u=o.logLevel)!==null&&u!==void 0?u:l.INFO,a);if(p&&!o.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),j.warn("Current logger will overwrite one already registered from "+F)}return R("diag",j,t,!0)};t.setLogger=n,t.disable=function(){C(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 c=u.value;o._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 o},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 V(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,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}(),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)}},ge=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},he=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))},de=function(){function r(){}return r.prototype.active=function(){return le},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,he([n],ge(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))},I="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(I,e,d.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 h(I)||me},r.prototype.disable=function(){this._getContextManager().disable(),C(I,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}(),S=V("OpenTelemetry Baggage Key");function U(r){return r.getValue(S)||void 0}function we(){return U(M.getInstance().active())}function Oe(r,e){return r.setValue(S,e)}function Ee(r){return r.deleteValue(S)}var B="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(B,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(){C(B,d.instance())},r.prototype._getGlobalPropagator=function(){return h(B)||Ae},r}(),xe=Ne.getInstance();const K=["bench","debug","prod"],Pe=r=>e=>K.indexOf(e)>=K.indexOf(r),b=class b{constructor(e,t=Pe("debug")){s(this,"meta",w.NOOP);s(this,"tracer");s(this,"filter");this.tracer=e,this.filter=t}child(e){const t=new b(this.tracer,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){return this.meta.noop||!this.filter(t)?n(new X(e)):this.tracer.startActiveSpan(e,a=>{const o=new W(e,a),i=n(o);return a.end(),i})}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 W{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}))}}class X{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=d;exports.Instrumentation=P;exports.LOG_LEVELS=T;exports.Logger=N;exports.NOOP=Re;exports.NoopSpan=X;exports.Tracer=x;exports._Span=W;exports.createContextKey=V;exports.getGlobal=h;exports.logLevelKeyFiler=q;exports.logThresholdFilter=D;exports.registerGlobal=R;exports.unregisterGlobal=C;
|
|
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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC;CACf;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;gBAEP,EACV,GAAQ,EACR,WAAgB,EAChB,MAAoB,EACpB,MAAoB,EACpB,IAAY,EAEZ,MAAM,GACP,EAAE,sBAAsB;IAMzB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,MAAM,WAAW,sBAAsB;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,IAAI,CAAC;CACf;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;gBAEP,EACV,GAAQ,EACR,WAAgB,EAChB,MAAoB,EACpB,MAAoB,EACpB,IAAY,EAEZ,MAAM,GACP,EAAE,sBAAsB;IAMzB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe;IAKnC,MAAM,CAAC,QAAQ,CAAC,IAAI,kBAAuC;CAC5D;AAED,eAAO,MAAM,IAAI,iBAAuB,CAAC"}
|
package/dist/trace.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AttributeValue, Span as OtelSpan, Tracer as OtelTracer } from '@opentelemetry/api';
|
|
2
|
+
import { Destructor } from '@synnaxlabs/x';
|
|
2
3
|
import { Environment, EnvironmentFilter } from './environment';
|
|
3
4
|
import { Meta } from './meta';
|
|
4
5
|
/** Carrier is an entitty that can carry trace metadata across process bounds */
|
|
@@ -11,55 +12,23 @@ export type SpanF = (span: Span) => unknown;
|
|
|
11
12
|
*/
|
|
12
13
|
export declare class Tracer {
|
|
13
14
|
private meta;
|
|
14
|
-
private readonly
|
|
15
|
+
private readonly otelTracer?;
|
|
15
16
|
private readonly filter;
|
|
16
17
|
constructor(tracer?: OtelTracer, filter?: EnvironmentFilter);
|
|
17
18
|
child(meta: Meta): Tracer;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
debug<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
28
|
-
/**
|
|
29
|
-
* Starts a new span in the bench environment. If a span already exists in the
|
|
30
|
-
* current context, it will be used as the parent span.
|
|
31
|
-
*
|
|
32
|
-
* @param key - The name of the span.
|
|
33
|
-
* @param f - The function to run under the span.
|
|
34
|
-
* @returns A span that tracks program execution. If the Tracer's environment
|
|
35
|
-
* rejects the 'bench' environment or the Tracer is noop, a NoopSpan is returned.
|
|
36
|
-
*/
|
|
37
|
-
bench<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
38
|
-
/**
|
|
39
|
-
* Starts a new span in the prod environment. If a span already exists in the
|
|
40
|
-
* current context, it will be used as the parent span.
|
|
41
|
-
*
|
|
42
|
-
* @param key - The name of the span.
|
|
43
|
-
* @param f - The function to run under the span.
|
|
44
|
-
* @returns A span that tracks program execution. If the Tracer's environment
|
|
45
|
-
* rejects the 'prod' environment or the Tracer is noop, a NoopSpan is returned.
|
|
46
|
-
*/
|
|
47
|
-
prod<F extends SpanF>(key: string, f: F): ReturnType<F>;
|
|
48
|
-
/**
|
|
49
|
-
* Stars a new span with the given key and environment. If a span already
|
|
50
|
-
* exists in the current context, it will be used as the parent span.
|
|
51
|
-
*
|
|
52
|
-
* @param key - The name of the span.
|
|
53
|
-
* @param env - The environment to run the span under.
|
|
54
|
-
* @param f - The function to run under the span.
|
|
55
|
-
* @returns A span that tracks program execution. If the Tracer's environment
|
|
56
|
-
* rejects the provided span or the Tracer is noop, a NoopSpan is returned.
|
|
57
|
-
*/
|
|
58
|
-
trace<F extends SpanF>(key: string, env: Environment, f: F): ReturnType<F>;
|
|
19
|
+
debug(key: string): Destructor;
|
|
20
|
+
debug<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
21
|
+
bench(key: string): Destructor;
|
|
22
|
+
bench<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
23
|
+
prod(key: string): Destructor;
|
|
24
|
+
prod<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
25
|
+
trace<F extends SpanF>(key: string, env: Environment, f?: F): ReturnType<F> | Destructor;
|
|
26
|
+
trace(key: string, env: Environment): Destructor;
|
|
27
|
+
trace<F extends SpanF>(key: string, env: Environment, f: F): ReturnType<F> | Destructor;
|
|
59
28
|
/**
|
|
60
29
|
* Injects metadata about the current trace into the provided carrier. This
|
|
61
|
-
* metadata can be
|
|
62
|
-
* allow the trace to
|
|
30
|
+
* metadata can be parsed on teh other side of a network or IPC request to
|
|
31
|
+
* allow the trace to propagate across services.
|
|
63
32
|
*
|
|
64
33
|
* @param carrier - The carrier to inject the metadata into.
|
|
65
34
|
*/
|
|
@@ -93,6 +62,8 @@ export declare class _Span implements Span {
|
|
|
93
62
|
constructor(key: string, span: OtelSpan);
|
|
94
63
|
set(key: string, value: AttributeValue): void;
|
|
95
64
|
recordError(error?: Error | null): void;
|
|
65
|
+
start(): void;
|
|
66
|
+
end(): void;
|
|
96
67
|
}
|
|
97
68
|
/** Span implementation that does nothing */
|
|
98
69
|
export declare class NoopSpan implements Span {
|
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;
|
|
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,GAAG,UAAU;IAerE,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,GAAG,UAAU;IAerE,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,GAAG,UAAU;IAcpE,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;IAC7B,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,UAAU;IAChD,KAAK,CAAC,CAAC,SAAS,KAAK,EACnB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,WAAW,EAChB,CAAC,EAAE,CAAC,GACH,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU;IAkC7B;;;;;;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;CAeZ;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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/alamos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Distributed instrumentation for Synnax",
|
|
6
6
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/freighter/ts",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@opentelemetry/api": "^1.9.0",
|
|
22
|
-
"@synnaxlabs/x": "0.
|
|
22
|
+
"@synnaxlabs/x": "0.42.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"eslint": "^9.
|
|
25
|
+
"eslint": "^9.24.0",
|
|
26
26
|
"madge": "^8.0.0",
|
|
27
|
-
"typescript": "^5.8.
|
|
28
|
-
"vite": "^6.2.
|
|
29
|
-
"vitest": "^
|
|
30
|
-
"
|
|
27
|
+
"typescript": "^5.8.3",
|
|
28
|
+
"vite": "^6.2.5",
|
|
29
|
+
"vitest": "^3.1.1",
|
|
30
|
+
"eslint-config-synnaxlabs": "0.0.1",
|
|
31
31
|
"@synnaxlabs/vite-plugin": "0.0.1",
|
|
32
|
-
"
|
|
32
|
+
"@synnaxlabs/tsconfig": "0.0.2"
|
|
33
33
|
},
|
|
34
34
|
"main": "dist/index.js",
|
|
35
35
|
"module": "dist/index.js",
|
package/src/instrumentation.ts
CHANGED
package/src/trace.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
SpanStatusCode,
|
|
16
16
|
type Tracer as OtelTracer,
|
|
17
17
|
} from "@opentelemetry/api";
|
|
18
|
+
import { type Destructor } from "@synnaxlabs/x";
|
|
18
19
|
|
|
19
20
|
import {
|
|
20
21
|
type Environment,
|
|
@@ -35,23 +36,26 @@ export type SpanF = (span: Span) => unknown;
|
|
|
35
36
|
*/
|
|
36
37
|
export class Tracer {
|
|
37
38
|
private meta: Meta = Meta.NOOP;
|
|
38
|
-
private readonly
|
|
39
|
+
private readonly otelTracer?: OtelTracer;
|
|
39
40
|
private readonly filter: EnvironmentFilter;
|
|
40
41
|
|
|
41
42
|
constructor(
|
|
42
43
|
tracer?: OtelTracer,
|
|
43
44
|
filter: EnvironmentFilter = envThresholdFilter("debug"),
|
|
44
45
|
) {
|
|
45
|
-
this.
|
|
46
|
+
this.otelTracer = tracer;
|
|
46
47
|
this.filter = filter;
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
child(meta: Meta): Tracer {
|
|
50
|
-
const t = new Tracer(this.
|
|
51
|
+
const t = new Tracer(this.otelTracer, this.filter);
|
|
51
52
|
t.meta = meta;
|
|
52
53
|
return t;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
debug(key: string): Destructor;
|
|
57
|
+
debug<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
58
|
+
|
|
55
59
|
/**
|
|
56
60
|
* Starts a new span in the debug environment. If a span already exists in the
|
|
57
61
|
* current context, it will be used as the parent span.
|
|
@@ -61,10 +65,13 @@ export class Tracer {
|
|
|
61
65
|
* @returns A span that tracks program execution. If the Tracer's environment
|
|
62
66
|
* rejects the 'debug' environment or the Tracer is noop, a NoopSpan is returned.
|
|
63
67
|
*/
|
|
64
|
-
debug<F extends SpanF>(key: string, f
|
|
68
|
+
debug<F extends SpanF>(key: string, f?: F): ReturnType<F> | Destructor {
|
|
65
69
|
return this.trace(key, "debug", f);
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
bench(key: string): Destructor;
|
|
73
|
+
bench<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
74
|
+
|
|
68
75
|
/**
|
|
69
76
|
* Starts a new span in the bench environment. If a span already exists in the
|
|
70
77
|
* current context, it will be used as the parent span.
|
|
@@ -74,10 +81,13 @@ export class Tracer {
|
|
|
74
81
|
* @returns A span that tracks program execution. If the Tracer's environment
|
|
75
82
|
* rejects the 'bench' environment or the Tracer is noop, a NoopSpan is returned.
|
|
76
83
|
*/
|
|
77
|
-
bench<F extends SpanF>(key: string, f
|
|
84
|
+
bench<F extends SpanF>(key: string, f?: F): ReturnType<F> | Destructor {
|
|
78
85
|
return this.trace(key, "bench", f);
|
|
79
86
|
}
|
|
80
87
|
|
|
88
|
+
prod(key: string): Destructor;
|
|
89
|
+
prod<F extends SpanF>(key: string, f: F): ReturnType<F> | Destructor;
|
|
90
|
+
|
|
81
91
|
/**
|
|
82
92
|
* Starts a new span in the prod environment. If a span already exists in the
|
|
83
93
|
* current context, it will be used as the parent span.
|
|
@@ -87,9 +97,20 @@ export class Tracer {
|
|
|
87
97
|
* @returns A span that tracks program execution. If the Tracer's environment
|
|
88
98
|
* rejects the 'prod' environment or the Tracer is noop, a NoopSpan is returned.
|
|
89
99
|
*/
|
|
90
|
-
prod<F extends SpanF>(key: string, f
|
|
100
|
+
prod<F extends SpanF>(key: string, f?: F): ReturnType<F> | Destructor {
|
|
91
101
|
return this.trace(key, "prod", f);
|
|
92
102
|
}
|
|
103
|
+
trace<F extends SpanF>(
|
|
104
|
+
key: string,
|
|
105
|
+
env: Environment,
|
|
106
|
+
f?: F,
|
|
107
|
+
): ReturnType<F> | Destructor;
|
|
108
|
+
trace(key: string, env: Environment): Destructor;
|
|
109
|
+
trace<F extends SpanF>(
|
|
110
|
+
key: string,
|
|
111
|
+
env: Environment,
|
|
112
|
+
f: F,
|
|
113
|
+
): ReturnType<F> | Destructor;
|
|
93
114
|
|
|
94
115
|
/**
|
|
95
116
|
* Stars a new span with the given key and environment. If a span already
|
|
@@ -101,21 +122,32 @@ export class Tracer {
|
|
|
101
122
|
* @returns A span that tracks program execution. If the Tracer's environment
|
|
102
123
|
* rejects the provided span or the Tracer is noop, a NoopSpan is returned.
|
|
103
124
|
*/
|
|
104
|
-
trace<F extends SpanF>(
|
|
105
|
-
|
|
125
|
+
trace<F extends SpanF>(
|
|
126
|
+
key: string,
|
|
127
|
+
env: Environment,
|
|
128
|
+
f?: F,
|
|
129
|
+
): ReturnType<F> | Destructor {
|
|
130
|
+
if (f == null) {
|
|
131
|
+
if (this.meta.noop || !this.filter(env) || this.otelTracer == null)
|
|
132
|
+
return () => {};
|
|
133
|
+
const span = new _Span(key, this.otelTracer.startSpan(key));
|
|
134
|
+
span.start();
|
|
135
|
+
return () => span.end();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.meta.noop || !this.filter(env) || this.otelTracer == null)
|
|
106
139
|
return f(new NoopSpan(key)) as ReturnType<F>;
|
|
107
|
-
return this.
|
|
140
|
+
return this.otelTracer.startActiveSpan(key, (otelSpan) => {
|
|
108
141
|
const span = new _Span(key, otelSpan);
|
|
109
142
|
const result = f(span);
|
|
110
|
-
otelSpan.end();
|
|
111
143
|
return result as ReturnType<F>;
|
|
112
144
|
});
|
|
113
145
|
}
|
|
114
146
|
|
|
115
147
|
/**
|
|
116
148
|
* Injects metadata about the current trace into the provided carrier. This
|
|
117
|
-
* metadata can be
|
|
118
|
-
* allow the trace to
|
|
149
|
+
* metadata can be parsed on teh other side of a network or IPC request to
|
|
150
|
+
* allow the trace to propagate across services.
|
|
119
151
|
*
|
|
120
152
|
* @param carrier - The carrier to inject the metadata into.
|
|
121
153
|
*/
|
|
@@ -172,6 +204,26 @@ export class _Span implements Span {
|
|
|
172
204
|
this.otel.recordException(error);
|
|
173
205
|
this.otel.setStatus({ code: SpanStatusCode.ERROR });
|
|
174
206
|
}
|
|
207
|
+
|
|
208
|
+
start(): void {
|
|
209
|
+
performance.mark(`alamos.trace.start.${this.key}`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
end(): void {
|
|
213
|
+
try {
|
|
214
|
+
performance.mark(`alamos.trace.end.${this.key}`);
|
|
215
|
+
const duration = performance.measure(
|
|
216
|
+
`alamos.trace.duration.${this.key}`,
|
|
217
|
+
`alamos.trace.start.${this.key}`,
|
|
218
|
+
`alamos.trace.end.${this.key}`,
|
|
219
|
+
);
|
|
220
|
+
this.set("duration", duration.duration);
|
|
221
|
+
this.set("duration", duration.duration);
|
|
222
|
+
this.otel.end();
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error(e);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
175
227
|
}
|
|
176
228
|
|
|
177
229
|
/** Span implementation that does nothing */
|