Skip to content

Commit 8a286cc

Browse files
committed
lib: sub-class metric types from Metric
1 parent 758e26a commit 8a286cc

5 files changed

Lines changed: 84 additions & 167 deletions

File tree

doc/api/metrics.md

Lines changed: 9 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -321,30 +321,20 @@ import { gauge } from 'node:metrics';
321321

322322
const memoryUsage = gauge('memory.usage', { service: 'web' });
323323

324-
memoryUsage.metric.report(85); // Reports a value of 85
325-
memoryUsage.metric.report(90, { threshold: 'warning' }); // Reports 90 with metadata
324+
memoryUsage.report(85); // Reports a value of 85
325+
memoryUsage.report(90, { threshold: 'warning' }); // Reports 90 with metadata
326326
```
327327

328328
### Class: `Counter`
329329

330-
* Extends: {metrics.Gauge}
330+
* Extends: {metrics.Metric}
331331

332332
<!-- YAML
333333
added: REPLACEME
334334
-->
335335

336336
A metric that only increases or decreases.
337337

338-
#### `counter.metric`
339-
340-
<!-- YAML
341-
added: REPLACEME
342-
-->
343-
344-
* {metrics.Metric}
345-
346-
The underlying metric instance used for reporting.
347-
348338
#### `counter.value`
349339

350340
<!-- YAML
@@ -401,21 +391,13 @@ errorCount.decrement({ errorType: 'timeout' }); // Decrement by 1 with metada
401391

402392
### Class: `Gauge`
403393

404-
<!-- YAML
405-
added: REPLACEME
406-
-->
407-
408-
A metric representing a single value that can go up or down.
409-
410-
#### `gauge.metric`
394+
* Extends: {metrics.Metric}
411395

412396
<!-- YAML
413397
added: REPLACEME
414398
-->
415399

416-
* {metrics.Metric}
417-
418-
The underlying metric instance used for reporting.
400+
A metric representing a single value that can go up or down.
419401

420402
#### `gauge.value`
421403

@@ -451,24 +433,14 @@ memory.reset(1024, { source: 'system' }); // Set to 1024 with metadata
451433

452434
### Class: `Timer`
453435

454-
* Extends: {metrics.Gauge}
436+
* Extends: {metrics.Metric}
455437

456438
<!-- YAML
457439
added: REPLACEME
458440
-->
459441

460442
A metric for measuring durations.
461443

462-
#### `timer.metric`
463-
464-
<!-- YAML
465-
added: REPLACEME
466-
-->
467-
468-
* {metrics.Metric}
469-
470-
The underlying metric instance used for reporting.
471-
472444
#### `timer.start`
473445

474446
<!-- YAML
@@ -546,21 +518,13 @@ const dbQueryTimer = timer('db.query.duration');
546518

547519
### Class: `TimerFactory`
548520

549-
<!-- YAML
550-
added: REPLACEME
551-
-->
552-
553-
A factory for creating timer instances.
554-
555-
#### `timer.metric`
521+
* Extends: {metrics.Metric}
556522

557523
<!-- YAML
558524
added: REPLACEME
559525
-->
560526

561-
* {metrics.Metric}
562-
563-
The underlying metric instance used for reporting.
527+
A factory for creating timer instances.
564528

565529
#### `timerFactory.create([meta])`
566530

@@ -583,24 +547,14 @@ const t = dbQueryTimer.create({ query: 'SELECT * FROM users' });
583547

584548
### Class: `PullGauge`
585549

586-
* Extends: {metrics.Gauge}
550+
* Extends: {metrics.Metric}
587551

588552
<!-- YAML
589553
added: REPLACEME
590554
-->
591555

592556
A gauge that samples values on-demand when the `sample()` method is called.
593557

594-
#### `pullGauge.metric`
595-
596-
<!-- YAML
597-
added: REPLACEME
598-
-->
599-
600-
* {metrics.Metric}
601-
602-
The underlying metric instance used for reporting.
603-
604558
#### `pullGauge.sample([meta])`
605559

606560
<!-- YAML

0 commit comments

Comments
 (0)