Skip to content

Commit

Permalink
Install prometheus recorder earlier so kafka metrics work
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman committed Dec 19, 2024
1 parent 5381ef5 commit e1d1926
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 9 additions & 1 deletion crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ impl Node {

let config = self.updateable_config.pinned();

let prometheus_handle = if config.common.disable_prometheus {
None
} else {
Some(network_server::install_global_prometheus_recorder(
&config.common,
))
};

if let Some(metadata_store) = self.metadata_store_role {
tc.spawn(
TaskKind::MetadataStore,
Expand Down Expand Up @@ -431,7 +439,7 @@ impl Node {
TaskKind::RpcServer,
"node-rpc-server",
None,
self.server.run(config.common.clone()),
self.server.run(config.common.clone(), prometheus_handle),
)?;

Ok(())
Expand Down
1 change: 1 addition & 0 deletions crates/node/src/network_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ mod prometheus_helpers;
mod service;
mod state;

pub(crate) use metrics::install_global_prometheus_recorder;
pub use service::{AdminDependencies, NetworkServer, WorkerDependencies};
11 changes: 6 additions & 5 deletions crates/node/src/network_server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use restate_types::config::CommonOptions;
use crate::network_server::handler;
use crate::network_server::handler::cluster_ctrl::ClusterCtrlSvcHandler;
use crate::network_server::handler::node::NodeSvcHandler;
use crate::network_server::metrics::install_global_prometheus_recorder;
use crate::network_server::multiplex::MultiplexService;
use crate::network_server::state::NodeCtrlHandlerStateBuilder;

Expand All @@ -57,15 +56,17 @@ impl NetworkServer {
}
}

pub async fn run(self, options: CommonOptions) -> Result<(), anyhow::Error> {
pub async fn run(
self,
options: CommonOptions,
prometheus_handle: Option<metrics_exporter_prometheus::PrometheusHandle>,
) -> Result<(), anyhow::Error> {
let tc = task_center();
// Configure Metric Exporter
let mut state_builder = NodeCtrlHandlerStateBuilder::default();
state_builder.task_center(tc.clone());

if !options.disable_prometheus {
let prometheus_handle = install_global_prometheus_recorder(&options);

if let Some(prometheus_handle) = prometheus_handle {
tc.spawn_child(
TaskKind::SystemService,
"prometheus-metrics-upkeep",
Expand Down

0 comments on commit e1d1926

Please sign in to comment.