Skip to content

Commit 48a3c65

Browse files
committed
feat: Introduce service_is_healthy metric
1 parent 38f205c commit 48a3c65

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/heartbeat.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::config::Config;
33
use crate::grpc::protobuf::uniffle::coordinator_server_client::CoordinatorServerClient;
44
use crate::grpc::protobuf::uniffle::{ShuffleServerHeartBeatRequest, ShuffleServerId};
55
use crate::health_service::HealthService;
6+
use crate::metric::SERVICE_IS_HEALTHY;
67
use crate::runtime::manager::RuntimeManager;
78
use log::info;
89
use std::time::Duration;
@@ -58,6 +59,8 @@ impl HeartbeatTask {
5859
all_tags.extend_from_slice(&*tags);
5960

6061
let healthy = health_service.is_healthy().await.unwrap_or(false);
62+
SERVICE_IS_HEALTHY.set(if healthy { 0 } else { 1 });
63+
6164
let memory_snapshot = app_manager
6265
.store_memory_snapshot()
6366
.await

src/metric.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ pub static GAUGE_LOCAL_DISK_IS_HEALTHY: Lazy<IntGaugeVec> = Lazy::new(|| {
398398
.unwrap()
399399
});
400400

401+
pub static SERVICE_IS_HEALTHY: Lazy<IntGauge> =
402+
Lazy::new(|| IntGauge::new("service_is_healthy", "service_is_healthy").expect(""));
403+
401404
pub static GAUGE_RUNTIME_ALIVE_THREAD_NUM: Lazy<IntGaugeVec> = Lazy::new(|| {
402405
register_int_gauge_vec!(
403406
"runtime_thread_alive_gauge",
@@ -520,6 +523,9 @@ pub static EVENT_BUS_HANDLE_DURATION: Lazy<HistogramVec> = Lazy::new(|| {
520523
});
521524

522525
fn register_custom_metrics() {
526+
REGISTRY
527+
.register(Box::new(SERVICE_IS_HEALTHY.clone()))
528+
.expect("");
523529
REGISTRY
524530
.register(Box::new(GAUGE_MEMORY_SPILL_IN_QUEUE_BYTES.clone()))
525531
.expect("");

0 commit comments

Comments
 (0)