Skip to content

Commit

Permalink
chore: Add tokio metrics to the app
Browse files Browse the repository at this point in the history
  • Loading branch information
klochowicz committed Aug 30, 2023
1 parent 80674f5 commit d6cefdd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion mobile/native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ serde_json = "1"
state = "0.5.3"
thiserror = "1"
time = { version = "0.3.20", features = ["formatting"] }
tokio = { version = "1.25.0", features = ["macros", "rt", "rt-multi-thread", "sync", "time"] }
tokio = { version = "1.25.0", features = ["macros", "rt", "rt-multi-thread", "sync", "time", "tracing"] }
tokio-metrics = "0.2.2"
tracing = "0.1.37"
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "env-filter", "time", "json"] }
trade = { path = "../../crates/trade" }
Expand Down
13 changes: 13 additions & 0 deletions mobile/native/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,19 @@ pub fn run(
config::set(config.clone());
db::init_db(&app_dir, get_network())?;
let runtime = ln_dlc::get_or_create_tokio_runtime()?;

// TODO: Hide this behind some debug flag, it shouldn't run in production
// (or maybe log once a minute in release build?)
let handle = runtime.handle();
let runtime_monitor = tokio_metrics::RuntimeMonitor::new(handle);
let frequency = Duration::from_secs(5);
runtime.spawn(async move {
for metrics in runtime_monitor.intervals() {
tracing::debug!(?metrics, "tokio metrics");
tokio::time::sleep(frequency).await;
}
});

ln_dlc::run(app_dir, seed_dir, runtime)?;

let (_health, tx) = health::Health::new(config, runtime);
Expand Down

0 comments on commit d6cefdd

Please sign in to comment.