@libp2p/prometheus-metrics 4.3.9 → 4.3.10
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/counter-group.js +4 -4
- package/dist/src/counter.js +4 -4
- package/dist/src/histogram-group.js +4 -4
- package/dist/src/histogram.js +4 -4
- package/dist/src/metric-group.js +4 -4
- package/dist/src/metric.js +4 -4
- package/dist/src/summary-group.js +4 -4
- package/dist/src/summary.js +4 -4
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.js +1 -1
- package/package.json +7 -7
- package/src/counter-group.ts +4 -4
- package/src/counter.ts +4 -4
- package/src/histogram-group.ts +4 -4
- package/src/histogram.ts +4 -4
- package/src/metric-group.ts +4 -4
- package/src/metric.ts +4 -4
- package/src/summary-group.ts +4 -4
- package/src/summary.ts +4 -4
- package/src/utils.ts +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Counter as PromCounter } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusCounterGroup {
|
|
4
4
|
counter;
|
|
5
5
|
label;
|
|
6
6
|
calculators;
|
|
7
7
|
constructor(name, opts) {
|
|
8
|
-
name =
|
|
9
|
-
const help =
|
|
10
|
-
const label = this.label =
|
|
8
|
+
name = normalizeString(name);
|
|
9
|
+
const help = normalizeString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normalizeString(opts.label ?? name);
|
|
11
11
|
let collect;
|
|
12
12
|
this.calculators = [];
|
|
13
13
|
// calculated metric
|
package/dist/src/counter.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Counter as PromCounter } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusCounter {
|
|
4
4
|
counter;
|
|
5
5
|
calculators;
|
|
6
6
|
constructor(name, opts) {
|
|
7
|
-
name =
|
|
8
|
-
const help =
|
|
9
|
-
const labels = opts.label != null ? [
|
|
7
|
+
name = normalizeString(name);
|
|
8
|
+
const help = normalizeString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : [];
|
|
10
10
|
let collect;
|
|
11
11
|
this.calculators = [];
|
|
12
12
|
// calculated metric
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Histogram as PromHistogram } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusHistogramGroup {
|
|
4
4
|
histogram;
|
|
5
5
|
label;
|
|
6
6
|
calculators;
|
|
7
7
|
constructor(name, opts) {
|
|
8
|
-
name =
|
|
9
|
-
const help =
|
|
10
|
-
const label = this.label =
|
|
8
|
+
name = normalizeString(name);
|
|
9
|
+
const help = normalizeString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normalizeString(opts.label ?? name);
|
|
11
11
|
let collect;
|
|
12
12
|
this.calculators = [];
|
|
13
13
|
// calculated metric
|
package/dist/src/histogram.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Histogram as PromHistogram } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusHistogram {
|
|
4
4
|
histogram;
|
|
5
5
|
calculators;
|
|
6
6
|
constructor(name, opts) {
|
|
7
|
-
name =
|
|
8
|
-
const help =
|
|
9
|
-
const labels = opts.label != null ? [
|
|
7
|
+
name = normalizeString(name);
|
|
8
|
+
const help = normalizeString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : [];
|
|
10
10
|
let collect;
|
|
11
11
|
this.calculators = [];
|
|
12
12
|
// calculated metric
|
package/dist/src/metric-group.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Gauge } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusMetricGroup {
|
|
4
4
|
gauge;
|
|
5
5
|
label;
|
|
6
6
|
calculators;
|
|
7
7
|
constructor(name, opts) {
|
|
8
|
-
name =
|
|
9
|
-
const help =
|
|
10
|
-
const label = this.label =
|
|
8
|
+
name = normalizeString(name);
|
|
9
|
+
const help = normalizeString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normalizeString(opts.label ?? name);
|
|
11
11
|
let collect;
|
|
12
12
|
this.calculators = [];
|
|
13
13
|
// calculated metric
|
package/dist/src/metric.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Gauge } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusMetric {
|
|
4
4
|
gauge;
|
|
5
5
|
calculators;
|
|
6
6
|
constructor(name, opts) {
|
|
7
|
-
name =
|
|
8
|
-
const help =
|
|
9
|
-
const labels = opts.label != null ? [
|
|
7
|
+
name = normalizeString(name);
|
|
8
|
+
const help = normalizeString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : [];
|
|
10
10
|
let collect;
|
|
11
11
|
this.calculators = [];
|
|
12
12
|
// calculated metric
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Summary as PromSummary } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusSummaryGroup {
|
|
4
4
|
summary;
|
|
5
5
|
label;
|
|
6
6
|
calculators;
|
|
7
7
|
constructor(name, opts) {
|
|
8
|
-
name =
|
|
9
|
-
const help =
|
|
10
|
-
const label = this.label =
|
|
8
|
+
name = normalizeString(name);
|
|
9
|
+
const help = normalizeString(opts.help ?? name);
|
|
10
|
+
const label = this.label = normalizeString(opts.label ?? name);
|
|
11
11
|
let collect;
|
|
12
12
|
this.calculators = [];
|
|
13
13
|
// calculated metric
|
package/dist/src/summary.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Summary as PromSummary } from 'prom-client';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js';
|
|
3
3
|
export class PrometheusSummary {
|
|
4
4
|
summary;
|
|
5
5
|
calculators;
|
|
6
6
|
constructor(name, opts) {
|
|
7
|
-
name =
|
|
8
|
-
const help =
|
|
9
|
-
const labels = opts.label != null ? [
|
|
7
|
+
name = normalizeString(name);
|
|
8
|
+
const help = normalizeString(opts.help ?? name);
|
|
9
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : [];
|
|
10
10
|
let collect;
|
|
11
11
|
this.calculators = [];
|
|
12
12
|
// calculated metric
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ export declare const ONE_MINUTE: number;
|
|
|
8
8
|
* See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
|
|
9
9
|
* for rules on valid naming
|
|
10
10
|
*/
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function normalizeString(str: string): string;
|
|
12
12
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ export const ONE_MINUTE = 60 * ONE_SECOND;
|
|
|
4
4
|
* See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
|
|
5
5
|
* for rules on valid naming
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function normalizeString(str) {
|
|
8
8
|
return str
|
|
9
9
|
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
10
10
|
.replace(/_+/g, '_');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/prometheus-metrics",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.10",
|
|
4
4
|
"description": "Collect libp2p metrics for scraping by Prometheus or Graphana",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -48,19 +48,19 @@
|
|
|
48
48
|
"test:electron-main": "aegir test -t electron-main --cov"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@libp2p/interface": "^2.6.
|
|
51
|
+
"@libp2p/interface": "^2.6.1",
|
|
52
52
|
"it-foreach": "^2.1.1",
|
|
53
53
|
"it-stream-types": "^2.0.2",
|
|
54
54
|
"prom-client": "^15.1.3",
|
|
55
55
|
"uint8arraylist": "^2.4.8"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@libp2p/crypto": "^5.0.
|
|
59
|
-
"@libp2p/interface-compliance-tests": "^6.3.
|
|
60
|
-
"@libp2p/logger": "^5.1.
|
|
61
|
-
"@libp2p/peer-id": "^5.0.
|
|
58
|
+
"@libp2p/crypto": "^5.0.13",
|
|
59
|
+
"@libp2p/interface-compliance-tests": "^6.3.5",
|
|
60
|
+
"@libp2p/logger": "^5.1.10",
|
|
61
|
+
"@libp2p/peer-id": "^5.0.14",
|
|
62
62
|
"@multiformats/multiaddr": "^12.3.3",
|
|
63
|
-
"aegir": "^45.
|
|
63
|
+
"aegir": "^45.1.1",
|
|
64
64
|
"it-drain": "^3.0.7",
|
|
65
65
|
"it-pipe": "^3.0.1",
|
|
66
66
|
"p-defer": "^4.0.1"
|
package/src/counter-group.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Counter as PromCounter, type CollectFunction } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString, type CalculatedMetric } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedMetricOptions } from './index.js'
|
|
4
4
|
import type { CounterGroup, CalculateMetric } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -9,9 +9,9 @@ export class PrometheusCounterGroup implements CounterGroup, CalculatedMetric<Re
|
|
|
9
9
|
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
10
|
|
|
11
11
|
constructor (name: string, opts: PrometheusCalculatedMetricOptions<Record<string, number>>) {
|
|
12
|
-
name =
|
|
13
|
-
const help =
|
|
14
|
-
const label = this.label =
|
|
12
|
+
name = normalizeString(name)
|
|
13
|
+
const help = normalizeString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normalizeString(opts.label ?? name)
|
|
15
15
|
let collect: CollectFunction<PromCounter<any>> | undefined
|
|
16
16
|
this.calculators = []
|
|
17
17
|
|
package/src/counter.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Counter as PromCounter } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString, type CalculatedMetric } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedMetricOptions } from './index.js'
|
|
4
4
|
import type { CalculateMetric, Counter } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -8,9 +8,9 @@ export class PrometheusCounter implements Counter, CalculatedMetric {
|
|
|
8
8
|
private readonly calculators: CalculateMetric[]
|
|
9
9
|
|
|
10
10
|
constructor (name: string, opts: PrometheusCalculatedMetricOptions) {
|
|
11
|
-
name =
|
|
12
|
-
const help =
|
|
13
|
-
const labels = opts.label != null ? [
|
|
11
|
+
name = normalizeString(name)
|
|
12
|
+
const help = normalizeString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : []
|
|
14
14
|
let collect: CollectFunction<PromCounter<any>> | undefined
|
|
15
15
|
this.calculators = []
|
|
16
16
|
|
package/src/histogram-group.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Histogram as PromHistogram } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString, type CalculatedMetric } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedHistogramOptions } from './index.js'
|
|
4
4
|
import type { CalculateMetric, HistogramGroup, StopTimer } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -9,9 +9,9 @@ export class PrometheusHistogramGroup implements HistogramGroup, CalculatedMetri
|
|
|
9
9
|
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
10
|
|
|
11
11
|
constructor (name: string, opts: PrometheusCalculatedHistogramOptions<Record<string, number>>) {
|
|
12
|
-
name =
|
|
13
|
-
const help =
|
|
14
|
-
const label = this.label =
|
|
12
|
+
name = normalizeString(name)
|
|
13
|
+
const help = normalizeString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normalizeString(opts.label ?? name)
|
|
15
15
|
let collect: CollectFunction<PromHistogram<any>> | undefined
|
|
16
16
|
this.calculators = []
|
|
17
17
|
|
package/src/histogram.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Histogram as PromHistogram } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedHistogramOptions } from './index.js'
|
|
4
4
|
import type { StopTimer, CalculateMetric, Histogram } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -8,9 +8,9 @@ export class PrometheusHistogram implements Histogram {
|
|
|
8
8
|
private readonly calculators: CalculateMetric[]
|
|
9
9
|
|
|
10
10
|
constructor (name: string, opts: PrometheusCalculatedHistogramOptions) {
|
|
11
|
-
name =
|
|
12
|
-
const help =
|
|
13
|
-
const labels = opts.label != null ? [
|
|
11
|
+
name = normalizeString(name)
|
|
12
|
+
const help = normalizeString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : []
|
|
14
14
|
let collect: CollectFunction<PromHistogram<any>> | undefined
|
|
15
15
|
this.calculators = []
|
|
16
16
|
|
package/src/metric-group.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Gauge } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString, type CalculatedMetric } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedMetricOptions } from './index.js'
|
|
4
4
|
import type { CalculateMetric, MetricGroup, StopTimer } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -9,9 +9,9 @@ export class PrometheusMetricGroup implements MetricGroup, CalculatedMetric<Reco
|
|
|
9
9
|
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
10
|
|
|
11
11
|
constructor (name: string, opts: PrometheusCalculatedMetricOptions<Record<string, number>>) {
|
|
12
|
-
name =
|
|
13
|
-
const help =
|
|
14
|
-
const label = this.label =
|
|
12
|
+
name = normalizeString(name)
|
|
13
|
+
const help = normalizeString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normalizeString(opts.label ?? name)
|
|
15
15
|
let collect: CollectFunction<Gauge<any>> | undefined
|
|
16
16
|
this.calculators = []
|
|
17
17
|
|
package/src/metric.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Gauge } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedMetricOptions } from './index.js'
|
|
4
4
|
import type { Metric, StopTimer, CalculateMetric } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -8,9 +8,9 @@ export class PrometheusMetric implements Metric {
|
|
|
8
8
|
private readonly calculators: CalculateMetric[]
|
|
9
9
|
|
|
10
10
|
constructor (name: string, opts: PrometheusCalculatedMetricOptions) {
|
|
11
|
-
name =
|
|
12
|
-
const help =
|
|
13
|
-
const labels = opts.label != null ? [
|
|
11
|
+
name = normalizeString(name)
|
|
12
|
+
const help = normalizeString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : []
|
|
14
14
|
let collect: CollectFunction<Gauge<any>> | undefined
|
|
15
15
|
this.calculators = []
|
|
16
16
|
|
package/src/summary-group.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Summary as PromSummary } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString, type CalculatedMetric } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedSummaryOptions } from './index.js'
|
|
4
4
|
import type { CalculateMetric, SummaryGroup, StopTimer } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -9,9 +9,9 @@ export class PrometheusSummaryGroup implements SummaryGroup, CalculatedMetric<Re
|
|
|
9
9
|
private readonly calculators: Array<CalculateMetric<Record<string, number>>>
|
|
10
10
|
|
|
11
11
|
constructor (name: string, opts: PrometheusCalculatedSummaryOptions<Record<string, number>>) {
|
|
12
|
-
name =
|
|
13
|
-
const help =
|
|
14
|
-
const label = this.label =
|
|
12
|
+
name = normalizeString(name)
|
|
13
|
+
const help = normalizeString(opts.help ?? name)
|
|
14
|
+
const label = this.label = normalizeString(opts.label ?? name)
|
|
15
15
|
let collect: CollectFunction<PromSummary<any>> | undefined
|
|
16
16
|
this.calculators = []
|
|
17
17
|
|
package/src/summary.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CollectFunction, Summary as PromSummary } from 'prom-client'
|
|
2
|
-
import {
|
|
2
|
+
import { normalizeString } from './utils.js'
|
|
3
3
|
import type { PrometheusCalculatedSummaryOptions } from './index.js'
|
|
4
4
|
import type { StopTimer, CalculateMetric, Summary } from '@libp2p/interface'
|
|
5
5
|
|
|
@@ -8,9 +8,9 @@ export class PrometheusSummary implements Summary {
|
|
|
8
8
|
private readonly calculators: CalculateMetric[]
|
|
9
9
|
|
|
10
10
|
constructor (name: string, opts: PrometheusCalculatedSummaryOptions) {
|
|
11
|
-
name =
|
|
12
|
-
const help =
|
|
13
|
-
const labels = opts.label != null ? [
|
|
11
|
+
name = normalizeString(name)
|
|
12
|
+
const help = normalizeString(opts.help ?? name)
|
|
13
|
+
const labels = opts.label != null ? [normalizeString(opts.label)] : []
|
|
14
14
|
let collect: CollectFunction<PromSummary<any>> | undefined
|
|
15
15
|
this.calculators = []
|
|
16
16
|
|
package/src/utils.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const ONE_MINUTE = 60 * ONE_SECOND
|
|
|
11
11
|
* See https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels
|
|
12
12
|
* for rules on valid naming
|
|
13
13
|
*/
|
|
14
|
-
export function
|
|
14
|
+
export function normalizeString (str: string): string {
|
|
15
15
|
return str
|
|
16
16
|
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
17
17
|
.replace(/_+/g, '_')
|