Skip to content

Commit

Permalink
feat(tracing): using tracing and zenoh-util log init (#204)
Browse files Browse the repository at this point in the history
* feat(tracing): use tracing and zenoh-util log init

Signed-off-by: gabrik <[email protected]>

* feat(tracing): using zenoh main branch

Signed-off-by: gabrik <[email protected]>

---------

Signed-off-by: gabrik <[email protected]>
  • Loading branch information
gabrik authored Apr 16, 2024
1 parent 5738a56 commit bcc346c
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 101 deletions.
85 changes: 30 additions & 55 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@ cdr = "0.2.4"
clap = "3.2.23"
cyclors = { version = "0.2.0", git = "https://github.com/ZettaScaleLabs/cyclors.git", branch = "master" }
derivative = "2.2.0"
env_logger = "0.10.0"
flume = "0.11.0"
futures = "0.3.26"
git-version = "0.3.5"
hex = "0.4.3"
lazy_static = "1.4.0"
log = "0.4.17"
regex = "1.7.1"
rustc_version = "0.4"
serde = "1.0.154"
serde_json = "1.0.94"
tracing = "0.1"
zenoh = { version = "0.11.0-dev", git = "https://github.com/eclipse-zenoh/zenoh.git", branch = "main", features = [
"unstable",
] }
Expand Down
4 changes: 2 additions & 2 deletions zenoh-bridge-dds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ dds_shm = ["zenoh-plugin-dds/dds_shm"]
async-std = { workspace = true, features = ["unstable", "attributes"] }
async-liveliness-monitor = { workspace = true }
clap = { workspace = true }
env_logger = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
zenoh = { workspace = true }
zenoh-plugin-rest = { workspace = true }
zenoh-plugin-trait = { workspace = true }
zenoh-plugin-dds = { version = "0.11.0-dev", path = "../zenoh-plugin-dds/", default-features = false }
zenoh-util = { workspace = true }

[[bin]]
name = "zenoh-bridge-dds"
Expand Down
14 changes: 7 additions & 7 deletions zenoh-bridge-dds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ r#"--watchdog=[PERIOD] 'Experimental!! Run a watchdog thread that monitors the

#[async_std::main]
async fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("z=info")).init();
log::info!("zenoh-bridge-dds {}", DDSPlugin::PLUGIN_LONG_VERSION);
zenoh_util::init_log_from_env();
tracing::info!("zenoh-bridge-dds {}", DDSPlugin::PLUGIN_LONG_VERSION);

let (config, watchdog_period) = parse_args();
let rest_plugin = config.plugin("rest").is_some();
Expand Down Expand Up @@ -278,7 +278,7 @@ fn run_watchdog(period: f32) {
// Start a Liveliness Monitor thread for async_std Runtime
let (_task, monitor) = LivelinessMonitor::start(async_std::task::spawn);
std::thread::spawn(move || {
log::debug!(
tracing::debug!(
"Watchdog started with period {} sec",
sleep_time.as_secs_f32()
);
Expand All @@ -289,7 +289,7 @@ fn run_watchdog(period: f32) {

// Monitor watchdog thread itself
if elapsed > sleep_time + max_sleep_delta {
log::warn!(
tracing::warn!(
"Watchdog thread slept more than configured: {} seconds",
elapsed.as_secs_f32()
);
Expand All @@ -298,11 +298,11 @@ fn run_watchdog(period: f32) {
let report = monitor.latest_report();
if report.elapsed() > report_threshold_1 {
if report.elapsed() > sleep_time {
log::error!("Watchdog detecting async_std is stalled! No task scheduling since {} seconds", report.elapsed().as_secs_f32());
tracing::error!("Watchdog detecting async_std is stalled! No task scheduling since {} seconds", report.elapsed().as_secs_f32());
} else if report.elapsed() > report_threshold_2 {
log::warn!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros());
tracing::warn!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros());
} else {
log::info!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros());
tracing::info!("Watchdog detecting async_std was not scheduling tasks during the last {} ms", report.elapsed().as_micros());
}
}
}
Expand Down
Loading

0 comments on commit bcc346c

Please sign in to comment.