Skip to content

Commit

Permalink
Add main loop prometheus gauge for liveness monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
philippem authored and shesek committed May 22, 2024
1 parent 24d34fe commit 5db7d2b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/bin/electrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use electrs::{

#[cfg(feature = "liquid")]
use electrs::elements::AssetRegistry;
use electrs::metrics::MetricOpts;

fn fetch_from(config: &Config, store: &Store) -> FetchFrom {
let mut jsonrpc_import = config.jsonrpc_import;
Expand Down Expand Up @@ -110,7 +111,15 @@ fn run_server(config: Arc<Config>) -> Result<()> {
let rest_server = rest::start(Arc::clone(&config), Arc::clone(&query));
let electrum_server = ElectrumRPC::start(Arc::clone(&config), Arc::clone(&query), &metrics);

let main_loop_count = metrics.gauge(MetricOpts::new(
"electrs_main_loop_count",
"count of iterations of electrs main loop each 5 seconds or after interrupts",
));

loop {

main_loop_count.inc();

if let Err(err) = signal.wait(Duration::from_secs(5), true) {
info!("stopping server: {}", err);
rest_server.stop();
Expand Down

0 comments on commit 5db7d2b

Please sign in to comment.