@dxos/tracing 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea

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.
@@ -6,11 +6,10 @@ import { Context as Context2 } from "@dxos/context";
6
6
  // src/symbols.ts
7
7
  var symbolTracingContext = Symbol("dxos.tracing.context");
8
8
  var getTracingContext = (target) => {
9
- var _target, _symbolTracingContext;
10
- return (_target = target)[_symbolTracingContext = symbolTracingContext] ?? (_target[_symbolTracingContext] = {
9
+ return target[symbolTracingContext] ??= {
11
10
  infoProperties: {},
12
11
  metricsProperties: {}
13
- });
12
+ };
14
13
  };
15
14
  var TRACE_SPAN_ATTRIBUTE = "dxos.trace-span";
16
15
 
@@ -27,37 +26,27 @@ import { invariant } from "@dxos/invariant";
27
26
  var createId = () => Math.random().toString(36).slice(2);
28
27
 
29
28
  // src/diagnostic.ts
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
29
  var __dxlog_file = "/__w/dxos/dxos/packages/common/tracing/src/diagnostic.ts";
44
30
  var DIAGNOSTICS_TIMEOUT = 1e4;
45
31
  var TraceDiagnosticImpl = class {
46
- unregister() {
47
- this._onUnregister();
48
- }
32
+ id;
33
+ fetch;
34
+ name;
35
+ _onUnregister;
49
36
  constructor(id, fetch, name, _onUnregister) {
50
- _define_property(this, "id", void 0);
51
- _define_property(this, "fetch", void 0);
52
- _define_property(this, "name", void 0);
53
- _define_property(this, "_onUnregister", void 0);
54
37
  this.id = id;
55
38
  this.fetch = fetch;
56
39
  this.name = name;
57
40
  this._onUnregister = _onUnregister;
58
41
  }
42
+ unregister() {
43
+ this._onUnregister();
44
+ }
59
45
  };
60
46
  var DiagnosticsManager = class {
47
+ instanceId = createId();
48
+ registry = /* @__PURE__ */ new Map();
49
+ _instanceTag = null;
61
50
  get instanceTag() {
62
51
  return this._instanceTag;
63
52
  }
@@ -120,37 +109,34 @@ var DiagnosticsManager = class {
120
109
  };
121
110
  }
122
111
  }
123
- constructor() {
124
- _define_property(this, "instanceId", createId());
125
- _define_property(this, "registry", /* @__PURE__ */ new Map());
126
- _define_property(this, "_instanceTag", null);
127
- }
128
112
  };
129
113
 
130
114
  // src/diagnostics-channel.ts
131
115
  import { Trigger, sleep } from "@dxos/async";
132
116
  import { Context } from "@dxos/context";
133
117
  import { invariant as invariant2 } from "@dxos/invariant";
134
- function _define_property2(obj, key, value) {
135
- if (key in obj) {
136
- Object.defineProperty(obj, key, {
137
- value,
138
- enumerable: true,
139
- configurable: true,
140
- writable: true
141
- });
142
- } else {
143
- obj[key] = value;
144
- }
145
- return obj;
146
- }
147
118
  var __dxlog_file2 = "/__w/dxos/dxos/packages/common/tracing/src/diagnostics-channel.ts";
148
119
  var DEFAULT_CHANNEL_NAME = "dxos-diagnostics";
149
120
  var DISCOVER_TIME = 500;
150
121
  var DiagnosticsChannel = class _DiagnosticsChannel {
122
+ _channelName;
151
123
  static get supported() {
152
124
  return globalThis.BroadcastChannel != null;
153
125
  }
126
+ _ctx = new Context(void 0, {
127
+ F: __dxlog_file2,
128
+ L: 46
129
+ });
130
+ // Separate channels becauase the client and server may be in the same process.
131
+ _serveChannel = void 0;
132
+ _clientChannel = void 0;
133
+ constructor(_channelName = DEFAULT_CHANNEL_NAME) {
134
+ this._channelName = _channelName;
135
+ if (_DiagnosticsChannel.supported) {
136
+ this._serveChannel = new BroadcastChannel(_channelName);
137
+ this._clientChannel = new BroadcastChannel(_channelName);
138
+ }
139
+ }
154
140
  destroy() {
155
141
  void this._ctx.dispose();
156
142
  this._serveChannel?.close();
@@ -276,40 +262,11 @@ var DiagnosticsChannel = class _DiagnosticsChannel {
276
262
  this._clientChannel.removeEventListener("message", listener);
277
263
  }
278
264
  }
279
- constructor(_channelName = DEFAULT_CHANNEL_NAME) {
280
- _define_property2(this, "_channelName", void 0);
281
- _define_property2(this, "_ctx", void 0);
282
- _define_property2(this, "_serveChannel", void 0);
283
- _define_property2(this, "_clientChannel", void 0);
284
- this._channelName = _channelName;
285
- this._ctx = new Context(void 0, {
286
- F: __dxlog_file2,
287
- L: 46
288
- });
289
- this._serveChannel = void 0;
290
- this._clientChannel = void 0;
291
- if (_DiagnosticsChannel.supported) {
292
- this._serveChannel = new BroadcastChannel(_channelName);
293
- this._clientChannel = new BroadcastChannel(_channelName);
294
- }
295
- }
296
265
  };
297
266
 
298
267
  // src/remote/metrics.ts
299
- function _define_property3(obj, key, value) {
300
- if (key in obj) {
301
- Object.defineProperty(obj, key, {
302
- value,
303
- enumerable: true,
304
- configurable: true,
305
- writable: true
306
- });
307
- } else {
308
- obj[key] = value;
309
- }
310
- return obj;
311
- }
312
268
  var RemoteMetrics = class {
269
+ _metrics = /* @__PURE__ */ new Set();
313
270
  registerProcessor(processor) {
314
271
  this._metrics.add(processor);
315
272
  }
@@ -325,26 +282,12 @@ var RemoteMetrics = class {
325
282
  gauge(name, value, data) {
326
283
  return Array.from(this._metrics.values()).map((processor) => processor.gauge(name, value, data));
327
284
  }
328
- constructor() {
329
- _define_property3(this, "_metrics", /* @__PURE__ */ new Set());
330
- }
331
285
  };
332
286
 
333
287
  // src/remote/tracing.ts
334
- function _define_property4(obj, key, value) {
335
- if (key in obj) {
336
- Object.defineProperty(obj, key, {
337
- value,
338
- enumerable: true,
339
- configurable: true,
340
- writable: true
341
- });
342
- } else {
343
- obj[key] = value;
344
- }
345
- return obj;
346
- }
347
288
  var RemoteTracing = class {
289
+ _tracing;
290
+ _spanMap = /* @__PURE__ */ new Map();
348
291
  registerProcessor(processor) {
349
292
  this._tracing = processor;
350
293
  }
@@ -367,28 +310,15 @@ var RemoteTracing = class {
367
310
  }
368
311
  }
369
312
  }
370
- constructor() {
371
- _define_property4(this, "_tracing", void 0);
372
- _define_property4(this, "_spanMap", /* @__PURE__ */ new Map());
373
- }
374
313
  };
375
314
 
376
315
  // src/trace-sender.ts
377
316
  import { Stream } from "@dxos/codec-protobuf/stream";
378
- function _define_property5(obj, key, value) {
379
- if (key in obj) {
380
- Object.defineProperty(obj, key, {
381
- value,
382
- enumerable: true,
383
- configurable: true,
384
- writable: true
385
- });
386
- } else {
387
- obj[key] = value;
388
- }
389
- return obj;
390
- }
391
317
  var TraceSender = class {
318
+ _traceProcessor;
319
+ constructor(_traceProcessor) {
320
+ this._traceProcessor = _traceProcessor;
321
+ }
392
322
  streamTrace(request) {
393
323
  return new Stream(({ ctx, next }) => {
394
324
  const flushEvents = (resources, spans2, logs) => {
@@ -470,53 +400,40 @@ var TraceSender = class {
470
400
  flushEvents(null, null, null);
471
401
  });
472
402
  }
473
- constructor(_traceProcessor) {
474
- _define_property5(this, "_traceProcessor", void 0);
475
- this._traceProcessor = _traceProcessor;
476
- }
477
403
  };
478
404
 
479
405
  // src/weak-ref.ts
480
406
  var WeakRefMock = class {
481
- deref() {
482
- return void 0;
483
- }
484
407
  // eslint-disable-next-line @typescript-eslint/no-useless-constructor
485
408
  constructor(target) {
486
409
  }
410
+ deref() {
411
+ return void 0;
412
+ }
487
413
  };
488
414
  var WeakRef = globalThis.WeakRef ?? WeakRefMock;
489
415
 
490
416
  // src/trace-processor.ts
491
- function _define_property6(obj, key, value) {
492
- if (key in obj) {
493
- Object.defineProperty(obj, key, {
494
- value,
495
- enumerable: true,
496
- configurable: true,
497
- writable: true
498
- });
499
- } else {
500
- obj[key] = value;
501
- }
502
- return obj;
503
- }
504
- var _globalThis;
505
417
  var __dxlog_file3 = "/__w/dxos/dxos/packages/common/tracing/src/trace-processor.ts";
506
418
  var ResourceEntry = class {
507
- getMetric(name) {
508
- return this.data.metrics?.find((metric) => metric.name === name);
509
- }
419
+ data;
420
+ instance;
421
+ annotation;
422
+ /**
423
+ * Sometimes bundlers mangle class names: WebFile -> WebFile2.
424
+ *
425
+ * We use a heuristic to remove the suffix.
426
+ */
427
+ sanitizedClassName;
510
428
  constructor(data, instance, annotation) {
511
- _define_property6(this, "data", void 0);
512
- _define_property6(this, "instance", void 0);
513
- _define_property6(this, "annotation", void 0);
514
- _define_property6(this, "sanitizedClassName", void 0);
515
429
  this.data = data;
516
430
  this.instance = instance;
517
431
  this.annotation = annotation;
518
432
  this.sanitizedClassName = sanitizeClassName(data.className);
519
433
  }
434
+ getMetric(name) {
435
+ return this.data.metrics?.find((metric) => metric.name === name);
436
+ }
520
437
  };
521
438
  var MAX_RESOURCE_RECORDS = 2e3;
522
439
  var MAX_SPAN_RECORDS = 1e3;
@@ -525,6 +442,34 @@ var REFRESH_INTERVAL = 1e3;
525
442
  var MAX_INFO_OBJECT_DEPTH = 8;
526
443
  var IS_CLOUDFLARE_WORKERS = !!globalThis?.navigator?.userAgent?.includes("Cloudflare-Workers");
527
444
  var TraceProcessor = class {
445
+ diagnostics = new DiagnosticsManager();
446
+ diagnosticsChannel = new DiagnosticsChannel();
447
+ remoteMetrics = new RemoteMetrics();
448
+ remoteTracing = new RemoteTracing();
449
+ subscriptions = /* @__PURE__ */ new Set();
450
+ resources = /* @__PURE__ */ new Map();
451
+ resourceInstanceIndex = /* @__PURE__ */ new WeakMap();
452
+ resourceIdList = [];
453
+ spans = /* @__PURE__ */ new Map();
454
+ spanIdList = [];
455
+ logs = [];
456
+ _instanceTag = null;
457
+ constructor() {
458
+ log.addProcessor(this._logProcessor.bind(this), void 0, {
459
+ F: __dxlog_file3,
460
+ L: 103,
461
+ S: this,
462
+ C: (f, a) => f(...a)
463
+ });
464
+ if (!IS_CLOUDFLARE_WORKERS) {
465
+ const refreshInterval = setInterval(this.refresh.bind(this), REFRESH_INTERVAL);
466
+ unrefTimeout(refreshInterval);
467
+ }
468
+ if (DiagnosticsChannel.supported) {
469
+ this.diagnosticsChannel.serve(this.diagnostics);
470
+ }
471
+ this.diagnosticsChannel.unref();
472
+ }
528
473
  setInstanceTag(tag) {
529
474
  this._instanceTag = tag;
530
475
  this.diagnostics.setInstanceTag(tag);
@@ -636,10 +581,10 @@ var TraceProcessor = class {
636
581
  let _changed = false;
637
582
  const oldInfo = resource2.data.info;
638
583
  resource2.data.info = this.getResourceInfo(instance);
639
- _changed || (_changed = !areEqualShallow(oldInfo, resource2.data.info));
584
+ _changed ||= !areEqualShallow(oldInfo, resource2.data.info);
640
585
  const oldMetrics = resource2.data.metrics;
641
586
  resource2.data.metrics = this.getResourceMetrics(instance);
642
- _changed || (_changed = !areEqualShallow(oldMetrics, resource2.data.metrics));
587
+ _changed ||= !areEqualShallow(oldMetrics, resource2.data.metrics);
643
588
  this._markResourceDirty(resource2.data.id);
644
589
  }
645
590
  for (const subscription of this.subscriptions) {
@@ -693,67 +638,73 @@ var TraceProcessor = class {
693
638
  subscription.newLogs.push(log2);
694
639
  }
695
640
  }
696
- constructor() {
697
- _define_property6(this, "diagnostics", new DiagnosticsManager());
698
- _define_property6(this, "diagnosticsChannel", new DiagnosticsChannel());
699
- _define_property6(this, "remoteMetrics", new RemoteMetrics());
700
- _define_property6(this, "remoteTracing", new RemoteTracing());
701
- _define_property6(this, "subscriptions", /* @__PURE__ */ new Set());
702
- _define_property6(this, "resources", /* @__PURE__ */ new Map());
703
- _define_property6(this, "resourceInstanceIndex", /* @__PURE__ */ new WeakMap());
704
- _define_property6(this, "resourceIdList", []);
705
- _define_property6(this, "spans", /* @__PURE__ */ new Map());
706
- _define_property6(this, "spanIdList", []);
707
- _define_property6(this, "logs", []);
708
- _define_property6(this, "_instanceTag", null);
709
- _define_property6(this, "_logProcessor", (config, entry) => {
710
- switch (entry.level) {
711
- case LogLevel.ERROR:
712
- case LogLevel.WARN:
713
- case LogLevel.TRACE: {
714
- const scope = entry.meta?.S;
715
- const resource2 = this.resourceInstanceIndex.get(scope);
716
- if (!resource2) {
717
- return;
718
- }
719
- const context = getContextFromEntry(entry) ?? {};
720
- for (const key of Object.keys(context)) {
721
- context[key] = sanitizeValue(context[key], 0, this);
722
- }
723
- const entryToPush = {
724
- level: entry.level,
725
- message: entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : ""),
726
- context,
727
- timestamp: /* @__PURE__ */ new Date(),
728
- meta: {
729
- file: entry.meta?.F ?? "",
730
- line: entry.meta?.L ?? 0,
731
- resourceId: resource2.data.id
732
- }
733
- };
734
- this._pushLog(entryToPush);
735
- break;
641
+ _logProcessor = (config, entry) => {
642
+ switch (entry.level) {
643
+ case LogLevel.ERROR:
644
+ case LogLevel.WARN:
645
+ case LogLevel.TRACE: {
646
+ const scope = entry.meta?.S;
647
+ const resource2 = this.resourceInstanceIndex.get(scope);
648
+ if (!resource2) {
649
+ return;
650
+ }
651
+ const context = getContextFromEntry(entry) ?? {};
652
+ for (const key of Object.keys(context)) {
653
+ context[key] = sanitizeValue(context[key], 0, this);
736
654
  }
737
- default:
655
+ const entryToPush = {
656
+ level: entry.level,
657
+ message: entry.message ?? (entry.error ? entry.error.message ?? String(entry.error) : ""),
658
+ context,
659
+ timestamp: /* @__PURE__ */ new Date(),
660
+ meta: {
661
+ file: entry.meta?.F ?? "",
662
+ line: entry.meta?.L ?? 0,
663
+ resourceId: resource2.data.id
664
+ }
665
+ };
666
+ this._pushLog(entryToPush);
667
+ break;
738
668
  }
739
- });
740
- log.addProcessor(this._logProcessor.bind(this), void 0, {
741
- F: __dxlog_file3,
742
- L: 103,
743
- S: this,
744
- C: (f, a) => f(...a)
745
- });
746
- if (!IS_CLOUDFLARE_WORKERS) {
747
- const refreshInterval = setInterval(this.refresh.bind(this), REFRESH_INTERVAL);
748
- unrefTimeout(refreshInterval);
669
+ default:
749
670
  }
750
- if (DiagnosticsChannel.supported) {
751
- this.diagnosticsChannel.serve(this.diagnostics);
752
- }
753
- this.diagnosticsChannel.unref();
754
- }
671
+ };
755
672
  };
756
673
  var TracingSpan = class _TracingSpan {
674
+ _traceProcessor;
675
+ static nextId = 0;
676
+ id;
677
+ parentId = null;
678
+ methodName;
679
+ resourceId = null;
680
+ op;
681
+ attributes;
682
+ startTs;
683
+ endTs = null;
684
+ error = null;
685
+ _showInBrowserTimeline;
686
+ _ctx = null;
687
+ constructor(_traceProcessor, params) {
688
+ this._traceProcessor = _traceProcessor;
689
+ this.id = _TracingSpan.nextId++;
690
+ this.methodName = params.methodName;
691
+ this.resourceId = _traceProcessor.getResourceId(params.instance);
692
+ this.startTs = performance.now();
693
+ this._showInBrowserTimeline = params.showInBrowserTimeline;
694
+ this.op = params.op;
695
+ this.attributes = params.attributes ?? {};
696
+ if (params.parentCtx) {
697
+ this._ctx = params.parentCtx.derive({
698
+ attributes: {
699
+ [TRACE_SPAN_ATTRIBUTE]: this.id
700
+ }
701
+ });
702
+ const parentId = params.parentCtx.getAttribute(TRACE_SPAN_ATTRIBUTE);
703
+ if (typeof parentId === "number") {
704
+ this.parentId = parentId;
705
+ }
706
+ }
707
+ }
757
708
  get name() {
758
709
  const resource2 = this._traceProcessor.resources.get(this.resourceId);
759
710
  return resource2 ? `${resource2.sanitizedClassName}#${resource2.data.instanceId}.${this.methodName}` : this.methodName;
@@ -795,46 +746,7 @@ var TracingSpan = class _TracingSpan {
795
746
  });
796
747
  }
797
748
  }
798
- constructor(_traceProcessor, params) {
799
- _define_property6(this, "_traceProcessor", void 0);
800
- _define_property6(this, "id", void 0);
801
- _define_property6(this, "parentId", void 0);
802
- _define_property6(this, "methodName", void 0);
803
- _define_property6(this, "resourceId", void 0);
804
- _define_property6(this, "op", void 0);
805
- _define_property6(this, "attributes", void 0);
806
- _define_property6(this, "startTs", void 0);
807
- _define_property6(this, "endTs", void 0);
808
- _define_property6(this, "error", void 0);
809
- _define_property6(this, "_showInBrowserTimeline", void 0);
810
- _define_property6(this, "_ctx", void 0);
811
- this._traceProcessor = _traceProcessor;
812
- this.parentId = null;
813
- this.resourceId = null;
814
- this.endTs = null;
815
- this.error = null;
816
- this._ctx = null;
817
- this.id = _TracingSpan.nextId++;
818
- this.methodName = params.methodName;
819
- this.resourceId = _traceProcessor.getResourceId(params.instance);
820
- this.startTs = performance.now();
821
- this._showInBrowserTimeline = params.showInBrowserTimeline;
822
- this.op = params.op;
823
- this.attributes = params.attributes ?? {};
824
- if (params.parentCtx) {
825
- this._ctx = params.parentCtx.derive({
826
- attributes: {
827
- [TRACE_SPAN_ATTRIBUTE]: this.id
828
- }
829
- });
830
- const parentId = params.parentCtx.getAttribute(TRACE_SPAN_ATTRIBUTE);
831
- if (typeof parentId === "number") {
832
- this.parentId = parentId;
833
- }
834
- }
835
- }
836
749
  };
837
- _define_property6(TracingSpan, "nextId", 0);
838
750
  var serializeError = (err) => {
839
751
  if (err instanceof Error) {
840
752
  return {
@@ -846,7 +758,7 @@ var serializeError = (err) => {
846
758
  message: String(err)
847
759
  };
848
760
  };
849
- var TRACE_PROCESSOR = (_globalThis = globalThis).TRACE_PROCESSOR ?? (_globalThis.TRACE_PROCESSOR = new TraceProcessor());
761
+ var TRACE_PROCESSOR = globalThis.TRACE_PROCESSOR ??= new TraceProcessor();
850
762
  var sanitizeValue = (value, depth, traceProcessor) => {
851
763
  switch (typeof value) {
852
764
  case "string":
@@ -919,18 +831,15 @@ var isMapLike = (value) => value instanceof Map || typeof value === "object" &&
919
831
 
920
832
  // src/api.ts
921
833
  var resource = (options) => (constructor) => {
922
- const klass = /* @__PURE__ */ (() => {
923
- class _class extends constructor {
924
- constructor(...rest) {
925
- super(...rest);
926
- TRACE_PROCESSOR.createTraceResource({
927
- constructor,
928
- annotation: options?.annotation,
929
- instance: this
930
- });
931
- }
834
+ const klass = /* @__PURE__ */ (() => class extends constructor {
835
+ constructor(...rest) {
836
+ super(...rest);
837
+ TRACE_PROCESSOR.createTraceResource({
838
+ constructor,
839
+ annotation: options?.annotation,
840
+ instance: this
841
+ });
932
842
  }
933
- return _class;
934
843
  })();
935
844
  Object.defineProperty(klass, "name", {
936
845
  value: constructor.name
@@ -1009,20 +918,12 @@ var trace = {
1009
918
  };
1010
919
 
1011
920
  // src/metrics/base.ts
1012
- function _define_property7(obj, key, value) {
1013
- if (key in obj) {
1014
- Object.defineProperty(obj, key, {
1015
- value,
1016
- enumerable: true,
1017
- configurable: true,
1018
- writable: true
1019
- });
1020
- } else {
1021
- obj[key] = value;
1022
- }
1023
- return obj;
1024
- }
1025
921
  var BaseCounter = class {
922
+ /**
923
+ * @internal
924
+ */
925
+ _instance;
926
+ name;
1026
927
  /**
1027
928
  * @internal
1028
929
  */
@@ -1032,27 +933,16 @@ var BaseCounter = class {
1032
933
  }
1033
934
  _tick(time) {
1034
935
  }
1035
- constructor() {
1036
- _define_property7(this, "_instance", void 0);
1037
- _define_property7(this, "name", void 0);
1038
- }
1039
936
  };
1040
937
 
1041
938
  // src/metrics/unary-counter.ts
1042
- function _define_property8(obj, key, value) {
1043
- if (key in obj) {
1044
- Object.defineProperty(obj, key, {
1045
- value,
1046
- enumerable: true,
1047
- configurable: true,
1048
- writable: true
1049
- });
1050
- } else {
1051
- obj[key] = value;
1052
- }
1053
- return obj;
1054
- }
1055
939
  var UnaryCounter = class extends BaseCounter {
940
+ value = 0;
941
+ units;
942
+ constructor({ units } = {}) {
943
+ super();
944
+ this.units = units;
945
+ }
1056
946
  inc(by = 1) {
1057
947
  this.value += by;
1058
948
  }
@@ -1065,28 +955,19 @@ var UnaryCounter = class extends BaseCounter {
1065
955
  }
1066
956
  };
1067
957
  }
1068
- constructor({ units } = {}) {
1069
- super(), _define_property8(this, "value", 0), _define_property8(this, "units", void 0);
1070
- this.units = units;
1071
- }
1072
958
  };
1073
959
 
1074
960
  // src/metrics/time-series-counter.ts
1075
- function _define_property9(obj, key, value) {
1076
- if (key in obj) {
1077
- Object.defineProperty(obj, key, {
1078
- value,
1079
- enumerable: true,
1080
- configurable: true,
1081
- writable: true
1082
- });
1083
- } else {
1084
- obj[key] = value;
1085
- }
1086
- return obj;
1087
- }
1088
961
  var MAX_BUCKETS = 60;
1089
962
  var TimeSeriesCounter = class extends BaseCounter {
963
+ _currentValue = 0;
964
+ _totalValue = 0;
965
+ _buckets = [];
966
+ units;
967
+ constructor({ units } = {}) {
968
+ super();
969
+ this.units = units;
970
+ }
1090
971
  inc(by = 1) {
1091
972
  this._currentValue += by;
1092
973
  this._totalValue += by;
@@ -1115,28 +996,15 @@ var TimeSeriesCounter = class extends BaseCounter {
1115
996
  }
1116
997
  };
1117
998
  }
1118
- constructor({ units } = {}) {
1119
- super(), _define_property9(this, "_currentValue", 0), _define_property9(this, "_totalValue", 0), _define_property9(this, "_buckets", []), _define_property9(this, "units", void 0);
1120
- this.units = units;
1121
- }
1122
999
  };
1123
1000
 
1124
1001
  // src/metrics/time-usage-counter.ts
1125
- function _define_property10(obj, key, value) {
1126
- if (key in obj) {
1127
- Object.defineProperty(obj, key, {
1128
- value,
1129
- enumerable: true,
1130
- configurable: true,
1131
- writable: true
1132
- });
1133
- } else {
1134
- obj[key] = value;
1135
- }
1136
- return obj;
1137
- }
1138
1002
  var MAX_BUCKETS2 = 60;
1139
1003
  var TimeUsageCounter = class extends BaseCounter {
1004
+ _currentValue = 0;
1005
+ _totalValue = 0;
1006
+ _buckets = [];
1007
+ _lastTickTime = performance.now();
1140
1008
  record(time) {
1141
1009
  this._currentValue += time;
1142
1010
  this._totalValue += time;
@@ -1177,26 +1045,16 @@ var TimeUsageCounter = class extends BaseCounter {
1177
1045
  }
1178
1046
  };
1179
1047
  }
1180
- constructor(...args) {
1181
- super(...args), _define_property10(this, "_currentValue", 0), _define_property10(this, "_totalValue", 0), _define_property10(this, "_buckets", []), _define_property10(this, "_lastTickTime", performance.now());
1182
- }
1183
1048
  };
1184
1049
 
1185
1050
  // src/metrics/map-counter.ts
1186
- function _define_property11(obj, key, value) {
1187
- if (key in obj) {
1188
- Object.defineProperty(obj, key, {
1189
- value,
1190
- enumerable: true,
1191
- configurable: true,
1192
- writable: true
1193
- });
1194
- } else {
1195
- obj[key] = value;
1196
- }
1197
- return obj;
1198
- }
1199
1051
  var MapCounter = class extends BaseCounter {
1052
+ values = /* @__PURE__ */ new Map();
1053
+ units;
1054
+ constructor({ units } = {}) {
1055
+ super();
1056
+ this.units = units;
1057
+ }
1200
1058
  inc(key, by = 1) {
1201
1059
  const prev = this.values.get(key) ?? 0;
1202
1060
  this.values.set(key, prev + by);
@@ -1213,27 +1071,14 @@ var MapCounter = class extends BaseCounter {
1213
1071
  }
1214
1072
  };
1215
1073
  }
1216
- constructor({ units } = {}) {
1217
- super(), _define_property11(this, "values", /* @__PURE__ */ new Map()), _define_property11(this, "units", void 0);
1218
- this.units = units;
1219
- }
1220
1074
  };
1221
1075
 
1222
1076
  // src/metrics/custom-counter.ts
1223
- function _define_property12(obj, key, value) {
1224
- if (key in obj) {
1225
- Object.defineProperty(obj, key, {
1226
- value,
1227
- enumerable: true,
1228
- configurable: true,
1229
- writable: true
1230
- });
1231
- } else {
1232
- obj[key] = value;
1233
- }
1234
- return obj;
1235
- }
1236
1077
  var CustomCounter = class extends BaseCounter {
1078
+ _getData;
1079
+ constructor(_getData) {
1080
+ super(), this._getData = _getData;
1081
+ }
1237
1082
  getData() {
1238
1083
  return {
1239
1084
  name: this.name,
@@ -1242,9 +1087,6 @@ var CustomCounter = class extends BaseCounter {
1242
1087
  }
1243
1088
  };
1244
1089
  }
1245
- constructor(_getData) {
1246
- super(), _define_property12(this, "_getData", void 0), this._getData = _getData;
1247
- }
1248
1090
  };
1249
1091
 
1250
1092
  // src/index.ts