Skip to content

Commit

Permalink
Merge pull request #111 from celo-org/alvarof/metrics-port
Browse files Browse the repository at this point in the history
Adds metrics to new registry
  • Loading branch information
alecps authored Oct 23, 2023
2 parents 101ea6c + 3681fe7 commit 0dd0583
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-gifts-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@celo/phone-number-privacy-combiner': patch
---

Include all metrics in new Prometheus register
22 changes: 21 additions & 1 deletion packages/phone-number-privacy/combiner/src/common/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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<string>,
...labels: string[]
Expand Down
5 changes: 2 additions & 3 deletions packages/phone-number-privacy/combiner/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0dd0583

Please sign in to comment.