Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ausias-armesto committed Sep 10, 2024
1 parent 47c59fb commit fbacd5a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Settings = {
intervalMs: number;
offsetMs: number;
metricLabels: { [key: string]: string };
metrics: {[key:string]: prom.Summary};
metrics: { [key: string]: prom.Summary };
};

// if this file is the entrypoint of the nodejs process
Expand Down Expand Up @@ -132,7 +132,7 @@ if (require.main === module) {
percentiles: [0.5, 0.7, 0.9, 0.99],
});

settings.metrics['hoprSum'] =new prom.Summary({
settings.metrics['hoprSum'] = new prom.Summary({
name: `uhttp_hopr_network_milliseconds`,
help: 'Estimated duration through the HOPR mixnet back and forth',
labelNames,
Expand All @@ -158,15 +158,17 @@ function start(uHTTPsettings: UHTTPsettings, settings: Settings) {

function tick(uClient: Routing.Client, uHTTPsettings: UHTTPsettings, settings: Settings) {
log.info('Executing latency tick - scheduled to execute every %dms', settings.intervalMs);
const hops = uHTTPsettings.forceZeroHop ? 0 : 1;
runner
.once(uClient, uHTTPsettings.rpcProvider)
.then(collectMetrics(settings.metrics, settings.metricLabels))
.catch(reportError(settings.metrics, settings.metricLabels))
.finally(pushMetrics(settings.pushGateway));
}

function collectMetrics(metrics: { [key: string]: prom.Summary }, metricLabels: { [key: string]: string }) {
function collectMetrics(
metrics: { [key: string]: prom.Summary },
metricLabels: { [key: string]: string },
) {
return function (metricsDurations: runner.Durations) {
metrics['fetchSum'].observe(metricLabels, metricsDurations.fetchDur);
metrics['rpcSum'].observe(metricLabels, metricsDurations.rpcDur);
Expand All @@ -176,7 +178,10 @@ function collectMetrics(metrics: { [key: string]: prom.Summary }, metricLabels:
};
}

function reportError(metrics: { [key: string]: prom.Summary }, metricLabels: { [key: string]: string }) {
function reportError(
metrics: { [key: string]: prom.Summary },
metricLabels: { [key: string]: string },
) {
return function (err: Error) {
log.error('Error trying to check latency: %s', err);
metrics['errorSum'].observe(metricLabels, 0);
Expand Down

0 comments on commit fbacd5a

Please sign in to comment.