From 004c296795ebf379aa7b56e4e8b1a7f628c25425 Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 23 Oct 2023 20:22:25 +0200 Subject: [PATCH 1/2] Register metrics in new registry --- .../combiner/src/common/metrics.ts | 22 ++++++++++++++++++- .../combiner/src/server.ts | 5 ++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/phone-number-privacy/combiner/src/common/metrics.ts b/packages/phone-number-privacy/combiner/src/common/metrics.ts index b46e045c6..3dac80807 100644 --- a/packages/phone-number-privacy/combiner/src/common/metrics.ts +++ b/packages/phone-number-privacy/combiner/src/common/metrics.ts @@ -3,7 +3,7 @@ import { config } from '../config' const { Counter, Histogram } = client -const register = new client.Registry() +export const register = new client.Registry() register.setDefaultLabels({ app: config.serviceName, @@ -87,6 +87,19 @@ export const Counters = { }), } +register.registerMetric(Counters.requests) +register.registerMetric(Counters.responses) +register.registerMetric(Counters.errors) +register.registerMetric(Counters.blockchainErrors) +register.registerMetric(Counters.blsComputeErrors) +register.registerMetric(Counters.errorsCaughtInEndpointHandler) +register.registerMetric(Counters.notEnoughSigErrors) +register.registerMetric(Counters.sigRequestErrors) +register.registerMetric(Counters.sigInconsistenciesErrors) +register.registerMetric(Counters.sigResponses) +register.registerMetric(Counters.unknownErrors) +register.registerMetric(Counters.warnings) + const buckets = [0.001, 0.01, 0.1, 0.5, 1, 2, 5, 10] export const Histograms = { @@ -128,6 +141,13 @@ export const Histograms = { }), } +register.registerMetric(Histograms.responseLatency) +register.registerMetric(Histograms.fullNodeLatency) +register.registerMetric(Histograms.signerLatency) +register.registerMetric(Histograms.eventLoopLag) +register.registerMetric(Histograms.signatureAggregationLatency) +register.registerMetric(Histograms.signerTailLatency) + export function newMeter( histogram: client.Histogram, ...labels: string[] diff --git a/packages/phone-number-privacy/combiner/src/server.ts b/packages/phone-number-privacy/combiner/src/server.ts index 1348421e2..6c276a35f 100644 --- a/packages/phone-number-privacy/combiner/src/server.ts +++ b/packages/phone-number-privacy/combiner/src/server.ts @@ -10,7 +10,6 @@ import { import express, { RequestHandler } from 'express' import fs from 'fs' import https from 'https' -import * as PromClient from 'prom-client' import { Signer } from './common/combine' import { catchErrorHandler, @@ -21,7 +20,7 @@ import { ResultHandler, tracingHandler, } from './common/handlers' -import { Histograms } from './common/metrics' +import { Histograms, register } from './common/metrics' import { CombinerConfig, getCombinerVersion } from './config' import { disableDomain } from './domain/endpoints/disable/action' import { domainQuota } from './domain/endpoints/quota/action' @@ -109,7 +108,7 @@ export function startCombiner(config: CombinerConfig, kit?: ContractKit) { createHandler(domains.enabled, disableDomain(domainSigners, domains)) ) app.get(CombinerEndpoint.METRICS, (_req, res) => { - res.send(PromClient.register.metrics()) + res.send(register.metrics()) }) const sslOptions = getSslOptions(config) From a55409c83211b12e5432c3a52b51930ecced8f8a Mon Sep 17 00:00:00 2001 From: alvarof2 Date: Mon, 23 Oct 2023 20:24:24 +0200 Subject: [PATCH 2/2] Add changeset --- .changeset/healthy-gifts-hang.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/healthy-gifts-hang.md diff --git a/.changeset/healthy-gifts-hang.md b/.changeset/healthy-gifts-hang.md new file mode 100644 index 000000000..12645537d --- /dev/null +++ b/.changeset/healthy-gifts-hang.md @@ -0,0 +1,5 @@ +--- +'@celo/phone-number-privacy-combiner': patch +--- + +Include all metrics in new Prometheus register