@grest-ts/metrics 0.0.5 → 0.0.7
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.
- package/LICENSE +21 -21
- package/README.md +45 -40
- package/dist/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/GGMetric.ts +124 -124
- package/src/GGMetricKey.ts +38 -38
- package/src/GGMetrics.ts +34 -34
- package/src/GGMetricsDefineStorage.ts +8 -8
- package/src/GGMetricsLoader.ts +21 -21
- package/src/GGMetricsStore.ts +26 -26
- package/src/exporters/GGJsonMetricsExporter.ts +176 -176
- package/src/exporters/GGMetricsExporter.ts +88 -88
- package/src/exporters/GGNestedMetricsExporter.ts +335 -335
- package/src/index-browser.ts +16 -16
- package/src/index-node.ts +21 -21
- package/src/keys/GGCounterKey.ts +29 -29
- package/src/keys/GGGaugeKey.ts +37 -37
- package/src/keys/GGHistogramKey.ts +37 -37
- package/src/keys/GGLazyGaugeKey.ts +36 -36
- package/src/metric/GGCounter.ts +19 -19
- package/src/metric/GGGauge.ts +38 -38
- package/src/metric/GGHistogram.ts +68 -68
- package/src/metric/GGLazyGauge.ts +31 -31
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {GGMetric} from "../GGMetric.js";
|
|
2
|
-
import type {GGLazyGaugeKey} from "../keys/GGLazyGaugeKey";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A gauge that computes its value lazily by calling a function.
|
|
6
|
-
* Perfect for "current state" metrics like memory usage, active handles, etc.
|
|
7
|
-
* Does not support labels - use regular GGGauge if you need labels.
|
|
8
|
-
*/
|
|
9
|
-
export class GGLazyGauge extends GGMetric<{}, number, GGLazyGaugeKey> {
|
|
10
|
-
|
|
11
|
-
protected getDefaultValue(): number {
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Get the current value by calling the getValue function.
|
|
17
|
-
*/
|
|
18
|
-
public getValue(): number {
|
|
19
|
-
return this.key.options.getValue();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Returns a map with single entry (empty key -> current value).
|
|
24
|
-
* Compatible with exporter iteration pattern.
|
|
25
|
-
*/
|
|
26
|
-
public getValues(): Map<string, number> {
|
|
27
|
-
const map = new Map<string, number>();
|
|
28
|
-
map.set('', this.getValue());
|
|
29
|
-
return map;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
import {GGMetric} from "../GGMetric.js";
|
|
2
|
+
import type {GGLazyGaugeKey} from "../keys/GGLazyGaugeKey";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A gauge that computes its value lazily by calling a function.
|
|
6
|
+
* Perfect for "current state" metrics like memory usage, active handles, etc.
|
|
7
|
+
* Does not support labels - use regular GGGauge if you need labels.
|
|
8
|
+
*/
|
|
9
|
+
export class GGLazyGauge extends GGMetric<{}, number, GGLazyGaugeKey> {
|
|
10
|
+
|
|
11
|
+
protected getDefaultValue(): number {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get the current value by calling the getValue function.
|
|
17
|
+
*/
|
|
18
|
+
public getValue(): number {
|
|
19
|
+
return this.key.options.getValue();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns a map with single entry (empty key -> current value).
|
|
24
|
+
* Compatible with exporter iteration pattern.
|
|
25
|
+
*/
|
|
26
|
+
public getValues(): Map<string, number> {
|
|
27
|
+
const map = new Map<string, number>();
|
|
28
|
+
map.set('', this.getValue());
|
|
29
|
+
return map;
|
|
30
|
+
}
|
|
31
|
+
}
|