Skip to content

Commit

Permalink
feat(metrics): add eventName to network worker message metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed Jul 27, 2023
1 parent dabfad4 commit b33a034
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/beacon-node/src/metrics/metrics/lodestar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ export function createLodestarMetrics(
help: "Current count of pending items in reqRespBridgeReqCaller data structure",
}),
},
networkWorkerWireEventsOnMainThreadLatencySec: register.histogram({
networkWorkerWireEventsOnMainThreadLatencySec: register.histogram<"eventName">({
name: "lodestar_network_worker_wire_events_on_main_thread_latency",
help: "Latency to transmit network events to main thread across worker port",
labelNames: ["eventName"],
buckets: [0.001, 0.003, 0.01, 0.03, 0.1],
}),

Expand Down
3 changes: 2 additions & 1 deletion packages/beacon-node/src/network/core/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ export function getNetworkCoreWorkerMetrics(register: RegistryMetricCreator) {
name: "lodestar_network_worker_reqresp_bridge_caller_pending_count",
help: "Current count of pending elements in respBridgeCaller",
}),
networkWorkerWireEventsOnWorkerThreadLatencySec: register.histogram({
networkWorkerWireEventsOnWorkerThreadLatencySec: register.histogram<"eventName">({
name: "lodestar_network_worker_wire_events_on_worker_thread_latency",
help: "Latency to transmit network events to worker thread across parent port",
labelNames: ["eventName"],
buckets: [0.001, 0.003, 0.01, 0.03, 0.1],
}),
};
Expand Down
14 changes: 10 additions & 4 deletions packages/beacon-node/src/util/workerEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export function wireEventsOnWorkerThread<EventData>(
) {
const [sec, nanoSec] = process.hrtime(data.posted);
const networkWorkerLatency = sec + nanoSec / 1e9;
metrics?.networkWorkerWireEventsOnWorkerThreadLatencySec.observe(networkWorkerLatency);
logger.debug("network worker message latency", networkWorkerLatency);
metrics?.networkWorkerWireEventsOnWorkerThreadLatencySec.observe(
{eventName: data.event as string},
networkWorkerLatency
);
logger.trace("network worker message latency", networkWorkerLatency);
events.emit(data.event, data.data);
}
});
Expand Down Expand Up @@ -82,8 +85,11 @@ export function wireEventsOnMainThread<EventData>(
) {
const [sec, nanoSec] = process.hrtime(data.posted);
const networkWorkerLatency = sec + nanoSec / 1e9;
metrics?.networkWorkerWireEventsOnMainThreadLatencySec.observe(networkWorkerLatency);
logger.debug("network worker message latency", networkWorkerLatency);
metrics?.networkWorkerWireEventsOnMainThreadLatencySec.observe(
{eventName: data.event as string},
networkWorkerLatency
);
logger.trace("network worker message latency", networkWorkerLatency);
events.emit(data.event, data.data);
}
});
Expand Down

0 comments on commit b33a034

Please sign in to comment.