@grest-ts/metrics 0.0.5
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 -0
- package/README.md +40 -0
- package/dist/src/GGMetric.d.ts +60 -0
- package/dist/src/GGMetric.d.ts.map +1 -0
- package/dist/src/GGMetric.js +64 -0
- package/dist/src/GGMetric.js.map +1 -0
- package/dist/src/GGMetricKey.d.ts +13 -0
- package/dist/src/GGMetricKey.d.ts.map +1 -0
- package/dist/src/GGMetricKey.js +29 -0
- package/dist/src/GGMetricKey.js.map +1 -0
- package/dist/src/GGMetrics.d.ts +10 -0
- package/dist/src/GGMetrics.d.ts.map +1 -0
- package/dist/src/GGMetrics.js +29 -0
- package/dist/src/GGMetrics.js.map +1 -0
- package/dist/src/GGMetricsDefineStorage.d.ts +4 -0
- package/dist/src/GGMetricsDefineStorage.d.ts.map +1 -0
- package/dist/src/GGMetricsDefineStorage.js +7 -0
- package/dist/src/GGMetricsDefineStorage.js.map +1 -0
- package/dist/src/GGMetricsLoader.d.ts +8 -0
- package/dist/src/GGMetricsLoader.d.ts.map +1 -0
- package/dist/src/GGMetricsLoader.js +17 -0
- package/dist/src/GGMetricsLoader.js.map +1 -0
- package/dist/src/GGMetricsStore.d.ts +9 -0
- package/dist/src/GGMetricsStore.d.ts.map +1 -0
- package/dist/src/GGMetricsStore.js +20 -0
- package/dist/src/GGMetricsStore.js.map +1 -0
- package/dist/src/exporters/GGJsonMetricsExporter.d.ts +41 -0
- package/dist/src/exporters/GGJsonMetricsExporter.d.ts.map +1 -0
- package/dist/src/exporters/GGJsonMetricsExporter.js +129 -0
- package/dist/src/exporters/GGJsonMetricsExporter.js.map +1 -0
- package/dist/src/exporters/GGMetricsExporter.d.ts +41 -0
- package/dist/src/exporters/GGMetricsExporter.d.ts.map +1 -0
- package/dist/src/exporters/GGMetricsExporter.js +70 -0
- package/dist/src/exporters/GGMetricsExporter.js.map +1 -0
- package/dist/src/exporters/GGNestedMetricsExporter.d.ts +33 -0
- package/dist/src/exporters/GGNestedMetricsExporter.d.ts.map +1 -0
- package/dist/src/exporters/GGNestedMetricsExporter.js +275 -0
- package/dist/src/exporters/GGNestedMetricsExporter.js.map +1 -0
- package/dist/src/index-browser.d.ts +17 -0
- package/dist/src/index-browser.d.ts.map +1 -0
- package/dist/src/index-browser.js +17 -0
- package/dist/src/index-browser.js.map +1 -0
- package/dist/src/index-node.d.ts +17 -0
- package/dist/src/index-node.d.ts.map +1 -0
- package/dist/src/index-node.js +20 -0
- package/dist/src/index-node.js.map +1 -0
- package/dist/src/keys/GGCounterKey.d.ts +11 -0
- package/dist/src/keys/GGCounterKey.d.ts.map +1 -0
- package/dist/src/keys/GGCounterKey.js +21 -0
- package/dist/src/keys/GGCounterKey.js.map +1 -0
- package/dist/src/keys/GGGaugeKey.d.ts +13 -0
- package/dist/src/keys/GGGaugeKey.d.ts.map +1 -0
- package/dist/src/keys/GGGaugeKey.js +27 -0
- package/dist/src/keys/GGGaugeKey.js.map +1 -0
- package/dist/src/keys/GGHistogramKey.d.ts +13 -0
- package/dist/src/keys/GGHistogramKey.d.ts.map +1 -0
- package/dist/src/keys/GGHistogramKey.js +27 -0
- package/dist/src/keys/GGHistogramKey.js.map +1 -0
- package/dist/src/keys/GGLazyGaugeKey.d.ts +21 -0
- package/dist/src/keys/GGLazyGaugeKey.d.ts.map +1 -0
- package/dist/src/keys/GGLazyGaugeKey.js +25 -0
- package/dist/src/keys/GGLazyGaugeKey.js.map +1 -0
- package/dist/src/metric/GGCounter.d.ts +7 -0
- package/dist/src/metric/GGCounter.d.ts.map +1 -0
- package/dist/src/metric/GGCounter.js +14 -0
- package/dist/src/metric/GGCounter.js.map +1 -0
- package/dist/src/metric/GGGauge.d.ts +9 -0
- package/dist/src/metric/GGGauge.d.ts.map +1 -0
- package/dist/src/metric/GGGauge.js +31 -0
- package/dist/src/metric/GGGauge.js.map +1 -0
- package/dist/src/metric/GGHistogram.d.ts +27 -0
- package/dist/src/metric/GGHistogram.d.ts.map +1 -0
- package/dist/src/metric/GGHistogram.js +41 -0
- package/dist/src/metric/GGHistogram.js.map +1 -0
- package/dist/src/metric/GGLazyGauge.d.ts +20 -0
- package/dist/src/metric/GGLazyGauge.d.ts.map +1 -0
- package/dist/src/metric/GGLazyGauge.js +27 -0
- package/dist/src/metric/GGLazyGauge.js.map +1 -0
- package/dist/src/tsconfig.json +16 -0
- package/dist/testkit/GGMetricsCommands.d.ts +18 -0
- package/dist/testkit/GGMetricsCommands.d.ts.map +1 -0
- package/dist/testkit/GGMetricsCommands.js +77 -0
- package/dist/testkit/GGMetricsCommands.js.map +1 -0
- package/dist/testkit/GGMetricsInterceptor.d.ts +34 -0
- package/dist/testkit/GGMetricsInterceptor.d.ts.map +1 -0
- package/dist/testkit/GGMetricsInterceptor.js +202 -0
- package/dist/testkit/GGMetricsInterceptor.js.map +1 -0
- package/dist/testkit/GGMetricsWith.d.ts +22 -0
- package/dist/testkit/GGMetricsWith.d.ts.map +1 -0
- package/dist/testkit/GGMetricsWith.js +61 -0
- package/dist/testkit/GGMetricsWith.js.map +1 -0
- package/dist/testkit/GGTestMetricsExporter.d.ts +40 -0
- package/dist/testkit/GGTestMetricsExporter.d.ts.map +1 -0
- package/dist/testkit/GGTestMetricsExporter.js +119 -0
- package/dist/testkit/GGTestMetricsExporter.js.map +1 -0
- package/dist/testkit/GGTestSelectorMetrics.d.ts +15 -0
- package/dist/testkit/GGTestSelectorMetrics.d.ts.map +1 -0
- package/dist/testkit/GGTestSelectorMetrics.js +16 -0
- package/dist/testkit/GGTestSelectorMetrics.js.map +1 -0
- package/dist/testkit/index-testkit.d.ts +6 -0
- package/dist/testkit/index-testkit.d.ts.map +1 -0
- package/dist/testkit/index-testkit.js +6 -0
- package/dist/testkit/index-testkit.js.map +1 -0
- package/dist/tsconfig.publish.tsbuildinfo +1 -0
- package/package.json +58 -0
- package/src/GGMetric.ts +124 -0
- package/src/GGMetricKey.ts +38 -0
- package/src/GGMetrics.ts +34 -0
- package/src/GGMetricsDefineStorage.ts +8 -0
- package/src/GGMetricsLoader.ts +21 -0
- package/src/GGMetricsStore.ts +26 -0
- package/src/exporters/GGJsonMetricsExporter.ts +176 -0
- package/src/exporters/GGMetricsExporter.ts +88 -0
- package/src/exporters/GGNestedMetricsExporter.ts +335 -0
- package/src/index-browser.ts +16 -0
- package/src/index-node.ts +21 -0
- package/src/keys/GGCounterKey.ts +29 -0
- package/src/keys/GGGaugeKey.ts +37 -0
- package/src/keys/GGHistogramKey.ts +37 -0
- package/src/keys/GGLazyGaugeKey.ts +36 -0
- package/src/metric/GGCounter.ts +19 -0
- package/src/metric/GGGauge.ts +38 -0
- package/src/metric/GGHistogram.ts +68 -0
- package/src/metric/GGLazyGauge.ts +31 -0
- package/src/tsconfig.json +16 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { GG_METRICS } from "../GGMetricsLoader.js";
|
|
2
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for metrics exporters.
|
|
5
|
+
* Handles config parsing, metric filtering, and key discovery.
|
|
6
|
+
*/
|
|
7
|
+
export class GGMetricsExporter {
|
|
8
|
+
store;
|
|
9
|
+
includeKeys;
|
|
10
|
+
excludeKeys;
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
this.store = config.store ?? GG_METRICS.get();
|
|
13
|
+
this.includeKeys = config.include ? this.discoverKeys(config.include) : undefined;
|
|
14
|
+
this.excludeKeys = config.exclude ? this.discoverKeys(config.exclude) : undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Discover all GGMetricKey instances from an array of objects.
|
|
18
|
+
* Objects can be individual keys, or nested structures containing keys.
|
|
19
|
+
*/
|
|
20
|
+
discoverKeys(objects) {
|
|
21
|
+
const keys = new Set();
|
|
22
|
+
for (const obj of objects) {
|
|
23
|
+
this.discoverKeysRecursive(obj, keys);
|
|
24
|
+
}
|
|
25
|
+
return keys;
|
|
26
|
+
}
|
|
27
|
+
discoverKeysRecursive(obj, keys) {
|
|
28
|
+
if (obj instanceof GGMetricKey) {
|
|
29
|
+
keys.add(obj);
|
|
30
|
+
}
|
|
31
|
+
else if (obj && typeof obj === 'object') {
|
|
32
|
+
for (const value of Object.values(obj)) {
|
|
33
|
+
this.discoverKeysRecursive(value, keys);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a metric should be included in the export.
|
|
39
|
+
* Exclude takes precedence over include.
|
|
40
|
+
*/
|
|
41
|
+
shouldIncludeMetric(metric) {
|
|
42
|
+
// Exclude takes precedence
|
|
43
|
+
if (this.excludeKeys?.has(metric.key)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
// If include is set, only include those
|
|
47
|
+
if (this.includeKeys) {
|
|
48
|
+
return this.includeKeys.has(metric.key);
|
|
49
|
+
}
|
|
50
|
+
// Default: include all
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get all metrics that pass the include/exclude filters.
|
|
55
|
+
*/
|
|
56
|
+
*getFilteredMetrics() {
|
|
57
|
+
for (const metric of this.store.getAllMetrics()) {
|
|
58
|
+
if (this.shouldIncludeMetric(metric)) {
|
|
59
|
+
yield metric;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Export metrics as a JSON string.
|
|
65
|
+
*/
|
|
66
|
+
getMetricsString() {
|
|
67
|
+
return JSON.stringify(this.getMetrics(), null, 2);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=GGMetricsExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGMetricsExporter.js","sourceRoot":"","sources":["../../../src/exporters/GGMetricsExporter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO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B;QAC3B,IAAI,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,wCAAwC;QACxC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,uBAAuB;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACM,CAAE,kBAAkB;QACzB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC;YAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnC,MAAM,MAAM,CAAC;YACjB,CAAC;QACL,CAAC;IACL,CAAC;IAOD;;OAEG;IACH,gBAAgB;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GGMetric } from "../GGMetric.js";
|
|
2
|
+
import { GGMetricsExporter, ExporterConfig } from "./GGMetricsExporter.js";
|
|
3
|
+
export type NestedValueConverter = (metric: GGMetric<any>, value: any, exporter: GGNestedMetricsExporter) => any;
|
|
4
|
+
/**
|
|
5
|
+
* Exports metrics in a nested, human-readable format.
|
|
6
|
+
* Groups metrics by their groupBy configuration and nests remaining labels.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GGNestedMetricsExporter extends GGMetricsExporter<NestedMetricsOutput> {
|
|
9
|
+
private static converters;
|
|
10
|
+
/**
|
|
11
|
+
* Register a value converter for a custom metric type.
|
|
12
|
+
*/
|
|
13
|
+
static registerConverter(metricClass: Function, converter: NestedValueConverter): void;
|
|
14
|
+
constructor(config?: ExporterConfig);
|
|
15
|
+
getMetrics(): NestedMetricsOutput;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a label key string into a labels object.
|
|
18
|
+
* Exposed for use by converters.
|
|
19
|
+
*/
|
|
20
|
+
parseLabels(labelKey: string): Record<string, string>;
|
|
21
|
+
private collectMetricValues;
|
|
22
|
+
private computeGroupKey;
|
|
23
|
+
private getShortName;
|
|
24
|
+
private getMetricType;
|
|
25
|
+
private formatValue;
|
|
26
|
+
private buildGroupEntries;
|
|
27
|
+
private nestByLabels;
|
|
28
|
+
}
|
|
29
|
+
export interface NestedMetricsOutput {
|
|
30
|
+
timestamp: number;
|
|
31
|
+
groups: Record<string, any[]>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=GGNestedMetricsExporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGNestedMetricsExporter.d.ts","sourceRoot":"","sources":["../../../src/exporters/GGNestedMetricsExporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAMxC,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAEzE,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,uBAAuB,KAAK,GAAG,CAAC;AAEjH;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,iBAAiB,CAAC,mBAAmB,CAAC;IAG/E,OAAO,CAAC,MAAM,CAAC,UAAU,CAA6C;IAStE;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,GAAG,IAAI;gBAI1E,MAAM,GAAE,cAAmB;IAIvC,UAAU,IAAI,mBAAmB;IAiCjC;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAarD,OAAO,CAAC,mBAAmB;IAgC3B,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,iBAAiB;IA0FzB,OAAO,CAAC,YAAY;CA6CvB;AA0CD,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { GGCounter } from "../metric/GGCounter.js";
|
|
2
|
+
import { GGGauge } from "../metric/GGGauge.js";
|
|
3
|
+
import { GGLazyGauge } from "../metric/GGLazyGauge.js";
|
|
4
|
+
import { GGHistogram } from "../metric/GGHistogram.js";
|
|
5
|
+
import { GGMetricsExporter } from "./GGMetricsExporter.js";
|
|
6
|
+
/**
|
|
7
|
+
* Exports metrics in a nested, human-readable format.
|
|
8
|
+
* Groups metrics by their groupBy configuration and nests remaining labels.
|
|
9
|
+
*/
|
|
10
|
+
export class GGNestedMetricsExporter extends GGMetricsExporter {
|
|
11
|
+
// Static map for extensibility - register value converters for new metric types
|
|
12
|
+
static converters = new Map();
|
|
13
|
+
static {
|
|
14
|
+
GGNestedMetricsExporter.registerConverter(GGCounter, convertCounterValue);
|
|
15
|
+
GGNestedMetricsExporter.registerConverter(GGGauge, convertGaugeValue);
|
|
16
|
+
GGNestedMetricsExporter.registerConverter(GGLazyGauge, convertLazyGaugeValue);
|
|
17
|
+
GGNestedMetricsExporter.registerConverter(GGHistogram, convertHistogramValue);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Register a value converter for a custom metric type.
|
|
21
|
+
*/
|
|
22
|
+
static registerConverter(metricClass, converter) {
|
|
23
|
+
GGNestedMetricsExporter.converters.set(metricClass, converter);
|
|
24
|
+
}
|
|
25
|
+
constructor(config = {}) {
|
|
26
|
+
super(config);
|
|
27
|
+
}
|
|
28
|
+
getMetrics() {
|
|
29
|
+
const output = {
|
|
30
|
+
timestamp: Date.now(),
|
|
31
|
+
groups: {}
|
|
32
|
+
};
|
|
33
|
+
// Collect all metric values with their parsed data
|
|
34
|
+
const allValues = [];
|
|
35
|
+
for (const metric of this.getFilteredMetrics()) {
|
|
36
|
+
const entries = this.collectMetricValues(metric);
|
|
37
|
+
allValues.push(...entries);
|
|
38
|
+
}
|
|
39
|
+
// Group by the groupBy key
|
|
40
|
+
const groupedByKey = new Map();
|
|
41
|
+
for (const entry of allValues) {
|
|
42
|
+
const existing = groupedByKey.get(entry.groupKey);
|
|
43
|
+
if (existing) {
|
|
44
|
+
existing.push(entry);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
groupedByKey.set(entry.groupKey, [entry]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Build the nested structure for each group
|
|
51
|
+
for (const [groupKey, entries] of groupedByKey) {
|
|
52
|
+
output.groups[groupKey] = this.buildGroupEntries(entries);
|
|
53
|
+
}
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse a label key string into a labels object.
|
|
58
|
+
* Exposed for use by converters.
|
|
59
|
+
*/
|
|
60
|
+
parseLabels(labelKey) {
|
|
61
|
+
if (!labelKey)
|
|
62
|
+
return {};
|
|
63
|
+
const labels = {};
|
|
64
|
+
const parts = labelKey.split(',');
|
|
65
|
+
for (const part of parts) {
|
|
66
|
+
const [key, val] = part.split('=');
|
|
67
|
+
if (key && val !== undefined) {
|
|
68
|
+
labels[key] = val;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return labels;
|
|
72
|
+
}
|
|
73
|
+
collectMetricValues(metric) {
|
|
74
|
+
const entries = [];
|
|
75
|
+
const key = metric.key;
|
|
76
|
+
const groupByLabels = key.groupBy?.labels ?? [];
|
|
77
|
+
const metricName = this.getShortName(key);
|
|
78
|
+
for (const [labelKey, value] of metric.getValues()) {
|
|
79
|
+
const labels = this.parseLabels(labelKey);
|
|
80
|
+
// Compute groupBy key
|
|
81
|
+
const groupKey = this.computeGroupKey(key, labels);
|
|
82
|
+
// Compute remaining labels (not in groupBy)
|
|
83
|
+
const remainingLabels = {};
|
|
84
|
+
for (const [k, v] of Object.entries(labels)) {
|
|
85
|
+
if (!groupByLabels.includes(k)) {
|
|
86
|
+
remainingLabels[k] = v;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
entries.push({
|
|
90
|
+
groupKey,
|
|
91
|
+
metricName,
|
|
92
|
+
metricType: this.getMetricType(metric),
|
|
93
|
+
remainingLabels,
|
|
94
|
+
value: this.formatValue(metric, value)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return entries;
|
|
98
|
+
}
|
|
99
|
+
computeGroupKey(key, labels) {
|
|
100
|
+
const groupBy = key.groupBy;
|
|
101
|
+
if (!groupBy || groupBy.labels.length === 0) {
|
|
102
|
+
return key.root; // Use metric root as default group
|
|
103
|
+
}
|
|
104
|
+
if (groupBy.template) {
|
|
105
|
+
// Template string - replace {labelName} with values, missing values become empty string
|
|
106
|
+
return groupBy.template.replace(/\{(\w+)\}/g, (_, labelName) => {
|
|
107
|
+
return String(labels[labelName] ?? '');
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
// Default: join values with comma
|
|
112
|
+
return groupBy.labels.map(l => String(labels[l] ?? '')).join(',');
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
getShortName(key) {
|
|
116
|
+
// Remove the root prefix to get just the metric name
|
|
117
|
+
return key.name.replace(key.root, '');
|
|
118
|
+
}
|
|
119
|
+
getMetricType(metric) {
|
|
120
|
+
return metric.constructor.name;
|
|
121
|
+
}
|
|
122
|
+
formatValue(metric, value) {
|
|
123
|
+
const converter = GGNestedMetricsExporter.converters.get(metric.constructor);
|
|
124
|
+
if (!converter) {
|
|
125
|
+
// Fallback: return raw value
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
return converter(metric, value, this);
|
|
129
|
+
}
|
|
130
|
+
buildGroupEntries(entries) {
|
|
131
|
+
// Find all unique "shared" label combinations
|
|
132
|
+
// Shared labels are those that exist in multiple metrics (like 'path')
|
|
133
|
+
// Non-shared labels are metric-specific (like 'result' only on counter)
|
|
134
|
+
// First, find which labels are common across all metrics in this group
|
|
135
|
+
const labelSets = new Map();
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
const labelNames = Object.keys(entry.remainingLabels);
|
|
138
|
+
const existing = labelSets.get(entry.metricName);
|
|
139
|
+
if (!existing) {
|
|
140
|
+
labelSets.set(entry.metricName, new Set(labelNames));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Find common labels (present in all metrics)
|
|
144
|
+
const allMetrics = [...labelSets.keys()];
|
|
145
|
+
let commonLabels = new Set();
|
|
146
|
+
if (allMetrics.length > 0) {
|
|
147
|
+
commonLabels = new Set(labelSets.get(allMetrics[0]));
|
|
148
|
+
for (let i = 1; i < allMetrics.length; i++) {
|
|
149
|
+
const metricLabels = labelSets.get(allMetrics[i]);
|
|
150
|
+
for (const label of commonLabels) {
|
|
151
|
+
if (!metricLabels.has(label)) {
|
|
152
|
+
commonLabels.delete(label);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Group entries by their common label values
|
|
158
|
+
const byCommonLabels = new Map();
|
|
159
|
+
for (const entry of entries) {
|
|
160
|
+
const commonKey = [...commonLabels]
|
|
161
|
+
.sort()
|
|
162
|
+
.map(l => `${l}=${entry.remainingLabels[l] ?? ''}`)
|
|
163
|
+
.join(',');
|
|
164
|
+
const existing = byCommonLabels.get(commonKey);
|
|
165
|
+
if (existing) {
|
|
166
|
+
existing.push(entry);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
byCommonLabels.set(commonKey, [entry]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Build output entries
|
|
173
|
+
const result = [];
|
|
174
|
+
for (const [_, groupEntries] of byCommonLabels) {
|
|
175
|
+
const outputEntry = {};
|
|
176
|
+
// Add common labels as direct properties
|
|
177
|
+
if (groupEntries.length > 0) {
|
|
178
|
+
for (const label of commonLabels) {
|
|
179
|
+
outputEntry[label] = groupEntries[0].remainingLabels[label];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Group entries by metric name
|
|
183
|
+
const byMetric = new Map();
|
|
184
|
+
for (const entry of groupEntries) {
|
|
185
|
+
const existing = byMetric.get(entry.metricName);
|
|
186
|
+
if (existing) {
|
|
187
|
+
existing.push(entry);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
byMetric.set(entry.metricName, [entry]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// Add each metric's values
|
|
194
|
+
for (const [metricName, metricEntries] of byMetric) {
|
|
195
|
+
// Get extra labels (not in commonLabels)
|
|
196
|
+
const extraLabels = Object.keys(metricEntries[0].remainingLabels)
|
|
197
|
+
.filter(l => !commonLabels.has(l));
|
|
198
|
+
if (extraLabels.length === 0) {
|
|
199
|
+
// No extra labels - value goes directly under metric name
|
|
200
|
+
outputEntry[metricName] = metricEntries[0].value;
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// Has extra labels - nest by those label names
|
|
204
|
+
this.nestByLabels(outputEntry, metricName, metricEntries, extraLabels, 0);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
result.push(outputEntry);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
nestByLabels(obj, metricName, entries, extraLabels, labelIndex) {
|
|
212
|
+
const currentLabel = extraLabels[labelIndex];
|
|
213
|
+
const isLastLabel = labelIndex === extraLabels.length - 1;
|
|
214
|
+
// Group entries by current label value
|
|
215
|
+
const byLabelValue = new Map();
|
|
216
|
+
for (const entry of entries) {
|
|
217
|
+
const labelValue = entry.remainingLabels[currentLabel] ?? '';
|
|
218
|
+
const existing = byLabelValue.get(labelValue);
|
|
219
|
+
if (existing) {
|
|
220
|
+
existing.push(entry);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
byLabelValue.set(labelValue, [entry]);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Create or get the label container
|
|
227
|
+
if (!obj[currentLabel]) {
|
|
228
|
+
obj[currentLabel] = {};
|
|
229
|
+
}
|
|
230
|
+
const labelContainer = obj[currentLabel];
|
|
231
|
+
// Add each label value
|
|
232
|
+
for (const [labelValue, valueEntries] of byLabelValue) {
|
|
233
|
+
if (isLastLabel) {
|
|
234
|
+
// Last label - add metric name and value
|
|
235
|
+
if (!labelContainer[labelValue]) {
|
|
236
|
+
labelContainer[labelValue] = {};
|
|
237
|
+
}
|
|
238
|
+
labelContainer[labelValue][metricName] = valueEntries[0].value;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// More labels to go - recurse
|
|
242
|
+
if (!labelContainer[labelValue]) {
|
|
243
|
+
labelContainer[labelValue] = {};
|
|
244
|
+
}
|
|
245
|
+
this.nestByLabels(labelContainer[labelValue], metricName, valueEntries, extraLabels, labelIndex + 1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Built-in value converters
|
|
251
|
+
function convertCounterValue(_metric, value, _exporter) {
|
|
252
|
+
return value;
|
|
253
|
+
}
|
|
254
|
+
function convertGaugeValue(_metric, value, _exporter) {
|
|
255
|
+
return value;
|
|
256
|
+
}
|
|
257
|
+
function convertLazyGaugeValue(_metric, value, _exporter) {
|
|
258
|
+
return value;
|
|
259
|
+
}
|
|
260
|
+
function convertHistogramValue(metric, value, _exporter) {
|
|
261
|
+
const buckets = metric.getBuckets();
|
|
262
|
+
const bucketObj = {};
|
|
263
|
+
for (let i = 0; i < buckets.length; i++) {
|
|
264
|
+
bucketObj[String(buckets[i])] = value.values[i] ?? 0;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
count: value.count,
|
|
268
|
+
sum: value.sum,
|
|
269
|
+
avg: value.count > 0 ? value.sum / value.count : 0,
|
|
270
|
+
min: value.min === Infinity ? 0 : value.min,
|
|
271
|
+
max: value.max === -Infinity ? 0 : value.max,
|
|
272
|
+
buckets: bucketObj
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=GGNestedMetricsExporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGNestedMetricsExporter.js","sourceRoot":"","sources":["../../../src/exporters/GGNestedMetricsExporter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAC,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAC,iBAAiB,EAAiB,MAAM,wBAAwB,CAAC;AAIzE;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,iBAAsC;IAE/E,gFAAgF;IACxE,MAAM,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkC,CAAC;IAEtE;QACI,uBAAuB,CAAC,iBAAiB,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAC1E,uBAAuB,CAAC,iBAAiB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;QACtE,uBAAuB,CAAC,iBAAiB,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;QAC9E,uBAAuB,CAAC,iBAAiB,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;IAClF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,WAAqB,EAAE,SAA+B;QAC3E,uBAAuB,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACnE,CAAC;IAED,YAAY,SAA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AAC,GAAG;QAC5C,OAAO,EAAE,SAAS;KACrB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './GGMetric';
|
|
2
|
+
export * from './metric/GGCounter';
|
|
3
|
+
export * from './metric/GGGauge';
|
|
4
|
+
export * from './metric/GGLazyGauge';
|
|
5
|
+
export * from './metric/GGHistogram';
|
|
6
|
+
export * from './GGMetrics';
|
|
7
|
+
export * from './GGMetricsLoader';
|
|
8
|
+
export * from "./GGMetricKey";
|
|
9
|
+
export * from "./keys/GGCounterKey";
|
|
10
|
+
export * from "./keys/GGGaugeKey";
|
|
11
|
+
export * from "./keys/GGLazyGaugeKey";
|
|
12
|
+
export * from "./keys/GGHistogramKey";
|
|
13
|
+
export * from './exporters/GGMetricsExporter';
|
|
14
|
+
export * from './exporters/GGJsonMetricsExporter';
|
|
15
|
+
export * from './exporters/GGNestedMetricsExporter';
|
|
16
|
+
export * from "./GGMetricsStore";
|
|
17
|
+
//# sourceMappingURL=index-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-browser.d.ts","sourceRoot":"","sources":["../../src/index-browser.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './GGMetric.js';
|
|
2
|
+
export * from './metric/GGCounter.js';
|
|
3
|
+
export * from './metric/GGGauge.js';
|
|
4
|
+
export * from './metric/GGLazyGauge.js';
|
|
5
|
+
export * from './metric/GGHistogram.js';
|
|
6
|
+
export * from './GGMetrics.js';
|
|
7
|
+
export * from './GGMetricsLoader.js';
|
|
8
|
+
export * from "./GGMetricKey.js";
|
|
9
|
+
export * from "./keys/GGCounterKey.js";
|
|
10
|
+
export * from "./keys/GGGaugeKey.js";
|
|
11
|
+
export * from "./keys/GGLazyGaugeKey.js";
|
|
12
|
+
export * from "./keys/GGHistogramKey.js";
|
|
13
|
+
export * from './exporters/GGMetricsExporter.js';
|
|
14
|
+
export * from './exporters/GGJsonMetricsExporter.js';
|
|
15
|
+
export * from './exporters/GGNestedMetricsExporter.js';
|
|
16
|
+
export * from "./GGMetricsStore.js";
|
|
17
|
+
//# sourceMappingURL=index-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-browser.js","sourceRoot":"","sources":["../../src/index-browser.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './GGMetric';
|
|
2
|
+
export * from './metric/GGCounter';
|
|
3
|
+
export * from './metric/GGGauge';
|
|
4
|
+
export * from './metric/GGLazyGauge';
|
|
5
|
+
export * from './metric/GGHistogram';
|
|
6
|
+
export * from './GGMetrics';
|
|
7
|
+
export * from './GGMetricsLoader';
|
|
8
|
+
export * from "./GGMetricKey";
|
|
9
|
+
export * from "./keys/GGCounterKey";
|
|
10
|
+
export * from "./keys/GGGaugeKey";
|
|
11
|
+
export * from "./keys/GGLazyGaugeKey";
|
|
12
|
+
export * from "./keys/GGHistogramKey";
|
|
13
|
+
export * from './exporters/GGMetricsExporter';
|
|
14
|
+
export * from './exporters/GGJsonMetricsExporter';
|
|
15
|
+
export * from './exporters/GGNestedMetricsExporter';
|
|
16
|
+
export * from "./GGMetricsStore";
|
|
17
|
+
//# sourceMappingURL=index-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.d.ts","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { _initMetricsStorage } from "./GGMetricsDefineStorage.js";
|
|
3
|
+
_initMetricsStorage(new AsyncLocalStorage());
|
|
4
|
+
export * from './GGMetric.js';
|
|
5
|
+
export * from './metric/GGCounter.js';
|
|
6
|
+
export * from './metric/GGGauge.js';
|
|
7
|
+
export * from './metric/GGLazyGauge.js';
|
|
8
|
+
export * from './metric/GGHistogram.js';
|
|
9
|
+
export * from './GGMetrics.js';
|
|
10
|
+
export * from './GGMetricsLoader.js';
|
|
11
|
+
export * from "./GGMetricKey.js";
|
|
12
|
+
export * from "./keys/GGCounterKey.js";
|
|
13
|
+
export * from "./keys/GGGaugeKey.js";
|
|
14
|
+
export * from "./keys/GGLazyGaugeKey.js";
|
|
15
|
+
export * from "./keys/GGHistogramKey.js";
|
|
16
|
+
export * from './exporters/GGMetricsExporter.js';
|
|
17
|
+
export * from './exporters/GGJsonMetricsExporter.js';
|
|
18
|
+
export * from './exporters/GGNestedMetricsExporter.js';
|
|
19
|
+
export * from "./GGMetricsStore.js";
|
|
20
|
+
//# sourceMappingURL=index-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-node.js","sourceRoot":"","sources":["../../src/index-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,mBAAmB,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;AAE7C,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGCounter } from "../metric/GGCounter.js";
|
|
3
|
+
import { GGMetricLabels, GGMetricOptions, LabelsArgs } from "../GGMetric.js";
|
|
4
|
+
export declare class GGCounterKey<TLabels extends GGMetricLabels = {}> extends GGMetricKey<TLabels, GGCounter<TLabels>> {
|
|
5
|
+
constructor(name: string, options: GGMetricOptions<TLabels>);
|
|
6
|
+
create(): GGCounter<TLabels>;
|
|
7
|
+
inc(value?: number, ...args: LabelsArgs<TLabels>): void;
|
|
8
|
+
getValue(...args: LabelsArgs<TLabels>): number;
|
|
9
|
+
reset(): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=GGCounterKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGCounterKey.d.ts","sourceRoot":"","sources":["../../../src/keys/GGCounterKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAE,eAAe,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE3E,qBAAa,YAAY,CACrB,OAAO,SAAS,cAAc,GAAG,EAAE,CACrC,SAAQ,WAAW,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;gBAElC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAKpD,MAAM,IAAI,SAAS,CAAC,OAAO,CAAC;IAI5B,GAAG,CAAC,KAAK,GAAE,MAAU,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAI1D,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM;IAI9C,KAAK,IAAI,IAAI;CAGvB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGCounter } from "../metric/GGCounter.js";
|
|
3
|
+
export class GGCounterKey extends GGMetricKey {
|
|
4
|
+
constructor(name, options) {
|
|
5
|
+
super(name, options);
|
|
6
|
+
Object.freeze(this);
|
|
7
|
+
}
|
|
8
|
+
create() {
|
|
9
|
+
return new GGCounter(this);
|
|
10
|
+
}
|
|
11
|
+
inc(value = 1, ...args) {
|
|
12
|
+
this.getMetric().inc(value, ...args);
|
|
13
|
+
}
|
|
14
|
+
getValue(...args) {
|
|
15
|
+
return this.getMetric().getValue(...args);
|
|
16
|
+
}
|
|
17
|
+
reset() {
|
|
18
|
+
this.getMetric().reset();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=GGCounterKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGCounterKey.js","sourceRoot":"","sources":["../../../src/keys/GGCounterKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAGjD,MAAM,OAAO,YAEX,SAAQ,WAAwC;IAE9C,YAAY,IAAY,EAAE,OAAiC;QACvD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAEM,MAAM;QACT,OAAO,IAAI,SAAS,CAAU,IAAI,CAAC,CAAC;IACxC,CAAC;IAEM,GAAG,CAAC,QAAgB,CAAC,EAAE,GAAG,IAAyB;QACtD,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,QAAQ,CAAC,GAAG,IAAyB;QACxC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGGauge } from "../metric/GGGauge.js";
|
|
3
|
+
import { GGMetricLabels, GGMetricOptions, LabelsArgs } from "../GGMetric.js";
|
|
4
|
+
export declare class GGGaugeKey<TLabels extends GGMetricLabels = {}> extends GGMetricKey<TLabels, GGGauge<TLabels>> {
|
|
5
|
+
constructor(name: string, options: GGMetricOptions<TLabels>);
|
|
6
|
+
create(): GGGauge<TLabels>;
|
|
7
|
+
set(value: number, ...args: LabelsArgs<TLabels>): void;
|
|
8
|
+
inc(value?: number, ...args: LabelsArgs<TLabels>): void;
|
|
9
|
+
dec(value?: number, ...args: LabelsArgs<TLabels>): void;
|
|
10
|
+
getValue(...args: LabelsArgs<TLabels>): number;
|
|
11
|
+
reset(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=GGGaugeKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGGaugeKey.d.ts","sourceRoot":"","sources":["../../../src/keys/GGGaugeKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAC,cAAc,EAAE,eAAe,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE3E,qBAAa,UAAU,CACnB,OAAO,SAAS,cAAc,GAAG,EAAE,CACrC,SAAQ,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;gBAEhC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IAKpD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAI1B,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAItD,GAAG,CAAC,KAAK,GAAE,MAAU,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAI1D,GAAG,CAAC,KAAK,GAAE,MAAU,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAI1D,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM;IAI9C,KAAK,IAAI,IAAI;CAGvB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGGauge } from "../metric/GGGauge.js";
|
|
3
|
+
export class GGGaugeKey extends GGMetricKey {
|
|
4
|
+
constructor(name, options) {
|
|
5
|
+
super(name, options);
|
|
6
|
+
Object.freeze(this);
|
|
7
|
+
}
|
|
8
|
+
create() {
|
|
9
|
+
return new GGGauge(this);
|
|
10
|
+
}
|
|
11
|
+
set(value, ...args) {
|
|
12
|
+
this.getMetric().set(value, ...args);
|
|
13
|
+
}
|
|
14
|
+
inc(value = 1, ...args) {
|
|
15
|
+
this.getMetric().inc(value, ...args);
|
|
16
|
+
}
|
|
17
|
+
dec(value = 1, ...args) {
|
|
18
|
+
this.getMetric().dec(value, ...args);
|
|
19
|
+
}
|
|
20
|
+
getValue(...args) {
|
|
21
|
+
return this.getMetric().getValue(...args);
|
|
22
|
+
}
|
|
23
|
+
reset() {
|
|
24
|
+
this.getMetric().reset();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=GGGaugeKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGGaugeKey.js","sourceRoot":"","sources":["../../../src/keys/GGGaugeKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAG7C,MAAM,OAAO,UAEX,SAAQ,WAAsC;IAE5C,YAAY,IAAY,EAAE,OAAiC;QACvD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAEM,MAAM;QACT,OAAO,IAAI,OAAO,CAAU,IAAI,CAAC,CAAC;IACtC,CAAC;IAEM,GAAG,CAAC,KAAa,EAAE,GAAG,IAAyB;QAClD,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,GAAG,CAAC,QAAgB,CAAC,EAAE,GAAG,IAAyB;QACtD,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,GAAG,CAAC,QAAgB,CAAC,EAAE,GAAG,IAAyB;QACtD,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACzC,CAAC;IAEM,QAAQ,CAAC,GAAG,IAAyB;QACxC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGHistogram, HistogramData, HistogramOptions } from "../metric/GGHistogram.js";
|
|
3
|
+
import { GGMetricLabels, LabelsArgs } from "../GGMetric.js";
|
|
4
|
+
export declare class GGHistogramKey<TLabels extends GGMetricLabels = {}> extends GGMetricKey<TLabels, GGHistogram<TLabels>> {
|
|
5
|
+
readonly buckets: number[];
|
|
6
|
+
constructor(name: string, options: HistogramOptions<TLabels>);
|
|
7
|
+
create(): GGHistogram<TLabels>;
|
|
8
|
+
observe(value: number, ...args: LabelsArgs<TLabels>): void;
|
|
9
|
+
startTimer(...args: LabelsArgs<TLabels>): () => void;
|
|
10
|
+
getValue(...args: LabelsArgs<TLabels>): HistogramData | undefined;
|
|
11
|
+
reset(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=GGHistogramKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGHistogramKey.d.ts","sourceRoot":"","sources":["../../../src/keys/GGHistogramKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAE1D,qBAAa,cAAc,CACvB,OAAO,SAAS,cAAc,GAAG,EAAE,CACrC,SAAQ,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAEhD,SAAgB,OAAO,EAAE,MAAM,EAAE,CAAC;gBAEtB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;IAOrD,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI;IAI1D,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,IAAI;IAIpD,QAAQ,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,aAAa,GAAG,SAAS;IAIjE,KAAK,IAAI,IAAI;CAGvB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { GGMetricKey } from "../GGMetricKey.js";
|
|
2
|
+
import { GGHistogram } from "../metric/GGHistogram.js";
|
|
3
|
+
export class GGHistogramKey extends GGMetricKey {
|
|
4
|
+
buckets;
|
|
5
|
+
constructor(name, options) {
|
|
6
|
+
super(name, options);
|
|
7
|
+
this.buckets = options.buckets.sort((a, b) => a - b);
|
|
8
|
+
Object.freeze(this.buckets);
|
|
9
|
+
Object.freeze(this);
|
|
10
|
+
}
|
|
11
|
+
create() {
|
|
12
|
+
return new GGHistogram(this);
|
|
13
|
+
}
|
|
14
|
+
observe(value, ...args) {
|
|
15
|
+
this.getMetric().observe(value, ...args);
|
|
16
|
+
}
|
|
17
|
+
startTimer(...args) {
|
|
18
|
+
return this.getMetric().startTimer(...args);
|
|
19
|
+
}
|
|
20
|
+
getValue(...args) {
|
|
21
|
+
return this.getMetric().getValue(...args);
|
|
22
|
+
}
|
|
23
|
+
reset() {
|
|
24
|
+
this.getMetric().reset();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=GGHistogramKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GGHistogramKey.js","sourceRoot":"","sources":["../../../src/keys/GGHistogramKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAkC,MAAM,0BAA0B,CAAC;AAGtF,MAAM,OAAO,cAEX,SAAQ,WAA0C;IAEhC,OAAO,CAAW;IAElC,YAAY,IAAY,EAAE,OAAkC;QACxD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAEM,MAAM;QACT,OAAO,IA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