@synnaxlabs/alamos 0.2.0 → 0.23.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.
Files changed (45) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/dev/index.d.ts +2 -0
  3. package/dist/dev/index.d.ts.map +1 -0
  4. package/dist/dev.cjs +1 -2
  5. package/dist/dev.js +70 -10812
  6. package/dist/environment.d.ts +1 -0
  7. package/dist/environment.d.ts.map +1 -0
  8. package/dist/external.d.ts +2 -1
  9. package/dist/external.d.ts.map +1 -0
  10. package/dist/index.cjs +1 -2
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +1 -2
  14. package/dist/{instrumentation-wOKsWHkZ.js → instrumentation-C9vttMJJ.js} +18 -22
  15. package/dist/instrumentation-Di8UqEoG.cjs +1 -0
  16. package/dist/instrumentation.d.ts +4 -2
  17. package/dist/instrumentation.d.ts.map +1 -0
  18. package/dist/log.d.ts +9 -5
  19. package/dist/log.d.ts.map +1 -0
  20. package/dist/meta.d.ts +1 -0
  21. package/dist/meta.d.ts.map +1 -0
  22. package/dist/trace.d.ts +5 -3
  23. package/dist/trace.d.ts.map +1 -0
  24. package/dist/trace.spec.d.ts +1 -0
  25. package/dist/trace.spec.d.ts.map +1 -0
  26. package/eslint.config.js +12 -0
  27. package/package.json +12 -13
  28. package/src/dev/index.ts +1 -20
  29. package/src/environment.ts +1 -1
  30. package/src/external.ts +2 -2
  31. package/src/index.ts +1 -1
  32. package/src/instrumentation.ts +3 -3
  33. package/src/log.ts +12 -16
  34. package/src/meta.ts +1 -1
  35. package/src/trace.spec.ts +2 -2
  36. package/src/trace.ts +6 -6
  37. package/vite.config.ts +3 -5
  38. package/.eslintrc.cjs +0 -18
  39. package/dist/dev.cjs.map +0 -1
  40. package/dist/dev.js.map +0 -1
  41. package/dist/index.cjs.map +0 -1
  42. package/dist/index.js.map +0 -1
  43. package/dist/instrumentation-KXpmw8Ox.cjs +0 -2
  44. package/dist/instrumentation-KXpmw8Ox.cjs.map +0 -1
  45. package/dist/instrumentation-wOKsWHkZ.js.map +0 -1
@@ -16,3 +16,4 @@ export type EnvironmentFilter = (env: Environment) => boolean;
16
16
  * than or equal to the given threshold.
17
17
  */
18
18
  export declare const envThresholdFilter: (treshold: Environment) => EnvironmentFilter;
19
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AASA,mCAAmC;AACnC,eAAO,MAAM,YAAY,qCAAsC,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAClB,WAAW,KAAG,iBAEoC,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { Instrumentation, NOOP } from './instrumentation';
1
2
  export * from './log';
2
3
  export * from './trace';
3
- export { Instrumentation, NOOP } from './instrumentation';
4
+ //# sourceMappingURL=external.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC1D,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./instrumentation-KXpmw8Ox.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;
2
- //# sourceMappingURL=index.cjs.map
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./instrumentation-Di8UqEoG.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.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './external';
2
2
  export * as alamos from './external';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,MAAM,MAAM,YAAY,CAAC"}
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-wOKsWHkZ.js";
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-C9vttMJJ.js";
2
2
  const g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3
3
  __proto__: null,
4
4
  Instrumentation: e,
@@ -23,4 +23,3 @@ export {
23
23
  n as logLevelKeyFiler,
24
24
  p as logThresholdFilter
25
25
  };
26
- //# sourceMappingURL=index.js.map
@@ -47,26 +47,24 @@ const S = ["debug", "info", "warn", "error"], Pe = (r) => {
47
47
  const t = new v({ filters: this.filters });
48
48
  return t.meta = e, t;
49
49
  }
50
- debug(e, t) {
51
- this.filter("debug") && (t == null ? console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e) : console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, e, A(t)));
50
+ 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, A(t)));
52
52
  }
53
- info(e, t) {
54
- this.filter("info") && (t == null ? console.log("%cINFO", "color: #005eff;", this.meta.path, e) : console.log("%cINFO", "color: #005eff;", this.meta.path, e, A(t)));
53
+ 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, A(t)));
55
55
  }
56
- warn(e, t) {
57
- this.filter("warn") && (t == null ? console.warn("WARN", this.meta.path, e) : console.warn("WARN", this.meta.path, e, A(t)));
56
+ 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, A(t)));
58
58
  }
59
- error(e, t) {
60
- this.filter("error") && (t == null ? console.error("ERROR", this.meta.path, e) : console.error("ERROR", this.meta.path, e, A(t)));
59
+ 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, A(t)));
61
61
  }
62
62
  };
63
63
  s(v, "NOOP", new v());
64
64
  let P = v;
65
- const A = (r) => (Object.entries(r).forEach(([e, t]) => {
66
- typeof t == "function" && (r[e] = t());
67
- }), r);
68
- var k = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {}, g = "1.6.0", F = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
69
- function X(r) {
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 : {}, g = "1.8.0", F = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
67
+ function Y(r) {
70
68
  var e = /* @__PURE__ */ new Set([r]), t = /* @__PURE__ */ new Set(), n = r.match(F);
71
69
  if (!n)
72
70
  return function() {
@@ -105,7 +103,7 @@ function X(r) {
105
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);
106
104
  };
107
105
  }
108
- var Y = X(g), D = g.split(".")[0], _ = Symbol.for("opentelemetry.js.api." + D), w = k;
106
+ var k = Y(g), D = g.split(".")[0], _ = Symbol.for("opentelemetry.js.api." + D), w = X;
109
107
  function I(r, e, t, n) {
110
108
  var a;
111
109
  n === void 0 && (n = !1);
@@ -124,7 +122,7 @@ function I(r, e, t, n) {
124
122
  }
125
123
  function O(r) {
126
124
  var e, t, n = (e = w[_]) === null || e === void 0 ? void 0 : e.version;
127
- if (!(!n || !Y(n)))
125
+ if (!(!n || !k(n)))
128
126
  return (t = w[_]) === null || t === void 0 ? void 0 : t[r];
129
127
  }
130
128
  function T(r, e) {
@@ -255,12 +253,12 @@ var Q = function(r, e) {
255
253
  typeof o == "number" && (o = {
256
254
  logLevel: o
257
255
  });
258
- var p = O("diag"), j = J((u = o.logLevel) !== null && u !== void 0 ? u : l.INFO, a);
256
+ var p = O("diag"), G = J((u = o.logLevel) !== null && u !== void 0 ? u : l.INFO, a);
259
257
  if (p && !o.suppressOverrideMessage) {
260
- var G = (c = new Error().stack) !== null && c !== void 0 ? c : "<failed to generate stacktrace>";
261
- p.warn("Current logger will be overwritten from " + G), j.warn("Current logger will overwrite one already registered from " + G);
258
+ var j = (c = new Error().stack) !== null && c !== void 0 ? c : "<failed to generate stacktrace>";
259
+ p.warn("Current logger will be overwritten from " + j), G.warn("Current logger will overwrite one already registered from " + j);
262
260
  }
263
- return I("diag", j, t, !0);
261
+ return I("diag", G, t, !0);
264
262
  };
265
263
  t.setLogger = n, t.disable = function() {
266
264
  T(L, t);
@@ -628,7 +626,7 @@ class Ne {
628
626
  s(this, "key");
629
627
  this.key = e;
630
628
  }
631
- set(e, t) {
629
+ set() {
632
630
  }
633
631
  recordError(e) {
634
632
  }
@@ -640,7 +638,6 @@ const m = class m {
640
638
  logger: n = P.NOOP,
641
639
  tracer: a = C.NOOP,
642
640
  noop: o = !1,
643
- // eslint-disable-next-line @typescript-eslint/naming-convention
644
641
  __meta: i
645
642
  }) {
646
643
  s(this, "meta");
@@ -673,4 +670,3 @@ export {
673
670
  I as r,
674
671
  T as u
675
672
  };
676
- //# sourceMappingURL=instrumentation-wOKsWHkZ.js.map
@@ -0,0 +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),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.8.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,6 +1,7 @@
1
- import { Logger } from './log';
2
- import { Meta } from './meta';
3
1
  import { Tracer } from './trace';
2
+ import { Meta } from './meta';
3
+ import { Logger } from './log';
4
+
4
5
  export interface InstrumentationOptions {
5
6
  key?: string;
6
7
  serviceName?: string;
@@ -18,3 +19,4 @@ export declare class Instrumentation {
18
19
  static readonly NOOP: Instrumentation;
19
20
  }
20
21
  export declare const NOOP: Instrumentation;
22
+ //# sourceMappingURL=instrumentation.d.ts.map
@@ -0,0 +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;IAMnC,MAAM,CAAC,QAAQ,CAAC,IAAI,kBAAuC;CAC5D;AAED,eAAO,MAAM,IAAI,iBAAuB,CAAC"}
package/dist/log.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { type UnknownRecord } from "@synnaxlabs/x";
2
1
  import { Meta } from './meta';
2
+ import { UnknownRecord } from '@synnaxlabs/x';
3
+
3
4
  export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
4
5
  export type LogLevel = (typeof LOG_LEVELS)[number];
5
6
  export interface LogLevelFilterProps {
@@ -7,6 +8,7 @@ export interface LogLevelFilterProps {
7
8
  path: string;
8
9
  level: LogLevel;
9
10
  }
11
+ type KV = UnknownRecord | (() => UnknownRecord);
10
12
  /**
11
13
  * LogLevelFilter is a function that returns true if the log at the given
12
14
  * level should be emitted.
@@ -27,9 +29,11 @@ export declare class Logger {
27
29
  constructor(p?: LoggerProps);
28
30
  private filter;
29
31
  child(meta: Meta): Logger;
30
- debug(msg: string, kv?: UnknownRecord): void;
31
- info(msg: string, kv?: UnknownRecord): void;
32
- warn(msg: string, kv?: UnknownRecord): void;
33
- error(msg: string, kv?: UnknownRecord): void;
32
+ debug(msg: string, kv?: KV, force?: boolean): void;
33
+ info(msg: string, kv?: KV, force?: boolean): void;
34
+ warn(msg: string, kv?: KV, force?: boolean): void;
35
+ error(msg: string, kv?: KV, force?: boolean): void;
34
36
  static readonly NOOP: Logger;
35
37
  }
38
+ export {};
39
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,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,aAAa,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,mBAAmB,KAAK,OAAO,CAAC;AAErE,eAAO,MAAM,kBAAkB,WAAY,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,UAAW,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/meta.d.ts CHANGED
@@ -9,3 +9,4 @@ export declare class Meta {
9
9
  get noop(): boolean;
10
10
  static readonly NOOP: Meta;
11
11
  }
12
+ //# sourceMappingURL=meta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../src/meta.ts"],"names":[],"mappings":"AASA,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAG3B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,MAAW,EACxB,IAAI,GAAE,OAAe;IAQvB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI/B,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAwB;CAC7C"}
package/dist/trace.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { type Span as OtelSpan, type Tracer as OtelTracer, type AttributeValue } from "@opentelemetry/api";
2
- import { type Environment, type EnvironmentFilter } from './environment';
3
1
  import { Meta } from './meta';
2
+ import { Environment, EnvironmentFilter } from './environment';
3
+ import { AttributeValue, Span as OtelSpan, Tracer as OtelTracer } from '@opentelemetry/api';
4
+
4
5
  /** Carrier is an entitty that can carry trace metadata across process bounds */
5
6
  export type Carrier = Record<string, string>;
6
7
  /** Function that executes under the given span */
@@ -98,6 +99,7 @@ export declare class _Span implements Span {
98
99
  export declare class NoopSpan implements Span {
99
100
  key: string;
100
101
  constructor(key: string);
101
- set(key: string, value: AttributeValue): void;
102
+ set(): void;
102
103
  recordError(_?: Error | null): void;
103
104
  }
105
+ //# sourceMappingURL=trace.d.ts.map
@@ -0,0 +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;AAE5B,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,MAAM,CAAa;IACpC,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;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAIxD;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAIxD;;;;;;;;OAQG;IACH,IAAI,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAIvD;;;;;;;;;OASG;IACH,KAAK,CAAC,CAAC,SAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAW1E;;;;;;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;CAKxC;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"}
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=trace.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace.spec.d.ts","sourceRoot":"","sources":["../src/trace.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ // Copyright 2024 Synnax Labs, Inc.
2
+ //
3
+ // Use of this software is governed by the Business Source License included in the file
4
+ // licenses/BSL.txt.
5
+ //
6
+ // As of the Change Date specified in that file, in accordance with the Business Source
7
+ // License, use of this software will be governed by the Apache License, Version 2.0,
8
+ // included in the file licenses/APL.txt.
9
+
10
+ import synnaxConfig from "eslint-config-synnaxlabs";
11
+
12
+ export default synnaxConfig
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/alamos",
3
- "private": false,
4
- "version": "0.2.0",
3
+ "version": "0.23.0",
5
4
  "type": "module",
6
5
  "description": "Distributed instrumentation for Synnax",
7
6
  "repository": "https://github.com/synnaxlabs/synnax/tree/main/freighter/ts",
@@ -19,19 +18,19 @@
19
18
  "node": ">=18"
20
19
  },
21
20
  "dependencies": {
22
- "@opentelemetry/api": "^1.6.0",
23
- "@opentelemetry/context-zone": "^1.17.1",
24
- "@opentelemetry/instrumentation-document-load": "^0.33.2",
25
- "@opentelemetry/sdk-trace-web": "^1.17.1",
26
- "@uptrace/node": "^1.17.0",
27
- "@uptrace/web": "^1.11.1",
28
- "@synnaxlabs/x": "0.12.0"
21
+ "@opentelemetry/api": "^1.8.0",
22
+ "@opentelemetry/context-zone": "^1.23.0",
23
+ "@opentelemetry/instrumentation-document-load": "^0.37.0",
24
+ "@opentelemetry/sdk-trace-web": "^1.23.0",
25
+ "@uptrace/node": "^1.19.0",
26
+ "@uptrace/web": "^1.19.0",
27
+ "@synnaxlabs/x": "0.23.0"
29
28
  },
30
29
  "devDependencies": {
31
- "@vitest/coverage-v8": "^1.2.",
32
- "typescript": "^5.3.3",
33
- "vite": "^5.1.2",
34
- "vitest": "^1.2.2",
30
+ "@vitest/coverage-v8": "^1.5.0",
31
+ "typescript": "^5.4.5",
32
+ "vite": "5.2.11",
33
+ "vitest": "^1.5.0",
35
34
  "@synnaxlabs/tsconfig": "0.0.2",
36
35
  "@synnaxlabs/vite-plugin": "0.0.1",
37
36
  "eslint-config-synnaxlabs": "0.0.1"
package/src/dev/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -8,32 +8,13 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import { trace } from "@opentelemetry/api";
11
- import { runtime } from "@synnaxlabs/x";
12
- import uptrace from "@uptrace/web";
13
11
 
14
12
  import { Instrumentation } from "@/instrumentation";
15
13
  import { Logger } from "@/log";
16
14
  import { Tracer } from "@/trace";
17
15
 
18
- const configureOpentelemetry = (config: uptrace.Config): void => {
19
- if (runtime.RUNTIME === "browser") {
20
- uptrace.configureOpentelemetry(config);
21
- } else {
22
- // eslint-disable-next-line @typescript-eslint/no-var-requires
23
- const uptrace = require("@uptrace/node");
24
- uptrace.configureOpentelemetry(config);
25
- }
26
- };
27
-
28
- const DEV_DSN = "http://synnax_dev@localhost:14318/2";
29
-
30
16
  export const instrumentation = (): Instrumentation => {
31
17
  const serviceName = "synnax";
32
- configureOpentelemetry({
33
- dsn: DEV_DSN,
34
- serviceName,
35
- deploymentEnvironment: "dev",
36
- });
37
18
  return new Instrumentation({
38
19
  key: "",
39
20
  serviceName,
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
package/src/external.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,6 +7,6 @@
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
+ export { Instrumentation, NOOP } from "@/instrumentation";
10
11
  export * from "@/log";
11
12
  export * from "@/trace";
12
- export { Instrumentation, NOOP } from "@/instrumentation";
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -31,7 +31,7 @@ export class Instrumentation {
31
31
  logger = Logger.NOOP,
32
32
  tracer = Tracer.NOOP,
33
33
  noop = false,
34
- // eslint-disable-next-line @typescript-eslint/naming-convention
34
+
35
35
  __meta,
36
36
  }: InstrumentationOptions) {
37
37
  this.meta = __meta ?? new Meta(key, key, serviceName, noop);
@@ -40,7 +40,7 @@ export class Instrumentation {
40
40
  }
41
41
 
42
42
  child(key: string): Instrumentation {
43
- // eslint-disable-next-line @typescript-eslint/naming-convention
43
+
44
44
  const __meta = this.meta.child(key);
45
45
  return new Instrumentation({ __meta, tracer: this.T, logger: this.L });
46
46
  }
package/src/log.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -20,6 +20,8 @@ export interface LogLevelFilterProps {
20
20
  level: LogLevel;
21
21
  }
22
22
 
23
+ type KV = UnknownRecord | (() => UnknownRecord);
24
+
23
25
  /**
24
26
  * LogLevelFilter is a function that returns true if the log at the given
25
27
  * level should be emitted.
@@ -76,26 +78,26 @@ export class Logger {
76
78
  return l;
77
79
  }
78
80
 
79
- debug(msg: string, kv?: UnknownRecord): void {
80
- if (!this.filter("debug")) return;
81
+ debug(msg: string, kv?: KV, force: boolean = false): void {
82
+ if (!this.filter("debug") && !force) return;
81
83
  if (kv == null) console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, msg);
82
84
  else console.log("%cDEBUG", "color: #8c00f0;", this.meta.path, msg, parseKV(kv));
83
85
  }
84
86
 
85
- info(msg: string, kv?: UnknownRecord): void {
86
- if (!this.filter("info")) return;
87
+ info(msg: string, kv?: KV, force: boolean = false): void {
88
+ if (!this.filter("info") && !force) return;
87
89
  if (kv == null) console.log("%cINFO", "color: #005eff;", this.meta.path, msg);
88
90
  else console.log("%cINFO", "color: #005eff;", this.meta.path, msg, parseKV(kv));
89
91
  }
90
92
 
91
- warn(msg: string, kv?: UnknownRecord): void {
92
- if (!this.filter("warn")) return;
93
+ warn(msg: string, kv?: KV, force: boolean = false): void {
94
+ if (!this.filter("warn") && !force) return;
93
95
  if (kv == null) console.warn("WARN", this.meta.path, msg);
94
96
  else console.warn("WARN", this.meta.path, msg, parseKV(kv));
95
97
  }
96
98
 
97
- error(msg: string, kv?: UnknownRecord): void {
98
- if (!this.filter("error")) return;
99
+ error(msg: string, kv?: KV, force: boolean = false): void {
100
+ if (!this.filter("error") && !force) return;
99
101
  if (kv == null) console.error("ERROR", this.meta.path, msg);
100
102
  else console.error("ERROR", this.meta.path, msg, parseKV(kv));
101
103
  }
@@ -103,10 +105,4 @@ export class Logger {
103
105
  static readonly NOOP = new Logger();
104
106
  }
105
107
 
106
- const parseKV = (kv: UnknownRecord): UnknownRecord => {
107
- Object.entries(kv).forEach(([k, v]) => {
108
- if (typeof v === "function") kv[k] = v();
109
- });
110
- return kv;
111
- }
112
-
108
+ const parseKV = (kv: KV): UnknownRecord => (typeof kv === "function" ? kv() : kv);
package/src/meta.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
package/src/trace.spec.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -10,7 +10,7 @@
10
10
  import { beforeAll, describe, expect, it } from "vitest";
11
11
 
12
12
  import { instrumentation } from "@/dev";
13
- import { Instrumentation } from "@/instrumentation";
13
+ import { type Instrumentation } from "@/instrumentation";
14
14
  import { Tracer } from "@/trace";
15
15
 
16
16
  describe("Trace", () => {
package/src/trace.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -8,12 +8,12 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import {
11
- type Span as OtelSpan,
12
- type Tracer as OtelTracer,
11
+ type AttributeValue,
13
12
  context,
14
- SpanStatusCode,
15
13
  propagation,
16
- type AttributeValue,
14
+ type Span as OtelSpan,
15
+ SpanStatusCode,
16
+ type Tracer as OtelTracer,
17
17
  } from "@opentelemetry/api";
18
18
 
19
19
  import {
@@ -182,7 +182,7 @@ export class NoopSpan implements Span {
182
182
  this.key = key;
183
183
  }
184
184
 
185
- set(key: string, value: AttributeValue): void {}
185
+ set(): void {}
186
186
 
187
187
  recordError(_?: Error | null): void {}
188
188
  }
package/vite.config.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 Synnax Labs, Inc.
1
+ // Copyright 2024 Synnax Labs, Inc.
2
2
  //
3
3
  // Use of this software is governed by the Business Source License included in the file
4
4
  // licenses/BSL.txt.
@@ -7,20 +7,18 @@
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 { isProd, lib } from "@synnaxlabs/vite-plugin";
10
11
  import path from "path";
11
12
  import { defineConfig } from "vite";
12
- import { lib } from "@synnaxlabs/vite-plugin";
13
13
 
14
14
  export default defineConfig({
15
15
  plugins: [lib({ name: "alamos" })],
16
16
  build: {
17
- sourcemap: true,
18
- minify: true,
19
17
  lib: {
20
18
  entry: {
21
19
  index: path.resolve(".", "src/index.ts"),
22
20
  dev: path.resolve(".", "src/dev/index.ts"),
23
21
  },
24
- }
22
+ },
25
23
  },
26
24
  });
package/.eslintrc.cjs DELETED
@@ -1,18 +0,0 @@
1
- /*
2
- * Copyright 2023 Synnax Labs, Inc.
3
- *
4
- * Use of this software is governed by the Business Source License included in the file
5
- * licenses/BSL.txt.
6
- *
7
- * As of the Change Date specified in that file, in accordance with the Business Source
8
- * License, use of this software will be governed by the Apache License, Version 2.0,
9
- * included in the file licenses/APL.txt.
10
- */
11
-
12
- module.exports = {
13
- root: true,
14
- extends: ["synnaxlabs"],
15
- parserOptions: {
16
- project: "./tsconfig.json",
17
- },
18
- };