Skip to content

Commit

Permalink
refactor(relay): Use follow-network instead of network in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kkirkov committed Sep 5, 2024
1 parent 3340204 commit f496e69
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion beacon-light-client/solidity/tasks/start-publishing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ task('start-publishing', 'Run relayer')
let networkName: string = '';
for (let i = 0; i < process.argv.length; i++) {
const arg = process.argv[i];
if (arg === '--network' && i + 1 < process.argv.length) {
if (arg === '--follow-network' && i + 1 < process.argv.length) {
networkName = process.argv[i + 1];
break;
}
Expand Down
19 changes: 12 additions & 7 deletions libs/typescript/ts-utils/prometheus-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const logger = getGenericLogger();

let network: string;

export function initPrometheusSetup(port?: number, curNetwork?: string) {
export function initPrometheusSetup(port?: number, curFollowNetwork?: string) {
const app = express();

if (!port) {
// Only for pollUpdates
port = 2999;
}
if (curNetwork) {
network = curNetwork;
if (curFollowNetwork) {
followNetwork = curFollowNetwork;
}

app.get('/metrics', async (req, res) => {
Expand Down Expand Up @@ -53,10 +53,15 @@ export async function prometheusTiming<T>(func: () => T, funcName: string) {
} finally {
const end = process.hrtime(start);
const durationSeconds = end[0] + end[1] / 1e9;
logger.info(
`Logging ${funcName} on ${network} - duration: ${durationSeconds}`,
);

if (network == undefined) {
logger.info(
`Executing method: ${funcName} with duration: ${durationSeconds}`,
);
} else {
logger.info(
`Executing method: ${funcName} on follow-network: ${followNetwork} with duration: ${durationSeconds}`,
);
}
if (functionExecutionTimeSummary) {
functionExecutionTimeSummary
.labels(funcName, network)
Expand Down

0 comments on commit f496e69

Please sign in to comment.