Skip to content

Commit

Permalink
Fix missing builder streamTime metric (#5257)
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech authored Mar 10, 2023
1 parent 9c7c08b commit 27feb58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 2 additions & 5 deletions packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {getClient, Api as BuilderApi} from "@lodestar/api/builder";
import {byteArrayEquals, toHexString} from "@chainsafe/ssz";
import {SLOTS_PER_EPOCH} from "@lodestar/params";

import {ApiError, Metrics as ApiMetrics} from "@lodestar/api";
import {ApiError} from "@lodestar/api";
import {validateBlobsAndKzgCommitments} from "../../chain/produceBlock/validateBlobsAndKzgCommitments.js";
import {Metrics} from "../../metrics/metrics.js";
import {IExecutionBuilder} from "./interface.js";
Expand Down Expand Up @@ -38,10 +38,7 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
constructor(opts: ExecutionBuilderHttpOpts, config: ChainForkConfig, metrics: Metrics | null = null) {
const baseUrl = opts.urls[0];
if (!baseUrl) throw Error("No Url provided for executionBuilder");
this.api = getClient(
{baseUrl, timeoutMs: opts.timeout},
{config, metrics: metrics?.builderHttpClient as ApiMetrics | undefined}
);
this.api = getClient({baseUrl, timeoutMs: opts.timeout}, {config, metrics: metrics?.builderHttpClient});
this.config = config;
this.issueLocalFcUForBlockProduction = opts.issueLocalFcUForBlockProduction;

Expand Down
4 changes: 3 additions & 1 deletion packages/beacon-node/src/metrics/interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {Gauge, Histogram} from "prom-client";

type CollectFn<T extends string> = (metric: IGauge<T>) => void;

export type IGauge<T extends string = string> = Pick<Gauge<T>, "inc" | "dec" | "set"> & {
addCollect: (collectFn: () => void) => void;
addCollect: (collectFn: CollectFn<T>) => void;
};

export type IHistogram<T extends string = string> = Pick<Histogram<T>, "observe" | "startTimer">;
Expand Down
9 changes: 7 additions & 2 deletions packages/beacon-node/src/metrics/metrics/lodestar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1427,13 +1427,18 @@ export function createLodestarMetrics(
// Expected times are ~ 50-500ms, but in an overload NodeJS they can be greater
buckets: [0.01, 0.1, 1, 5],
}),

streamTime: register.histogram<"routeId">({
name: "vc_builder_http_client_stream_time_seconds",
help: "Builder api - streaming time by routeId",
labelNames: ["routeId"],
// Provide max resolution on problematic values around 1 second
buckets: [0.1, 0.5, 1, 2, 5, 15],
}),
requestErrors: register.gauge<"routeId">({
name: "vc_builder_http_client_request_errors_total",
help: "Total count of errors on builder http client requests by routeId",
labelNames: ["routeId"],
}),

requestToFallbacks: register.gauge<"routeId">({
name: "vc_builder_http_client_request_to_fallbacks_total",
help: "Total count of requests to fallback URLs on builder http API by routeId",
Expand Down

0 comments on commit 27feb58

Please sign in to comment.