@dxos/tracing 0.8.1 → 0.8.2-main.10c050d

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.
@@ -15,7 +15,7 @@ export abstract class BaseCounter {
15
15
  /**
16
16
  * @internal
17
17
  */
18
- _assign(instance: any, name: string) {
18
+ _assign(instance: any, name: string): void {
19
19
  this._instance = instance;
20
20
  this.name = name;
21
21
  }
@@ -15,7 +15,7 @@ export class MapCounter extends BaseCounter {
15
15
  this.units = units;
16
16
  }
17
17
 
18
- inc(key: string, by = 1) {
18
+ inc(key: string, by = 1): void {
19
19
  const prev = this.values.get(key) ?? 0;
20
20
  this.values.set(key, prev + by);
21
21
  }
@@ -19,7 +19,7 @@ export class TimeSeriesCounter extends BaseCounter {
19
19
  this.units = units;
20
20
  }
21
21
 
22
- inc(by = 1) {
22
+ inc(by = 1): void {
23
23
  this._currentValue += by;
24
24
  this._totalValue += by;
25
25
  }
@@ -15,7 +15,7 @@ export class TimeUsageCounter extends BaseCounter {
15
15
 
16
16
  private _lastTickTime = performance.now();
17
17
 
18
- record(time: number) {
18
+ record(time: number): void {
19
19
  this._currentValue += time;
20
20
  this._totalValue += time;
21
21
  }
@@ -15,7 +15,7 @@ export class UnaryCounter extends BaseCounter {
15
15
  this.units = units;
16
16
  }
17
17
 
18
- inc(by = 1) {
18
+ inc(by = 1): void {
19
19
  this.value += by;
20
20
  }
21
21
 
@@ -35,23 +35,23 @@ interface MetricsMethods {
35
35
  export class RemoteMetrics implements MetricsMethods {
36
36
  private _metrics = new Set<MetricsMethods>();
37
37
 
38
- registerProcessor(processor: MetricsMethods) {
38
+ registerProcessor(processor: MetricsMethods): void {
39
39
  this._metrics.add(processor);
40
40
  }
41
41
 
42
- increment(name: string, value?: number, data?: MetricData) {
42
+ increment(name: string, value?: number, data?: MetricData): void[] {
43
43
  return Array.from(this._metrics.values()).map((processor) => processor.increment(name, value, data));
44
44
  }
45
45
 
46
- distribution(name: string, value: number, data?: MetricData) {
46
+ distribution(name: string, value: number, data?: MetricData): void[] {
47
47
  return Array.from(this._metrics.values()).map((processor) => processor.distribution(name, value, data));
48
48
  }
49
49
 
50
- set(name: string, value: number | string, data?: MetricData) {
50
+ set(name: string, value: number | string, data?: MetricData): void[] {
51
51
  return Array.from(this._metrics.values()).map((processor) => processor.set(name, value, data));
52
52
  }
53
53
 
54
- gauge(name: string, value: number, data?: MetricData) {
54
+ gauge(name: string, value: number, data?: MetricData): void[] {
55
55
  return Array.from(this._metrics.values()).map((processor) => processor.gauge(name, value, data));
56
56
  }
57
57
  }
@@ -26,11 +26,11 @@ export class RemoteTracing {
26
26
  private _tracing: TracingMethods | undefined;
27
27
  private _spanMap = new Map<TracingSpan, RemoteSpan>();
28
28
 
29
- registerProcessor(processor: TracingMethods) {
29
+ registerProcessor(processor: TracingMethods): void {
30
30
  this._tracing = processor;
31
31
  }
32
32
 
33
- flushSpan(span: TracingSpan) {
33
+ flushSpan(span: TracingSpan): void {
34
34
  if (!this._tracing) {
35
35
  return;
36
36
  }
@@ -113,7 +113,7 @@ export class TraceProcessor {
113
113
  this.diagnosticsChannel.unref();
114
114
  }
115
115
 
116
- setInstanceTag(tag: string) {
116
+ setInstanceTag(tag: string): void {
117
117
  this._instanceTag = tag;
118
118
  this.diagnostics.setInstanceTag(tag);
119
119
  }
@@ -122,7 +122,7 @@ export class TraceProcessor {
122
122
  * @internal
123
123
  */
124
124
  // TODO(burdon): Comment.
125
- createTraceResource(params: TraceResourceConstructorParams) {
125
+ createTraceResource(params: TraceResourceConstructorParams): void {
126
126
  const id = this.resources.size;
127
127
 
128
128
  // Init metrics counters.
@@ -154,7 +154,7 @@ export class TraceProcessor {
154
154
  this._markResourceDirty(id);
155
155
  }
156
156
 
157
- createTraceSender() {
157
+ createTraceSender(): TraceSender {
158
158
  return new TraceSender(this);
159
159
  }
160
160
 
@@ -165,7 +165,7 @@ export class TraceProcessor {
165
165
  }
166
166
 
167
167
  // TODO(burdon): Not implemented.
168
- addLink(parent: any, child: any, opts: AddLinkOptions) {}
168
+ addLink(parent: any, child: any, opts: AddLinkOptions): void {}
169
169
 
170
170
  //
171
171
  // Getters
@@ -236,7 +236,7 @@ export class TraceProcessor {
236
236
  return [...this.resources.values()].filter((res) => res.annotation === annotation);
237
237
  }
238
238
 
239
- refresh() {
239
+ refresh(): void {
240
240
  for (const resource of this.resources.values()) {
241
241
  const instance = resource.instance.deref();
242
242
  if (!instance) {
@@ -278,7 +278,7 @@ export class TraceProcessor {
278
278
  /**
279
279
  * @internal
280
280
  */
281
- _flushSpan(runtimeSpan: TracingSpan) {
281
+ _flushSpan(runtimeSpan: TracingSpan): void {
282
282
  const span = runtimeSpan.serialize();
283
283
  this.spans.set(span.id, span);
284
284
  this.spanIdList.push(span.id);
@@ -289,19 +289,19 @@ export class TraceProcessor {
289
289
  this.remoteTracing.flushSpan(runtimeSpan);
290
290
  }
291
291
 
292
- private _markResourceDirty(id: number) {
292
+ private _markResourceDirty(id: number): void {
293
293
  for (const subscription of this.subscriptions) {
294
294
  subscription.dirtyResources.add(id);
295
295
  }
296
296
  }
297
297
 
298
- private _markSpanDirty(id: number) {
298
+ private _markSpanDirty(id: number): void {
299
299
  for (const subscription of this.subscriptions) {
300
300
  subscription.dirtySpans.add(id);
301
301
  }
302
302
  }
303
303
 
304
- private _clearResources() {
304
+ private _clearResources(): void {
305
305
  // TODO(dmaretskyi): Use FinalizationRegistry to delete finalized resources first.
306
306
  while (this.resourceIdList.length > MAX_RESOURCE_RECORDS) {
307
307
  const id = this.resourceIdList.shift()!;
@@ -309,14 +309,14 @@ export class TraceProcessor {
309
309
  }
310
310
  }
311
311
 
312
- private _clearSpans() {
312
+ private _clearSpans(): void {
313
313
  while (this.spanIdList.length > MAX_SPAN_RECORDS) {
314
314
  const id = this.spanIdList.shift()!;
315
315
  this.spans.delete(id);
316
316
  }
317
317
  }
318
318
 
319
- private _pushLog(log: LogEntry) {
319
+ private _pushLog(log: LogEntry): void {
320
320
  this.logs.push(log);
321
321
  if (this.logs.length > MAX_LOG_RECORDS) {
322
322
  this.logs.shift();
@@ -413,7 +413,7 @@ export class TracingSpan {
413
413
  return this._ctx;
414
414
  }
415
415
 
416
- markSuccess() {
416
+ markSuccess(): void {
417
417
  this.endTs = performance.now();
418
418
  this._traceProcessor._flushSpan(this);
419
419
 
@@ -422,7 +422,7 @@ export class TracingSpan {
422
422
  }
423
423
  }
424
424
 
425
- markError(err: unknown) {
425
+ markError(err: unknown): void {
426
426
  this.endTs = performance.now();
427
427
  this.error = serializeError(err);
428
428
  this._traceProcessor._flushSpan(this);
@@ -444,7 +444,7 @@ export class TracingSpan {
444
444
  };
445
445
  }
446
446
 
447
- private _markInBrowserTimeline() {
447
+ private _markInBrowserTimeline(): void {
448
448
  if (typeof globalThis?.performance?.measure === 'function') {
449
449
  performance.measure(this.name, { start: this.startTs, end: this.endTs! });
450
450
  }
@@ -24,7 +24,7 @@ class FeedStore {
24
24
  }
25
25
 
26
26
  @trace.span()
27
- async openFeed(ctx: Context) {
27
+ async openFeed(ctx: Context): Promise<Feed> {
28
28
  const feed = new Feed();
29
29
  feed.key = Math.random().toString(36).substring(2, 15);
30
30
  this._feeds.set(feed.key, feed);
@@ -41,10 +41,10 @@ class Feed {
41
41
  key!: string;
42
42
 
43
43
  @trace.span()
44
- async open(ctx: Context) {}
44
+ async open(ctx: Context): Promise<void> {}
45
45
 
46
46
  @trace.span()
47
- async close() {
47
+ async close(): Promise<void> {
48
48
  throw new Error('Not implemented');
49
49
  }
50
50
  }