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 main loop prometheus gauge for liveness monitoring #86

Merged
merged 1 commit into from
May 22, 2024
Merged
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
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
Loading