@dxos/tracing 0.8.4-main.3f58842 → 0.8.4-main.5ad4a44

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