Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds metrics to new registry #111

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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