From b33a034e8062dce94cd2d6d6ba2da9d38404aa08 Mon Sep 17 00:00:00 2001 From: matthewkeil Date: Thu, 27 Jul 2023 02:25:12 -0400 Subject: [PATCH] feat(metrics): add eventName to network worker message metrics --- .../beacon-node/src/metrics/metrics/lodestar.ts | 3 ++- packages/beacon-node/src/network/core/metrics.ts | 3 ++- packages/beacon-node/src/util/workerEvents.ts | 14 ++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/beacon-node/src/metrics/metrics/lodestar.ts b/packages/beacon-node/src/metrics/metrics/lodestar.ts index 61983580f1c9..8b55faa83c55 100644 --- a/packages/beacon-node/src/metrics/metrics/lodestar.ts +++ b/packages/beacon-node/src/metrics/metrics/lodestar.ts @@ -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], }), diff --git a/packages/beacon-node/src/network/core/metrics.ts b/packages/beacon-node/src/network/core/metrics.ts index 2b0a4f81b0fd..7bddeafbe5c3 100644 --- a/packages/beacon-node/src/network/core/metrics.ts +++ b/packages/beacon-node/src/network/core/metrics.ts @@ -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], }), }; diff --git a/packages/beacon-node/src/util/workerEvents.ts b/packages/beacon-node/src/util/workerEvents.ts index 07cd915a4344..8eaf484a3fe0 100644 --- a/packages/beacon-node/src/util/workerEvents.ts +++ b/packages/beacon-node/src/util/workerEvents.ts @@ -42,8 +42,11 @@ export function wireEventsOnWorkerThread( ) { 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); } }); @@ -82,8 +85,11 @@ export function wireEventsOnMainThread( ) { 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); } });