@libp2p/prometheus-metrics 4.0.1 → 4.1.0
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/dist/src/histogram-group.d.ts +14 -0
- package/dist/src/histogram-group.d.ts.map +1 -0
- package/dist/src/histogram-group.js +52 -0
- package/dist/src/histogram-group.js.map +1 -0
- package/dist/src/histogram.d.ts +12 -0
- package/dist/src/histogram.d.ts.map +1 -0
- package/dist/src/histogram.js +45 -0
- package/dist/src/histogram.js.map +1 -0
- package/dist/src/index.d.ts +8 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +82 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/summary-group.d.ts +14 -0
- package/dist/src/summary-group.d.ts.map +1 -0
- package/dist/src/summary-group.js +56 -0
- package/dist/src/summary-group.js.map +1 -0
- package/dist/src/summary.d.ts +12 -0
- package/dist/src/summary.d.ts.map +1 -0
- package/dist/src/summary.js +49 -0
- package/dist/src/summary.js.map +1 -0
- package/dist/typedoc-urls.json +4 -0
- package/package.json +6 -6
- package/src/histogram-group.ts +63 -0
- package/src/histogram.ts +55 -0
- package/src/index.ts +132 -1
- package/src/summary-group.ts +67 -0
- package/src/summary.ts +59 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CalculatedMetric } from './utils.js';
|
|
2
|
+
import type { PrometheusCalculatedHistogramOptions } from './index.js';
|
|
3
|
+
import type { CalculateMetric, HistogramGroup, StopTimer } from '@libp2p/interface';
|
|
4
|
+
export declare class PrometheusHistogramGroup implements HistogramGroup, CalculatedMetric<Record<string, number>> {
|
|
5
|
+
private readonly histogram;
|
|
6
|
+
private readonly label;
|
|
7
|
+
private readonly calculators;
|
|
8
|
+
constructor(name: string, opts: PrometheusCalculatedHistogramOptions<Record<string, number>>);
|
|
9
|
+
addCalculator(calculator: CalculateMetric<Record<string, number>>): void;
|
|
10
|
+
observe(values: Record<string, number>): void;
|
|
11
|
+
reset(): void;
|
|
12
|
+
timer(key: string): StopTimer;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=histogram-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram-group.d.ts","sourceRoot":"","sources":["../../src/histogram-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEnF,qBAAa,wBAAyB,YAAW,cAAc,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgD;gBAE/D,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oCAAoC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAiC7F,aAAa,CAAE,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAIzE,OAAO,CAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAM9C,KAAK,IAAK,IAAI;IAId,KAAK,CAAE,GAAG,EAAE,MAAM,GAAG,SAAS;CAK/B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Histogram as PromHistogram } from 'prom-client';
|
|
2
|
+
import { normaliseString } from './utils.js';
|
|
3
|
+
export class PrometheusHistogramGroup {
|
|
4
|
+
histogram;
|
|
5
|
+
label;
|
|
6
|
+
calculators;
|
|
7
|
+
constructor(name, opts) {
|
|
8
|
+
name = normaliseString(name);
|
|
9
|
+
const help = normaliseString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normaliseString(opts.label ?? name);
|
|
11
|
+
let collect;
|
|
12
|
+
this.calculators = [];
|
|
13
|
+
// calculated metric
|
|
14
|
+
if (opts?.calculate != null) {
|
|
15
|
+
this.calculators.push(opts.calculate);
|
|
16
|
+
const self = this;
|
|
17
|
+
collect = async function () {
|
|
18
|
+
await Promise.all(self.calculators.map(async (calculate) => {
|
|
19
|
+
const values = await calculate();
|
|
20
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
21
|
+
this.observe({ [label]: key }, value);
|
|
22
|
+
});
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
this.histogram = new PromHistogram({
|
|
27
|
+
name,
|
|
28
|
+
help,
|
|
29
|
+
buckets: opts.buckets ?? [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
30
|
+
labelNames: [this.label],
|
|
31
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
32
|
+
collect
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
addCalculator(calculator) {
|
|
36
|
+
this.calculators.push(calculator);
|
|
37
|
+
}
|
|
38
|
+
observe(values) {
|
|
39
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
40
|
+
this.histogram.observe({ [this.label]: key }, value);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
reset() {
|
|
44
|
+
this.histogram.reset();
|
|
45
|
+
}
|
|
46
|
+
timer(key) {
|
|
47
|
+
return this.histogram.startTimer({
|
|
48
|
+
[key]: 0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=histogram-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram-group.js","sourceRoot":"","sources":["../../src/histogram-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;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C,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAClF,UAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACxB,SAAS,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;YACpE,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAE,UAAmD;QAChE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC;IAED,OAAO,CAAE,MAA8B;QACrC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC9C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,KAAK,CAAC,CAAA;QACtD,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;IAED,KAAK,CAAE,GAAW;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;YAC/B,CAAC,GAAG,CAAC,EAAE,CAAC;SACT,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PrometheusCalculatedHistogramOptions } from './index.js';
|
|
2
|
+
import type { StopTimer, CalculateMetric, Histogram } from '@libp2p/interface';
|
|
3
|
+
export declare class PrometheusHistogram implements Histogram {
|
|
4
|
+
private readonly histogram;
|
|
5
|
+
private readonly calculators;
|
|
6
|
+
constructor(name: string, opts: PrometheusCalculatedHistogramOptions);
|
|
7
|
+
addCalculator(calculator: CalculateMetric): void;
|
|
8
|
+
observe(value: number): void;
|
|
9
|
+
reset(): void;
|
|
10
|
+
timer(): StopTimer;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=histogram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram.d.ts","sourceRoot":"","sources":["../../src/histogram.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE9E,qBAAa,mBAAoB,YAAW,SAAS;IACnD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;gBAElC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oCAAoC;IA8BrE,aAAa,CAAE,UAAU,EAAE,eAAe,GAAG,IAAI;IAIjD,OAAO,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAK,IAAI;IAId,KAAK,IAAK,SAAS;CAGpB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Histogram as PromHistogram } from 'prom-client';
|
|
2
|
+
import { normaliseString } from './utils.js';
|
|
3
|
+
export class PrometheusHistogram {
|
|
4
|
+
histogram;
|
|
5
|
+
calculators;
|
|
6
|
+
constructor(name, opts) {
|
|
7
|
+
name = normaliseString(name);
|
|
8
|
+
const help = normaliseString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normaliseString(opts.label)] : [];
|
|
10
|
+
let collect;
|
|
11
|
+
this.calculators = [];
|
|
12
|
+
// calculated metric
|
|
13
|
+
if (opts?.calculate != null) {
|
|
14
|
+
this.calculators.push(opts.calculate);
|
|
15
|
+
const self = this;
|
|
16
|
+
collect = async function () {
|
|
17
|
+
const values = await Promise.all(self.calculators.map(async (calculate) => calculate()));
|
|
18
|
+
for (const value of values) {
|
|
19
|
+
this.observe(value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
this.histogram = new PromHistogram({
|
|
24
|
+
name,
|
|
25
|
+
help,
|
|
26
|
+
buckets: opts.buckets ?? [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
27
|
+
labelNames: labels,
|
|
28
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
29
|
+
collect
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
addCalculator(calculator) {
|
|
33
|
+
this.calculators.push(calculator);
|
|
34
|
+
}
|
|
35
|
+
observe(value) {
|
|
36
|
+
this.histogram.observe(value);
|
|
37
|
+
}
|
|
38
|
+
reset() {
|
|
39
|
+
this.histogram.reset();
|
|
40
|
+
}
|
|
41
|
+
timer() {
|
|
42
|
+
return this.histogram.startTimer();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=histogram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"histogram.js","sourceRoot":"","sources":["../../src/histogram.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,SAAS,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAI5C,MAAM,OAAO,mBAAmB;IACb,SAAS,CAAe;IACxB,WAAW,CAAmB;IAE/C,YAAa,IAAY,EAAE,IAA0C;QACnE,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;QAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QACtE,IAAI,OAAwD,CAAA;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;IACxB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC;CACF"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
68
|
import { type DefaultMetricsCollectorConfiguration, type Registry, type RegistryContentType } from 'prom-client';
|
|
69
|
-
import type { ComponentLogger, CalculatedMetricOptions, Metrics } from '@libp2p/interface';
|
|
69
|
+
import type { ComponentLogger, CalculatedMetricOptions, Metrics, CalculatedHistogramOptions, CalculatedSummaryOptions } from '@libp2p/interface';
|
|
70
|
+
export { linearBuckets, exponentialBuckets } from 'prom-client';
|
|
70
71
|
export interface PrometheusMetricsInit {
|
|
71
72
|
/**
|
|
72
73
|
* Use a custom registry to register metrics.
|
|
@@ -92,6 +93,12 @@ export interface PrometheusMetricsInit {
|
|
|
92
93
|
export interface PrometheusCalculatedMetricOptions<T = number> extends CalculatedMetricOptions<T> {
|
|
93
94
|
registry?: Registry;
|
|
94
95
|
}
|
|
96
|
+
export interface PrometheusCalculatedHistogramOptions<T = number> extends CalculatedHistogramOptions<T> {
|
|
97
|
+
registry?: Registry;
|
|
98
|
+
}
|
|
99
|
+
export interface PrometheusCalculatedSummaryOptions<T = number> extends CalculatedSummaryOptions<T> {
|
|
100
|
+
registry?: Registry;
|
|
101
|
+
}
|
|
95
102
|
export interface PrometheusMetricsComponents {
|
|
96
103
|
logger: ComponentLogger;
|
|
97
104
|
}
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAIH,OAAO,EAAyB,KAAK,oCAAoC,EAAY,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE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AC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,UAAU,EAAE,2BAA2B,KAAK,OAAO,CAI9H"}
|
package/dist/src/index.js
CHANGED
|
@@ -70,8 +70,14 @@ import each from 'it-foreach';
|
|
|
70
70
|
import { collectDefaultMetrics, register } from 'prom-client';
|
|
71
71
|
import { PrometheusCounterGroup } from './counter-group.js';
|
|
72
72
|
import { PrometheusCounter } from './counter.js';
|
|
73
|
+
import { PrometheusHistogramGroup } from './histogram-group.js';
|
|
74
|
+
import { PrometheusHistogram } from './histogram.js';
|
|
73
75
|
import { PrometheusMetricGroup } from './metric-group.js';
|
|
74
76
|
import { PrometheusMetric } from './metric.js';
|
|
77
|
+
import { PrometheusSummaryGroup } from './summary-group.js';
|
|
78
|
+
import { PrometheusSummary } from './summary.js';
|
|
79
|
+
// export helper functions for creating buckets
|
|
80
|
+
export { linearBuckets, exponentialBuckets } from 'prom-client';
|
|
75
81
|
// prom-client metrics are global
|
|
76
82
|
const metrics = new Map();
|
|
77
83
|
class PrometheusMetrics {
|
|
@@ -231,6 +237,82 @@ class PrometheusMetrics {
|
|
|
231
237
|
return counterGroup;
|
|
232
238
|
}
|
|
233
239
|
}
|
|
240
|
+
registerHistogram(name, opts = {}) {
|
|
241
|
+
if (name == null ?? name.trim() === '') {
|
|
242
|
+
throw new Error('Histogram name is required');
|
|
243
|
+
}
|
|
244
|
+
let metric = metrics.get(name);
|
|
245
|
+
if (metrics.has(name)) {
|
|
246
|
+
this.log('Reuse existing histogram', name);
|
|
247
|
+
if (opts.calculate != null) {
|
|
248
|
+
metric.addCalculator(opts.calculate);
|
|
249
|
+
}
|
|
250
|
+
return metrics.get(name);
|
|
251
|
+
}
|
|
252
|
+
this.log('Register histogram', name);
|
|
253
|
+
metric = new PrometheusHistogram(name, { registry: this.registry, ...opts });
|
|
254
|
+
metrics.set(name, metric);
|
|
255
|
+
if (opts.calculate == null) {
|
|
256
|
+
return metric;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
registerHistogramGroup(name, opts = {}) {
|
|
260
|
+
if (name == null ?? name.trim() === '') {
|
|
261
|
+
throw new Error('Histogram group name is required');
|
|
262
|
+
}
|
|
263
|
+
let metricGroup = metrics.get(name);
|
|
264
|
+
if (metricGroup != null) {
|
|
265
|
+
this.log('Reuse existing histogram group', name);
|
|
266
|
+
if (opts.calculate != null) {
|
|
267
|
+
metricGroup.addCalculator(opts.calculate);
|
|
268
|
+
}
|
|
269
|
+
return metricGroup;
|
|
270
|
+
}
|
|
271
|
+
this.log('Register histogram group', name);
|
|
272
|
+
metricGroup = new PrometheusHistogramGroup(name, { registry: this.registry, ...opts });
|
|
273
|
+
metrics.set(name, metricGroup);
|
|
274
|
+
if (opts.calculate == null) {
|
|
275
|
+
return metricGroup;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
registerSummary(name, opts = {}) {
|
|
279
|
+
if (name == null ?? name.trim() === '') {
|
|
280
|
+
throw new Error('Summary name is required');
|
|
281
|
+
}
|
|
282
|
+
let metric = metrics.get(name);
|
|
283
|
+
if (metrics.has(name)) {
|
|
284
|
+
this.log('Reuse existing summary', name);
|
|
285
|
+
if (opts.calculate != null) {
|
|
286
|
+
metric.addCalculator(opts.calculate);
|
|
287
|
+
}
|
|
288
|
+
return metrics.get(name);
|
|
289
|
+
}
|
|
290
|
+
this.log('Register summary', name);
|
|
291
|
+
metric = new PrometheusSummary(name, { registry: this.registry, ...opts });
|
|
292
|
+
metrics.set(name, metric);
|
|
293
|
+
if (opts.calculate == null) {
|
|
294
|
+
return metric;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
registerSummaryGroup(name, opts = {}) {
|
|
298
|
+
if (name == null ?? name.trim() === '') {
|
|
299
|
+
throw new Error('Summary group name is required');
|
|
300
|
+
}
|
|
301
|
+
let metricGroup = metrics.get(name);
|
|
302
|
+
if (metricGroup != null) {
|
|
303
|
+
this.log('Reuse existing summary group', name);
|
|
304
|
+
if (opts.calculate != null) {
|
|
305
|
+
metricGroup.addCalculator(opts.calculate);
|
|
306
|
+
}
|
|
307
|
+
return metricGroup;
|
|
308
|
+
}
|
|
309
|
+
this.log('Register summary group', name);
|
|
310
|
+
metricGroup = new PrometheusSummaryGroup(name, { registry: this.registry, ...opts });
|
|
311
|
+
metrics.set(name, metricGroup);
|
|
312
|
+
if (opts.calculate == null) {
|
|
313
|
+
return metricGroup;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
234
316
|
}
|
|
235
317
|
export function prometheusMetrics(init) {
|
|
236
318
|
return (components) => {
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,IAAI,MAAM,YAAY,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAA6C,QAAQ,EAA2C,MAAM,aAAa,CAAA;AACjJ,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,IAAI,MAAM,YAAY,CAAA;AAC7B,OAAO,EAAE,qBAAqB,EAA6C,QAAQ,EAA2C,MAAM,aAAa,CAAA;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,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,IAAI,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAEnC,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,8BAA8B,EAAE,IAAI,CAAC,CAAA;YAE9C,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;gBAC3B,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC3C,CAAC;YAED,OAAO,WAAW,CAAA;QACpB,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;QACxC,WAAW,GAAG,IAAI,sBAAsB,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAA;QAEpF,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAE9B,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YAC3B,OAAO,WAAW,CAAA;QACpB,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAE,IAAqC;IACtE,OAAO,CAAC,UAAU,EAAE,EAAE;QACpB,OAAO,IAAI,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAChD,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CalculatedMetric } from './utils.js';
|
|
2
|
+
import type { PrometheusCalculatedSummaryOptions } from './index.js';
|
|
3
|
+
import type { CalculateMetric, SummaryGroup, StopTimer } from '@libp2p/interface';
|
|
4
|
+
export declare class PrometheusSummaryGroup implements SummaryGroup, CalculatedMetric<Record<string, number>> {
|
|
5
|
+
private readonly summary;
|
|
6
|
+
private readonly label;
|
|
7
|
+
private readonly calculators;
|
|
8
|
+
constructor(name: string, opts: PrometheusCalculatedSummaryOptions<Record<string, number>>);
|
|
9
|
+
addCalculator(calculator: CalculateMetric<Record<string, number>>): void;
|
|
10
|
+
observe(values: Record<string, number>): void;
|
|
11
|
+
reset(): void;
|
|
12
|
+
timer(key: string): StopTimer;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=summary-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary-group.d.ts","sourceRoot":"","sources":["../../src/summary-group.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACnE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEjF,qBAAa,sBAAuB,YAAW,YAAY,EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgD;gBAE/D,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqC3F,aAAa,CAAE,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAIzE,OAAO,CAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAM9C,KAAK,IAAK,IAAI;IAId,KAAK,CAAE,GAAG,EAAE,MAAM,GAAG,SAAS;CAK/B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Summary as PromSummary } from 'prom-client';
|
|
2
|
+
import { normaliseString } from './utils.js';
|
|
3
|
+
export class PrometheusSummaryGroup {
|
|
4
|
+
summary;
|
|
5
|
+
label;
|
|
6
|
+
calculators;
|
|
7
|
+
constructor(name, opts) {
|
|
8
|
+
name = normaliseString(name);
|
|
9
|
+
const help = normaliseString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normaliseString(opts.label ?? name);
|
|
11
|
+
let collect;
|
|
12
|
+
this.calculators = [];
|
|
13
|
+
// calculated metric
|
|
14
|
+
if (opts?.calculate != null) {
|
|
15
|
+
this.calculators.push(opts.calculate);
|
|
16
|
+
const self = this;
|
|
17
|
+
collect = async function () {
|
|
18
|
+
await Promise.all(self.calculators.map(async (calculate) => {
|
|
19
|
+
const values = await calculate();
|
|
20
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
21
|
+
this.observe({ [label]: key }, value);
|
|
22
|
+
});
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
this.summary = new PromSummary({
|
|
27
|
+
name,
|
|
28
|
+
help,
|
|
29
|
+
percentiles: opts.percentiles ?? [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999],
|
|
30
|
+
maxAgeSeconds: opts.maxAgeSeconds,
|
|
31
|
+
ageBuckets: opts.ageBuckets,
|
|
32
|
+
pruneAgedBuckets: opts.pruneAgedBuckets,
|
|
33
|
+
compressCount: opts.compressCount ?? 1000,
|
|
34
|
+
labelNames: [this.label],
|
|
35
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
36
|
+
collect
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
addCalculator(calculator) {
|
|
40
|
+
this.calculators.push(calculator);
|
|
41
|
+
}
|
|
42
|
+
observe(values) {
|
|
43
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
44
|
+
this.summary.observe({ [this.label]: key }, value);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.summary.reset();
|
|
49
|
+
}
|
|
50
|
+
timer(key) {
|
|
51
|
+
return this.summary.startTimer({
|
|
52
|
+
[key]: 0
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=summary-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary-group.js","sourceRoot":"","sources":["../../src/summary-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,OAAO,IAAI,WAAW,EAAE,MAAM,aAAa,CAAA;AAC1E,OAAO,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAA;AAInE,MAAM,OAAO,sBAAsB;IAChB,OAAO,CAAa;IACpB,KAAK,CAAQ;IACb,WAAW,CAAgD;IAE5E,YAAa,IAAY,EAAE,IAAgE;QACzF,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;QAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAA;QAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAA;QAC9D,IAAI,OAAsD,CAAA;QAC1D,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QAErB,oBAAoB;QACpB,IAAI,IAAI,EAAE,SAAS,IAAI,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAA;YAEjB,OAAO,GAAG,KAAK;gBACb,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,EAAC,SAAS,EAAC,EAAE;oBACvD,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;oBAEhC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC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IAED,KAAK,CAAE,GAAW;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;YAC7B,CAAC,GAAG,CAAC,EAAE,CAAC;SACT,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PrometheusCalculatedSummaryOptions } from './index.js';
|
|
2
|
+
import type { StopTimer, CalculateMetric, Summary } from '@libp2p/interface';
|
|
3
|
+
export declare class PrometheusSummary implements Summary {
|
|
4
|
+
private readonly summary;
|
|
5
|
+
private readonly calculators;
|
|
6
|
+
constructor(name: string, opts: PrometheusCalculatedSummaryOptions);
|
|
7
|
+
addCalculator(calculator: CalculateMetric): void;
|
|
8
|
+
observe(value: number): void;
|
|
9
|
+
reset(): void;
|
|
10
|
+
timer(): StopTimer;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/summary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE5E,qBAAa,iBAAkB,YAAW,OAAO;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAmB;gBAElC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC;IAkCnE,aAAa,CAAE,UAAU,EAAE,eAAe,GAAG,IAAI;IAIjD,OAAO,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAK,IAAI;IAId,KAAK,IAAK,SAAS;CAGpB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Summary as PromSummary } from 'prom-client';
|
|
2
|
+
import { normaliseString } from './utils.js';
|
|
3
|
+
export class PrometheusSummary {
|
|
4
|
+
summary;
|
|
5
|
+
calculators;
|
|
6
|
+
constructor(name, opts) {
|
|
7
|
+
name = normaliseString(name);
|
|
8
|
+
const help = normaliseString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normaliseString(opts.label)] : [];
|
|
10
|
+
let collect;
|
|
11
|
+
this.calculators = [];
|
|
12
|
+
// calculated metric
|
|
13
|
+
if (opts?.calculate != null) {
|
|
14
|
+
this.calculators.push(opts.calculate);
|
|
15
|
+
const self = this;
|
|
16
|
+
collect = async function () {
|
|
17
|
+
const values = await Promise.all(self.calculators.map(async (calculate) => calculate()));
|
|
18
|
+
for (const value of values) {
|
|
19
|
+
this.observe(value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
this.summary = new PromSummary({
|
|
24
|
+
name,
|
|
25
|
+
help,
|
|
26
|
+
percentiles: opts.percentiles ?? [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999],
|
|
27
|
+
maxAgeSeconds: opts.maxAgeSeconds,
|
|
28
|
+
ageBuckets: opts.ageBuckets,
|
|
29
|
+
pruneAgedBuckets: opts.pruneAgedBuckets,
|
|
30
|
+
compressCount: opts.compressCount ?? 1000,
|
|
31
|
+
labelNames: labels,
|
|
32
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
33
|
+
collect
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
addCalculator(calculator) {
|
|
37
|
+
this.calculators.push(calculator);
|
|
38
|
+
}
|
|
39
|
+
observe(value) {
|
|
40
|
+
this.summary.observe(value);
|
|
41
|
+
}
|
|
42
|
+
reset() {
|
|
43
|
+
this.summary.reset();
|
|
44
|
+
}
|
|
45
|
+
timer() {
|
|
46
|
+
return this.summary.startTimer();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRo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AE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;YAC1E,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,IAAI;YACzC,UAAU,EAAE,MAAM;YAClB,SAAS,EAAE,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS;YACpE,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAE,UAA2B;QACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACnC,CAAC;IAED,OAAO,CAAE,KAAa;QACpB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IACtB,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;IAClC,CAAC;CACF"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"PrometheusCalculatedHistogramOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedHistogramOptions.html",
|
|
3
|
+
".:PrometheusCalculatedHistogramOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedHistogramOptions.html",
|
|
2
4
|
"PrometheusCalculatedMetricOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedMetricOptions.html",
|
|
3
5
|
".:PrometheusCalculatedMetricOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedMetricOptions.html",
|
|
6
|
+
"PrometheusCalculatedSummaryOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedSummaryOptions.html",
|
|
7
|
+
".:PrometheusCalculatedSummaryOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusCalculatedSummaryOptions.html",
|
|
4
8
|
"PrometheusMetricsComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusMetricsComponents.html",
|
|
5
9
|
".:PrometheusMetricsComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusMetricsComponents.html",
|
|
6
10
|
"PrometheusMetricsInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_prometheus_metrics.PrometheusMetricsInit.html",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/prometheus-metrics",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Collect libp2p metrics for scraping by Prometheus or Graphana",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"test:electron-main": "aegir test -t electron-main --cov"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@libp2p/interface": "^2.0
|
|
51
|
+
"@libp2p/interface": "^2.1.0",
|
|
52
52
|
"it-foreach": "^2.1.0",
|
|
53
53
|
"it-stream-types": "^2.0.1",
|
|
54
54
|
"prom-client": "^15.1.2",
|
|
55
55
|
"uint8arraylist": "^2.4.8"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@libp2p/crypto": "^5.0.
|
|
59
|
-
"@libp2p/interface-compliance-tests": "^6.0
|
|
60
|
-
"@libp2p/logger": "^5.0.
|
|
61
|
-
"@libp2p/peer-id": "^5.0.
|
|
58
|
+
"@libp2p/crypto": "^5.0.2",
|
|
59
|
+
"@libp2p/interface-compliance-tests": "^6.1.0",
|
|
60
|
+
"@libp2p/logger": "^5.0.2",
|
|
61
|
+
"@libp2p/peer-id": "^5.0.2",
|
|
62
62
|
"@multiformats/multiaddr": "^12.2.3",
|
|
63
63
|
"aegir": "^44.0.1",
|
|
64
64
|
"it-drain": "^3.0.7",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type CollectFunction, Histogram as PromHistogram } from 'prom-client'
|
|
2
|
+
import { normaliseString, type CalculatedMetric } from './utils.js'
|
|
3
|
+
import type { PrometheusCalculatedHistogramOptions } from './index.js'
|
|
4
|
+
import type { CalculateMetric, HistogramGroup, StopTimer } from '@libp2p/interface'
|
|
5
|
+
|
|
6
|
+
export class PrometheusHistogramGroup implements HistogramGroup, CalculatedMetric<Record<string, number>> {
|
|
7
|
+
private readonly histogram: PromHistogram
|
|
8
|
+
private readonly label: string
|
|
9
|
+
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
|
+
|
|
11
|
+
constructor (name: string, opts: PrometheusCalculatedHistogramOptions<Record<string, number>>) {
|
|
12
|
+
name = normaliseString(name)
|
|
13
|
+
const help = normaliseString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normaliseString(opts.label ?? name)
|
|
15
|
+
let collect: CollectFunction<PromHistogram<any>> | undefined
|
|
16
|
+
this.calculators = []
|
|
17
|
+
|
|
18
|
+
// calculated metric
|
|
19
|
+
if (opts?.calculate != null) {
|
|
20
|
+
this.calculators.push(opts.calculate)
|
|
21
|
+
const self = this
|
|
22
|
+
|
|
23
|
+
collect = async function () {
|
|
24
|
+
await Promise.all(self.calculators.map(async calculate => {
|
|
25
|
+
const values = await calculate()
|
|
26
|
+
|
|
27
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
28
|
+
this.observe({ [label]: key }, value)
|
|
29
|
+
})
|
|
30
|
+
}))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.histogram = new PromHistogram({
|
|
35
|
+
name,
|
|
36
|
+
help,
|
|
37
|
+
buckets: opts.buckets ?? [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
38
|
+
labelNames: [this.label],
|
|
39
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
40
|
+
collect
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addCalculator (calculator: CalculateMetric<Record<string, number>>): void {
|
|
45
|
+
this.calculators.push(calculator)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
observe (values: Record<string, number>): void {
|
|
49
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
50
|
+
this.histogram.observe({ [this.label]: key }, value)
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
reset (): void {
|
|
55
|
+
this.histogram.reset()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
timer (key: string): StopTimer {
|
|
59
|
+
return this.histogram.startTimer({
|
|
60
|
+
[key]: 0
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/histogram.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type CollectFunction, Histogram as PromHistogram } from 'prom-client'
|
|
2
|
+
import { normaliseString } from './utils.js'
|
|
3
|
+
import type { PrometheusCalculatedHistogramOptions } from './index.js'
|
|
4
|
+
import type { StopTimer, CalculateMetric, Histogram } from '@libp2p/interface'
|
|
5
|
+
|
|
6
|
+
export class PrometheusHistogram implements Histogram {
|
|
7
|
+
private readonly histogram: PromHistogram
|
|
8
|
+
private readonly calculators: CalculateMetric[]
|
|
9
|
+
|
|
10
|
+
constructor (name: string, opts: PrometheusCalculatedHistogramOptions) {
|
|
11
|
+
name = normaliseString(name)
|
|
12
|
+
const help = normaliseString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normaliseString(opts.label)] : []
|
|
14
|
+
let collect: CollectFunction<PromHistogram<any>> | undefined
|
|
15
|
+
this.calculators = []
|
|
16
|
+
|
|
17
|
+
// calculated metric
|
|
18
|
+
if (opts?.calculate != null) {
|
|
19
|
+
this.calculators.push(opts.calculate)
|
|
20
|
+
const self = this
|
|
21
|
+
|
|
22
|
+
collect = async function () {
|
|
23
|
+
const values = await Promise.all(self.calculators.map(async calculate => calculate()))
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
this.observe(value)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.histogram = new PromHistogram({
|
|
31
|
+
name,
|
|
32
|
+
help,
|
|
33
|
+
buckets: opts.buckets ?? [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10],
|
|
34
|
+
labelNames: labels,
|
|
35
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
36
|
+
collect
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
addCalculator (calculator: CalculateMetric): void {
|
|
41
|
+
this.calculators.push(calculator)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
observe (value: number): void {
|
|
45
|
+
this.histogram.observe(value)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
reset (): void {
|
|
49
|
+
this.histogram.reset()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
timer (): StopTimer {
|
|
53
|
+
return this.histogram.startTimer()
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -71,12 +71,19 @@ import each from 'it-foreach'
|
|
|
71
71
|
import { collectDefaultMetrics, type DefaultMetricsCollectorConfiguration, register, type Registry, type RegistryContentType } from 'prom-client'
|
|
72
72
|
import { PrometheusCounterGroup } from './counter-group.js'
|
|
73
73
|
import { PrometheusCounter } from './counter.js'
|
|
74
|
+
import { PrometheusHistogramGroup } from './histogram-group.js'
|
|
75
|
+
import { PrometheusHistogram } from './histogram.js'
|
|
74
76
|
import { PrometheusMetricGroup } from './metric-group.js'
|
|
75
77
|
import { PrometheusMetric } from './metric.js'
|
|
76
|
-
import
|
|
78
|
+
import { PrometheusSummaryGroup } from './summary-group.js'
|
|
79
|
+
import { PrometheusSummary } from './summary.js'
|
|
80
|
+
import type { ComponentLogger, Logger, MultiaddrConnection, Stream, Connection, CalculatedMetricOptions, Counter, CounterGroup, Metric, MetricGroup, MetricOptions, Metrics, CalculatedHistogramOptions, CalculatedSummaryOptions, HistogramOptions, Histogram, HistogramGroup, SummaryOptions, Summary, SummaryGroup } from '@libp2p/interface'
|
|
77
81
|
import type { Duplex } from 'it-stream-types'
|
|
78
82
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
79
83
|
|
|
84
|
+
// export helper functions for creating buckets
|
|
85
|
+
export { linearBuckets, exponentialBuckets } from 'prom-client'
|
|
86
|
+
|
|
80
87
|
// prom-client metrics are global
|
|
81
88
|
const metrics = new Map<string, any>()
|
|
82
89
|
|
|
@@ -110,6 +117,14 @@ export interface PrometheusCalculatedMetricOptions<T=number> extends CalculatedM
|
|
|
110
117
|
registry?: Registry
|
|
111
118
|
}
|
|
112
119
|
|
|
120
|
+
export interface PrometheusCalculatedHistogramOptions<T=number> extends CalculatedHistogramOptions<T> {
|
|
121
|
+
registry?: Registry
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface PrometheusCalculatedSummaryOptions<T=number> extends CalculatedSummaryOptions<T> {
|
|
125
|
+
registry?: Registry
|
|
126
|
+
}
|
|
127
|
+
|
|
113
128
|
export interface PrometheusMetricsComponents {
|
|
114
129
|
logger: ComponentLogger
|
|
115
130
|
}
|
|
@@ -330,6 +345,122 @@ class PrometheusMetrics implements Metrics {
|
|
|
330
345
|
return counterGroup
|
|
331
346
|
}
|
|
332
347
|
}
|
|
348
|
+
|
|
349
|
+
registerHistogram (name: string, opts: PrometheusCalculatedHistogramOptions): void
|
|
350
|
+
registerHistogram (name: string, opts?: HistogramOptions): Histogram
|
|
351
|
+
registerHistogram (name: string, opts: any = {}): any {
|
|
352
|
+
if (name == null ?? name.trim() === '') {
|
|
353
|
+
throw new Error('Histogram name is required')
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let metric = metrics.get(name)
|
|
357
|
+
|
|
358
|
+
if (metrics.has(name)) {
|
|
359
|
+
this.log('Reuse existing histogram', name)
|
|
360
|
+
|
|
361
|
+
if (opts.calculate != null) {
|
|
362
|
+
metric.addCalculator(opts.calculate)
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return metrics.get(name)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
this.log('Register histogram', name)
|
|
369
|
+
metric = new PrometheusHistogram(name, { registry: this.registry, ...opts })
|
|
370
|
+
|
|
371
|
+
metrics.set(name, metric)
|
|
372
|
+
|
|
373
|
+
if (opts.calculate == null) {
|
|
374
|
+
return metric
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
registerHistogramGroup (name: string, opts: PrometheusCalculatedHistogramOptions<Record<string, number>>): void
|
|
379
|
+
registerHistogramGroup (name: string, opts?: HistogramOptions): HistogramGroup
|
|
380
|
+
registerHistogramGroup (name: string, opts: any = {}): any {
|
|
381
|
+
if (name == null ?? name.trim() === '') {
|
|
382
|
+
throw new Error('Histogram group name is required')
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
let metricGroup = metrics.get(name)
|
|
386
|
+
|
|
387
|
+
if (metricGroup != null) {
|
|
388
|
+
this.log('Reuse existing histogram group', name)
|
|
389
|
+
|
|
390
|
+
if (opts.calculate != null) {
|
|
391
|
+
metricGroup.addCalculator(opts.calculate)
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return metricGroup
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
this.log('Register histogram group', name)
|
|
398
|
+
metricGroup = new PrometheusHistogramGroup(name, { registry: this.registry, ...opts })
|
|
399
|
+
|
|
400
|
+
metrics.set(name, metricGroup)
|
|
401
|
+
|
|
402
|
+
if (opts.calculate == null) {
|
|
403
|
+
return metricGroup
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
registerSummary (name: string, opts: PrometheusCalculatedSummaryOptions): void
|
|
408
|
+
registerSummary (name: string, opts?: SummaryOptions): Summary
|
|
409
|
+
registerSummary (name: string, opts: any = {}): any {
|
|
410
|
+
if (name == null ?? name.trim() === '') {
|
|
411
|
+
throw new Error('Summary name is required')
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let metric = metrics.get(name)
|
|
415
|
+
|
|
416
|
+
if (metrics.has(name)) {
|
|
417
|
+
this.log('Reuse existing summary', name)
|
|
418
|
+
|
|
419
|
+
if (opts.calculate != null) {
|
|
420
|
+
metric.addCalculator(opts.calculate)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return metrics.get(name)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
this.log('Register summary', name)
|
|
427
|
+
metric = new PrometheusSummary(name, { registry: this.registry, ...opts })
|
|
428
|
+
|
|
429
|
+
metrics.set(name, metric)
|
|
430
|
+
|
|
431
|
+
if (opts.calculate == null) {
|
|
432
|
+
return metric
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
registerSummaryGroup (name: string, opts: PrometheusCalculatedSummaryOptions<Record<string, number>>): void
|
|
437
|
+
registerSummaryGroup (name: string, opts?: SummaryOptions): SummaryGroup
|
|
438
|
+
registerSummaryGroup (name: string, opts: any = {}): any {
|
|
439
|
+
if (name == null ?? name.trim() === '') {
|
|
440
|
+
throw new Error('Summary group name is required')
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
let metricGroup = metrics.get(name)
|
|
444
|
+
|
|
445
|
+
if (metricGroup != null) {
|
|
446
|
+
this.log('Reuse existing summary group', name)
|
|
447
|
+
|
|
448
|
+
if (opts.calculate != null) {
|
|
449
|
+
metricGroup.addCalculator(opts.calculate)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return metricGroup
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
this.log('Register summary group', name)
|
|
456
|
+
metricGroup = new PrometheusSummaryGroup(name, { registry: this.registry, ...opts })
|
|
457
|
+
|
|
458
|
+
metrics.set(name, metricGroup)
|
|
459
|
+
|
|
460
|
+
if (opts.calculate == null) {
|
|
461
|
+
return metricGroup
|
|
462
|
+
}
|
|
463
|
+
}
|
|
333
464
|
}
|
|
334
465
|
|
|
335
466
|
export function prometheusMetrics (init?: Partial<PrometheusMetricsInit>): (components: PrometheusMetricsComponents) => Metrics {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type CollectFunction, Summary as PromSummary } from 'prom-client'
|
|
2
|
+
import { normaliseString, type CalculatedMetric } from './utils.js'
|
|
3
|
+
import type { PrometheusCalculatedSummaryOptions } from './index.js'
|
|
4
|
+
import type { CalculateMetric, SummaryGroup, StopTimer } from '@libp2p/interface'
|
|
5
|
+
|
|
6
|
+
export class PrometheusSummaryGroup implements SummaryGroup, CalculatedMetric<Record<string, number>> {
|
|
7
|
+
private readonly summary: PromSummary
|
|
8
|
+
private readonly label: string
|
|
9
|
+
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
|
+
|
|
11
|
+
constructor (name: string, opts: PrometheusCalculatedSummaryOptions<Record<string, number>>) {
|
|
12
|
+
name = normaliseString(name)
|
|
13
|
+
const help = normaliseString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normaliseString(opts.label ?? name)
|
|
15
|
+
let collect: CollectFunction<PromSummary<any>> | undefined
|
|
16
|
+
this.calculators = []
|
|
17
|
+
|
|
18
|
+
// calculated metric
|
|
19
|
+
if (opts?.calculate != null) {
|
|
20
|
+
this.calculators.push(opts.calculate)
|
|
21
|
+
const self = this
|
|
22
|
+
|
|
23
|
+
collect = async function () {
|
|
24
|
+
await Promise.all(self.calculators.map(async calculate => {
|
|
25
|
+
const values = await calculate()
|
|
26
|
+
|
|
27
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
28
|
+
this.observe({ [label]: key }, value)
|
|
29
|
+
})
|
|
30
|
+
}))
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.summary = new PromSummary({
|
|
35
|
+
name,
|
|
36
|
+
help,
|
|
37
|
+
percentiles: opts.percentiles ?? [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999],
|
|
38
|
+
maxAgeSeconds: opts.maxAgeSeconds,
|
|
39
|
+
ageBuckets: opts.ageBuckets,
|
|
40
|
+
pruneAgedBuckets: opts.pruneAgedBuckets,
|
|
41
|
+
compressCount: opts.compressCount ?? 1000,
|
|
42
|
+
labelNames: [this.label],
|
|
43
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
44
|
+
collect
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
addCalculator (calculator: CalculateMetric<Record<string, number>>): void {
|
|
49
|
+
this.calculators.push(calculator)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
observe (values: Record<string, number>): void {
|
|
53
|
+
Object.entries(values).forEach(([key, value]) => {
|
|
54
|
+
this.summary.observe({ [this.label]: key }, value)
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
reset (): void {
|
|
59
|
+
this.summary.reset()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
timer (key: string): StopTimer {
|
|
63
|
+
return this.summary.startTimer({
|
|
64
|
+
[key]: 0
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/summary.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type CollectFunction, Summary as PromSummary } from 'prom-client'
|
|
2
|
+
import { normaliseString } from './utils.js'
|
|
3
|
+
import type { PrometheusCalculatedSummaryOptions } from './index.js'
|
|
4
|
+
import type { StopTimer, CalculateMetric, Summary } from '@libp2p/interface'
|
|
5
|
+
|
|
6
|
+
export class PrometheusSummary implements Summary {
|
|
7
|
+
private readonly summary: PromSummary
|
|
8
|
+
private readonly calculators: CalculateMetric[]
|
|
9
|
+
|
|
10
|
+
constructor (name: string, opts: PrometheusCalculatedSummaryOptions) {
|
|
11
|
+
name = normaliseString(name)
|
|
12
|
+
const help = normaliseString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normaliseString(opts.label)] : []
|
|
14
|
+
let collect: CollectFunction<PromSummary<any>> | undefined
|
|
15
|
+
this.calculators = []
|
|
16
|
+
|
|
17
|
+
// calculated metric
|
|
18
|
+
if (opts?.calculate != null) {
|
|
19
|
+
this.calculators.push(opts.calculate)
|
|
20
|
+
const self = this
|
|
21
|
+
|
|
22
|
+
collect = async function () {
|
|
23
|
+
const values = await Promise.all(self.calculators.map(async calculate => calculate()))
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
this.observe(value)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.summary = new PromSummary({
|
|
31
|
+
name,
|
|
32
|
+
help,
|
|
33
|
+
percentiles: opts.percentiles ?? [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999],
|
|
34
|
+
maxAgeSeconds: opts.maxAgeSeconds,
|
|
35
|
+
ageBuckets: opts.ageBuckets,
|
|
36
|
+
pruneAgedBuckets: opts.pruneAgedBuckets,
|
|
37
|
+
compressCount: opts.compressCount ?? 1000,
|
|
38
|
+
labelNames: labels,
|
|
39
|
+
registers: opts.registry !== undefined ? [opts.registry] : undefined,
|
|
40
|
+
collect
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
addCalculator (calculator: CalculateMetric): void {
|
|
45
|
+
this.calculators.push(calculator)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
observe (value: number): void {
|
|
49
|
+
this.summary.observe(value)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
reset (): void {
|
|
53
|
+
this.summary.reset()
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
timer (): StopTimer {
|
|
57
|
+
return this.summary.startTimer()
|
|
58
|
+
}
|
|
59
|
+
}
|