Skip to content

Commit

Permalink
feat: integrate tokio traces & debug console (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
scarmuega authored Jun 22, 2024
1 parent e7eae90 commit 123f795
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 8 deletions.
93 changes: 90 additions & 3 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ trait-variant = "0.1.2"
comfy-table = { version = "7.1.1", optional = true }
inquire = { version = "0.7.5", optional = true }
toml = { version = "0.8.13", optional = true }
console-subscriber = { version = "0.3.0", optional = true }

[dev-dependencies]
tempfile = "3.3.0"

[features]
mithril = ["mithril-client"]
utils = ["comfy-table", "inquire", "toml"]
debug = ["console-subscriber", "tokio/tracing"]
default = ["mithril", "utils"]

# The profile that 'cargo dist' will build with
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,25 @@ sudo sh ./get-dolos.sh
```

After installation, follow this [configuration guide](book/src/configuration). Guide on running dolos [here](book/src/running).


# Debug

## Running Tokio Console

Make sure you have enable tokio traces in dolos.toml:
```toml
[logging]
max_level=trace
include_tokio=true
```

Start Dolos using:
```
RUSTFLAGS="--cfg tokio_unstable" cargo --features debug run
```

Then start tokio console:
```
tokio-console
```
27 changes: 22 additions & 5 deletions src/bin/dolos/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> {
.with_target("dolos", level)
.with_target("gasket", level);

if config.include_tokio {
filter = filter
.with_target("tokio", level)
.with_target("runtime", level);
}

if config.include_pallas {
filter = filter.with_target("pallas", level);
}
Expand All @@ -62,11 +68,22 @@ pub fn setup_tracing(config: &LoggingConfig) -> miette::Result<()> {
filter = filter.with_target("tonic", level);
}

tracing_subscriber::FmtSubscriber::builder()
.with_max_level(level)
.finish()
.with(filter)
.init();
#[cfg(not(feature = "debug"))]
{
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(filter)
.init();
}

#[cfg(feature = "debug")]
{
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(console_subscriber::spawn())
.with(filter)
.init();
}

Ok(())
}
Expand Down
4 changes: 4 additions & 0 deletions src/bin/dolos/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ pub struct LoggingConfig {
#[serde_as(as = "DisplayFromStr")]
max_level: tracing::Level,

#[serde(default)]
include_tokio: bool,

#[serde(default)]
include_pallas: bool,

Expand All @@ -120,6 +123,7 @@ impl Default for LoggingConfig {
fn default() -> Self {
Self {
max_level: tracing::Level::INFO,
include_tokio: Default::default(),
include_pallas: Default::default(),
include_grpc: Default::default(),
}
Expand Down

0 comments on commit 123f795

Please sign in to comment.