Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /health handler to node server #2462

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/node/src/network_server/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use std::fmt::Write;

use axum::extract::State;
use http::StatusCode;
use metrics_exporter_prometheus::formatting;
use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle};
use metrics_tracing_context::TracingContextLayer;
Expand Down Expand Up @@ -202,6 +203,10 @@ pub(crate) fn install_global_prometheus_recorder(opts: &CommonOptions) -> Promet
}

// -- Direct HTTP Handlers --
pub async fn report_health() -> StatusCode {
StatusCode::OK
}

pub async fn render_metrics(State(state): State<NodeCtrlHandlerState>) -> String {
let default_cf = CfName::new("default");
let mut out = String::new();
Expand Down
5 changes: 4 additions & 1 deletion crates/node/src/network_server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use tokio::time::MissedTickBehavior;
use tonic::codec::CompressionEncoding;
use tracing::{debug, trace};

use crate::network_server::metrics::{install_global_prometheus_recorder, render_metrics};
use crate::network_server::metrics::{
install_global_prometheus_recorder, render_metrics, report_health,
};
use crate::network_server::state::NodeCtrlHandlerStateBuilder;
use restate_core::network::protobuf::core_node_svc::core_node_svc_server::CoreNodeSvcServer;
use restate_core::network::protobuf::node_ctl_svc::node_ctl_svc_server::NodeCtlSvcServer;
Expand Down Expand Up @@ -80,6 +82,7 @@ impl NetworkServer {

// -- HTTP service (for prometheus et al.)
let axum_router = axum::Router::new()
.route("/health", get(report_health))
.route("/metrics", get(render_metrics))
.route("/debug/pprof/heap", get(pprof::heap))
.route(
Expand Down
Loading