Skip to content

Commit b31516c

Browse files
committed
feat: add monad_node_info metric with labels as OTEL resource attributes
1 parent 7797e97 commit b31516c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

monad-node/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ async fn run(node_state: NodeState, reload_handle: Box<dyn TracingReload>) -> Re
432432
network_name = node_state.node_config.network_name,
433433
node_name = node_state.node_config.node_name
434434
),
435+
node_state.node_config.network_name.clone(),
435436
record_metrics_interval,
436437
)
437438
.expect("failed to build otel monad-node");
@@ -772,6 +773,7 @@ fn resolve_domain_v4<P: PubKey>(node_id: &NodeId<P>, domain: &String) -> Option<
772773

773774
const GAUGE_TOTAL_UPTIME_US: &str = "monad.total_uptime_us";
774775
const GAUGE_STATE_TOTAL_UPDATE_US: &str = "monad.state.total_update_us";
776+
const GAUGE_NODE_INFO: &str = "monad_node_info";
775777

776778
fn send_metrics(
777779
meter: &opentelemetry::metrics::Meter,
@@ -781,6 +783,11 @@ fn send_metrics(
781783
process_start: &Instant,
782784
total_state_update_elapsed: &Duration,
783785
) {
786+
let node_info_gauge = gauge_cache
787+
.entry(GAUGE_NODE_INFO)
788+
.or_insert_with(|| meter.u64_gauge(GAUGE_NODE_INFO).build());
789+
node_info_gauge.record(1, &[]);
790+
784791
for (k, v) in state_metrics
785792
.metrics()
786793
.into_iter()
@@ -804,6 +811,7 @@ fn send_metrics(
804811
fn build_otel_meter_provider(
805812
otel_endpoint: &str,
806813
service_name: String,
814+
network_name: String,
807815
interval: Duration,
808816
) -> Result<opentelemetry_sdk::metrics::SdkMeterProvider, NodeSetupError> {
809817
let exporter = MetricExporter::builder()
@@ -829,6 +837,7 @@ fn build_otel_meter_provider(
829837
opentelemetry_semantic_conventions::resource::SERVICE_VERSION,
830838
CLIENT_VERSION,
831839
),
840+
opentelemetry::KeyValue::new("network", network_name),
832841
])
833842
.build(),
834843
);

0 commit comments

Comments
 (0)