@chainsafe/lodestar 1.47.0-dev.a16fc189fa → 1.47.0-dev.a64cdf7144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.git-data.json +1 -1
- package/lib/cmds/builder/handler.d.ts.map +1 -1
- package/lib/cmds/builder/handler.js +15 -2
- package/lib/cmds/builder/handler.js.map +1 -1
- package/lib/cmds/builder/options.d.ts +8 -0
- package/lib/cmds/builder/options.d.ts.map +1 -1
- package/lib/cmds/builder/options.js +24 -0
- package/lib/cmds/builder/options.js.map +1 -1
- package/package.json +14 -14
- package/src/cmds/builder/handler.ts +19 -3
- package/src/cmds/builder/options.ts +33 -0
package/.git-data.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAKlD,OAAO,EAAC,eAAe,EAA+B,MAAM,cAAc,CAAC;AAI3E,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEtF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { getClient } from "@lodestar/api";
|
|
3
|
-
import {
|
|
3
|
+
import { RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer } from "@lodestar/beacon-node";
|
|
4
|
+
import { Builder, getMetrics } from "@lodestar/builder";
|
|
4
5
|
import { getNodeLogger } from "@lodestar/logger/node";
|
|
5
6
|
import { fromHex, toPrintableUrl } from "@lodestar/utils";
|
|
6
7
|
import { getBeaconConfigFromArgs } from "../../config/beaconParams.js";
|
|
@@ -8,6 +9,7 @@ import { getGlobalPaths } from "../../paths/global.js";
|
|
|
8
9
|
import { cleanOldLogFiles, onGracefulShutdown, parseFeeRecipient, parseLoggerArgs } from "../../util/index.js";
|
|
9
10
|
import { getVersionData } from "../../util/version.js";
|
|
10
11
|
import { loadBuilderKeypair } from "./loadKeypair.js";
|
|
12
|
+
import { builderMetricsDefaultOptions } from "./options.js";
|
|
11
13
|
const ZERO_ADDRESS = "0x" + "0".repeat(40);
|
|
12
14
|
export async function builderHandler(args) {
|
|
13
15
|
const { config, network } = getBeaconConfigFromArgs(args);
|
|
@@ -37,7 +39,17 @@ export async function builderHandler(args) {
|
|
|
37
39
|
}, logger.info.bind(logger));
|
|
38
40
|
const abortController = new AbortController();
|
|
39
41
|
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
40
|
-
const
|
|
42
|
+
const register = args.metrics ? new RegistryMetricCreator() : null;
|
|
43
|
+
const metrics = register && getMetrics(register, { version, commit, network });
|
|
44
|
+
if (metrics) {
|
|
45
|
+
const closeMetrics = collectNodeJSMetrics(register);
|
|
46
|
+
onGracefulShutdownCbs.push(() => closeMetrics());
|
|
47
|
+
const port = args["metrics.port"] ?? builderMetricsDefaultOptions.port;
|
|
48
|
+
const address = args["metrics.address"] ?? builderMetricsDefaultOptions.address;
|
|
49
|
+
const metricsServer = await getHttpMetricsServer({ port, address }, { register, logger });
|
|
50
|
+
onGracefulShutdownCbs.push(() => metricsServer.close());
|
|
51
|
+
}
|
|
52
|
+
const api = getClient({ urls: [args.beaconNodeUrl], globalInit: { signal: abortController.signal, timeoutMs: args.requestTimeout } }, { config, logger, metrics: metrics?.restApiClient });
|
|
41
53
|
logger.info("Beacon node", { beaconNode: toPrintableUrl(args.beaconNodeUrl), timeoutMs: args.requestTimeout });
|
|
42
54
|
const builder = await Builder.init({
|
|
43
55
|
keypair,
|
|
@@ -46,6 +58,7 @@ export async function builderHandler(args) {
|
|
|
46
58
|
abortController,
|
|
47
59
|
api,
|
|
48
60
|
executionFeeRecipient: fromHex(executionFeeRecipient),
|
|
61
|
+
metrics,
|
|
49
62
|
});
|
|
50
63
|
onGracefulShutdownCbs.push(() => builder.close());
|
|
51
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../src/cmds/builder/handler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AACxC,OAAO,EAAC,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAC,OAAO,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,8BAA8B,CAAC;AAErE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAkB,4BAA4B,EAAC,MAAM,cAAc,CAAC;AAE3E,MAAM,YAAY,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAkC;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AS,EAAE,IAAI,CAAC,cAAc,EAAC,EAAC,EAC1G,EAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAC,CAClD,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAC,UAAU,EAAE,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,cAAc,EAAC,CAAC,CAAC;IAE7G,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;QACjC,OAAO;QACP,MAAM;QACN,MAAM;QACN,eAAe;QACf,GAAG;QACH,qBAAqB,EAAE,OAAO,CAAC,qBAAqB,CAAC;QACrD,OAAO;KACR,CAAC,CAAC;IAEH,qBAAqB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { CliCommandOptions } from "@lodestar/utils";
|
|
2
2
|
import { LogArgs } from "../../options/logOptions.js";
|
|
3
|
+
export declare const builderMetricsDefaultOptions: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
port: number;
|
|
6
|
+
address: string;
|
|
7
|
+
};
|
|
3
8
|
export type IBuilderCliArgs = LogArgs & {
|
|
4
9
|
beaconNodeUrl: string;
|
|
5
10
|
keystore: string;
|
|
@@ -7,6 +12,9 @@ export type IBuilderCliArgs = LogArgs & {
|
|
|
7
12
|
builderPubkey?: string;
|
|
8
13
|
executionFeeRecipient: string;
|
|
9
14
|
requestTimeout: number;
|
|
15
|
+
metrics?: boolean;
|
|
16
|
+
"metrics.port"?: number;
|
|
17
|
+
"metrics.address"?: string;
|
|
10
18
|
};
|
|
11
19
|
export declare const builderOptions: CliCommandOptions<IBuilderCliArgs>;
|
|
12
20
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAa,MAAM,6BAA6B,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAa,MAAM,6BAA6B,CAAC;AAEhE,eAAO,MAAM,4BAA4B;IACvC,OAAO;IACP,IAAI;IACJ,OAAO;CACR,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,eAAe,CA4D7D,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { defaultOptions } from "@lodestar/builder";
|
|
2
2
|
import { logOptions } from "../../options/logOptions.js";
|
|
3
|
+
export const builderMetricsDefaultOptions = {
|
|
4
|
+
enabled: false,
|
|
5
|
+
port: 5065,
|
|
6
|
+
address: "127.0.0.1",
|
|
7
|
+
};
|
|
3
8
|
export const builderOptions = {
|
|
4
9
|
...logOptions,
|
|
5
10
|
beaconNodeUrl: {
|
|
@@ -31,5 +36,24 @@ export const builderOptions = {
|
|
|
31
36
|
type: "number",
|
|
32
37
|
default: defaultOptions.requestTimeout,
|
|
33
38
|
},
|
|
39
|
+
// Metrics
|
|
40
|
+
metrics: {
|
|
41
|
+
description: "Enable the Prometheus metrics HTTP server",
|
|
42
|
+
type: "boolean",
|
|
43
|
+
defaultDescription: String(builderMetricsDefaultOptions.enabled),
|
|
44
|
+
group: "metrics",
|
|
45
|
+
},
|
|
46
|
+
"metrics.port": {
|
|
47
|
+
description: "Listen TCP port for the Prometheus metrics HTTP server",
|
|
48
|
+
type: "number",
|
|
49
|
+
defaultDescription: String(builderMetricsDefaultOptions.port),
|
|
50
|
+
group: "metrics",
|
|
51
|
+
},
|
|
52
|
+
"metrics.address": {
|
|
53
|
+
description: "Listen address for the Prometheus metrics HTTP server",
|
|
54
|
+
type: "string",
|
|
55
|
+
defaultDescription: String(builderMetricsDefaultOptions.address),
|
|
56
|
+
group: "metrics",
|
|
57
|
+
},
|
|
34
58
|
};
|
|
35
59
|
//# sourceMappingURL=options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAU,UAAU,EAAC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/cmds/builder/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAU,UAAU,EAAC,MAAM,6BAA6B,CAAC;AAEhE,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,OAAO,EAAE,KA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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainsafe/lodestar",
|
|
3
|
-
"version": "1.47.0-dev.
|
|
3
|
+
"version": "1.47.0-dev.a64cdf7144",
|
|
4
4
|
"description": "Command line interface for lodestar",
|
|
5
5
|
"author": "ChainSafe Systems",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"@libp2p/crypto": "^5.1.13",
|
|
69
69
|
"@libp2p/interface": "^3.1.0",
|
|
70
70
|
"@libp2p/peer-id": "^6.0.4",
|
|
71
|
-
"@lodestar/api": "^1.47.0-dev.
|
|
72
|
-
"@lodestar/beacon-node": "^1.47.0-dev.
|
|
73
|
-
"@lodestar/builder": "^1.47.0-dev.
|
|
74
|
-
"@lodestar/config": "^1.47.0-dev.
|
|
75
|
-
"@lodestar/db": "^1.47.0-dev.
|
|
76
|
-
"@lodestar/logger": "^1.47.0-dev.
|
|
77
|
-
"@lodestar/params": "^1.47.0-dev.
|
|
78
|
-
"@lodestar/state-transition": "^1.47.0-dev.
|
|
79
|
-
"@lodestar/types": "^1.47.0-dev.
|
|
80
|
-
"@lodestar/utils": "^1.47.0-dev.
|
|
81
|
-
"@lodestar/validator": "^1.47.0-dev.
|
|
71
|
+
"@lodestar/api": "^1.47.0-dev.a64cdf7144",
|
|
72
|
+
"@lodestar/beacon-node": "^1.47.0-dev.a64cdf7144",
|
|
73
|
+
"@lodestar/builder": "^1.47.0-dev.a64cdf7144",
|
|
74
|
+
"@lodestar/config": "^1.47.0-dev.a64cdf7144",
|
|
75
|
+
"@lodestar/db": "^1.47.0-dev.a64cdf7144",
|
|
76
|
+
"@lodestar/logger": "^1.47.0-dev.a64cdf7144",
|
|
77
|
+
"@lodestar/params": "^1.47.0-dev.a64cdf7144",
|
|
78
|
+
"@lodestar/state-transition": "^1.47.0-dev.a64cdf7144",
|
|
79
|
+
"@lodestar/types": "^1.47.0-dev.a64cdf7144",
|
|
80
|
+
"@lodestar/utils": "^1.47.0-dev.a64cdf7144",
|
|
81
|
+
"@lodestar/validator": "^1.47.0-dev.a64cdf7144",
|
|
82
82
|
"@multiformats/multiaddr": "^13.0.1",
|
|
83
83
|
"deepmerge": "^4.3.1",
|
|
84
84
|
"ethers": "^6.7.0",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@chainsafe/as-sha256": "^1.2.4",
|
|
96
96
|
"@ethereumjs/rlp": "^4.0.1",
|
|
97
|
-
"@lodestar/test-utils": "^1.47.0-dev.
|
|
97
|
+
"@lodestar/test-utils": "^1.47.0-dev.a64cdf7144",
|
|
98
98
|
"@types/debug": "^4.1.7",
|
|
99
99
|
"@types/inquirer": "^9.0.3",
|
|
100
100
|
"@types/js-yaml": "^4.0.5",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"web3": "^4.0.3",
|
|
109
109
|
"web3-eth-accounts": "^4.0.3"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "d460386e8f2c111c430f090b2d91e720e34067f8"
|
|
112
112
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import {getClient} from "@lodestar/api";
|
|
3
|
-
import {
|
|
3
|
+
import {RegistryMetricCreator, collectNodeJSMetrics, getHttpMetricsServer} from "@lodestar/beacon-node";
|
|
4
|
+
import {Builder, getMetrics} from "@lodestar/builder";
|
|
4
5
|
import {getNodeLogger} from "@lodestar/logger/node";
|
|
5
6
|
import {fromHex, toPrintableUrl} from "@lodestar/utils";
|
|
6
7
|
import {getBeaconConfigFromArgs} from "../../config/beaconParams.js";
|
|
@@ -9,7 +10,7 @@ import {getGlobalPaths} from "../../paths/global.js";
|
|
|
9
10
|
import {cleanOldLogFiles, onGracefulShutdown, parseFeeRecipient, parseLoggerArgs} from "../../util/index.js";
|
|
10
11
|
import {getVersionData} from "../../util/version.js";
|
|
11
12
|
import {loadBuilderKeypair} from "./loadKeypair.js";
|
|
12
|
-
import {IBuilderCliArgs} from "./options.js";
|
|
13
|
+
import {IBuilderCliArgs, builderMetricsDefaultOptions} from "./options.js";
|
|
13
14
|
|
|
14
15
|
const ZERO_ADDRESS = "0x" + "0".repeat(40);
|
|
15
16
|
|
|
@@ -49,9 +50,23 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
|
|
|
49
50
|
const abortController = new AbortController();
|
|
50
51
|
onGracefulShutdownCbs.push(async () => abortController.abort());
|
|
51
52
|
|
|
53
|
+
const register = args.metrics ? new RegistryMetricCreator() : null;
|
|
54
|
+
const metrics = register && getMetrics(register, {version, commit, network});
|
|
55
|
+
|
|
56
|
+
if (metrics) {
|
|
57
|
+
const closeMetrics = collectNodeJSMetrics(register);
|
|
58
|
+
onGracefulShutdownCbs.push(() => closeMetrics());
|
|
59
|
+
|
|
60
|
+
const port = args["metrics.port"] ?? builderMetricsDefaultOptions.port;
|
|
61
|
+
const address = args["metrics.address"] ?? builderMetricsDefaultOptions.address;
|
|
62
|
+
const metricsServer = await getHttpMetricsServer({port, address}, {register, logger});
|
|
63
|
+
|
|
64
|
+
onGracefulShutdownCbs.push(() => metricsServer.close());
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
const api = getClient(
|
|
53
68
|
{urls: [args.beaconNodeUrl], globalInit: {signal: abortController.signal, timeoutMs: args.requestTimeout}},
|
|
54
|
-
{config, logger}
|
|
69
|
+
{config, logger, metrics: metrics?.restApiClient}
|
|
55
70
|
);
|
|
56
71
|
|
|
57
72
|
logger.info("Beacon node", {beaconNode: toPrintableUrl(args.beaconNodeUrl), timeoutMs: args.requestTimeout});
|
|
@@ -63,6 +78,7 @@ export async function builderHandler(args: IBuilderCliArgs & GlobalArgs): Promis
|
|
|
63
78
|
abortController,
|
|
64
79
|
api,
|
|
65
80
|
executionFeeRecipient: fromHex(executionFeeRecipient),
|
|
81
|
+
metrics,
|
|
66
82
|
});
|
|
67
83
|
|
|
68
84
|
onGracefulShutdownCbs.push(() => builder.close());
|
|
@@ -2,6 +2,12 @@ import {defaultOptions} from "@lodestar/builder";
|
|
|
2
2
|
import {CliCommandOptions} from "@lodestar/utils";
|
|
3
3
|
import {LogArgs, logOptions} from "../../options/logOptions.js";
|
|
4
4
|
|
|
5
|
+
export const builderMetricsDefaultOptions = {
|
|
6
|
+
enabled: false,
|
|
7
|
+
port: 5065,
|
|
8
|
+
address: "127.0.0.1",
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
export type IBuilderCliArgs = LogArgs & {
|
|
6
12
|
beaconNodeUrl: string;
|
|
7
13
|
keystore: string;
|
|
@@ -9,6 +15,10 @@ export type IBuilderCliArgs = LogArgs & {
|
|
|
9
15
|
builderPubkey?: string;
|
|
10
16
|
executionFeeRecipient: string;
|
|
11
17
|
requestTimeout: number;
|
|
18
|
+
|
|
19
|
+
metrics?: boolean;
|
|
20
|
+
"metrics.port"?: number;
|
|
21
|
+
"metrics.address"?: string;
|
|
12
22
|
};
|
|
13
23
|
|
|
14
24
|
export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
|
|
@@ -48,4 +58,27 @@ export const builderOptions: CliCommandOptions<IBuilderCliArgs> = {
|
|
|
48
58
|
type: "number",
|
|
49
59
|
default: defaultOptions.requestTimeout,
|
|
50
60
|
},
|
|
61
|
+
|
|
62
|
+
// Metrics
|
|
63
|
+
|
|
64
|
+
metrics: {
|
|
65
|
+
description: "Enable the Prometheus metrics HTTP server",
|
|
66
|
+
type: "boolean",
|
|
67
|
+
defaultDescription: String(builderMetricsDefaultOptions.enabled),
|
|
68
|
+
group: "metrics",
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
"metrics.port": {
|
|
72
|
+
description: "Listen TCP port for the Prometheus metrics HTTP server",
|
|
73
|
+
type: "number",
|
|
74
|
+
defaultDescription: String(builderMetricsDefaultOptions.port),
|
|
75
|
+
group: "metrics",
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
"metrics.address": {
|
|
79
|
+
description: "Listen address for the Prometheus metrics HTTP server",
|
|
80
|
+
type: "string",
|
|
81
|
+
defaultDescription: String(builderMetricsDefaultOptions.address),
|
|
82
|
+
group: "metrics",
|
|
83
|
+
},
|
|
51
84
|
};
|