Skip to content

Commit 637745b

Browse files
authored
feat: add support for tracing to scenario runner (#5063)
1 parent 7c23825 commit 637745b

File tree

7 files changed

+32
-5
lines changed

7 files changed

+32
-5
lines changed

.cargo/config

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
[alias]
2-
gen-execution-api = "run --bin tools -- gen-execution-api"
3-
replay-block = "run --bin tools -- replay-block"
2+
gen-execution-api = "run --bin tools -- gen-execution-api"
3+
scenario = "run --release --bin tools -- scenario"
4+
scenario-with-tracing = "run --release --features tracing --bin tools -- scenario"
5+
replay-block = "run --release --bin tools -- replay-block"
46

57
[target.'cfg(all())']
68
rustflags = [

Cargo.lock

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/edr_napi/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ openssl-sys = { version = "0.9.93", features = ["vendored"] }
4646
napi-build = "2.0.1"
4747

4848
[features]
49-
tracing = ["edr_evm/tracing"]
49+
tracing = ["edr_evm/tracing", "edr_provider/tracing"]
5050
scenarios = ["rand"]
5151

5252
[profile.release]

crates/edr_provider/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ serde_json = { version = "1.0.89" }
2323
sha3 = { version = "0.10.6", default-features = false }
2424
thiserror = { version = "1.0.37", default-features = false }
2525
tokio = { version = "1.21.2", default-features = false, features = ["macros"] }
26-
tracing = { version = "0.1.37", features = ["attributes", "std"] }
26+
tracing = { version = "0.1.37", features = ["attributes", "std"], optional = true }
2727
lru = "0.12.2"
2828

2929
[dev-dependencies]
@@ -39,3 +39,4 @@ toml = { version = "0.5.9", default-features = false }
3939

4040
[features]
4141
test-utils = ["anyhow"]
42+
tracing = ["dep:tracing", "edr_eth/tracing", "edr_evm/tracing"]

crates/edr_provider/src/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl<LoggerErrorT: Debug> ProviderData<LoggerErrorT> {
526526
self.beneficiary
527527
}
528528

529-
#[tracing::instrument(level = "trace", skip(self))]
529+
#[cfg_attr(feature = "tracing", tracing::instrument(level = "trace", skip(self)))]
530530
pub fn debug_trace_transaction(
531531
&mut self,
532532
transaction_hash: &B256,

crates/tools/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ serde_json = "1.0.107"
1919
serde = { version = "1.0.189", features = ["derive"] }
2020
tempfile = "3.7.1"
2121
tokio = "1.33.0"
22+
tracing = { version = "0.1.37", features = ["attributes", "std"], optional = true }
23+
tracing-flame = { version = "0.2.0", default-features = false, features = ["smallvec"], optional = true }
24+
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec", "std"], optional = true }
2225
toml = { version = "0.5.9", default-features = false }
2326
walkdir = { version = "2.4.0", features = [] }
27+
28+
[features]
29+
tracing = ["dep:tracing", "dep:tracing-flame", "dep:tracing-subscriber", "edr_eth/tracing", "edr_evm/tracing", "edr_provider/tracing"]

crates/tools/src/scenario.rs

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use flate2::bufread::GzDecoder;
1313
use indicatif::ProgressBar;
1414
use serde::Deserialize;
1515
use tokio::{runtime, task};
16+
#[cfg(feature = "tracing")]
17+
use tracing_subscriber::{prelude::*, Registry};
1618

1719
#[derive(Clone, Debug, Deserialize)]
1820
struct ScenarioConfig {
@@ -30,6 +32,19 @@ pub async fn execute(scenario_path: &Path, max_count: Option<usize>) -> anyhow::
3032
let logger = Box::<DisabledLogger>::default();
3133
let subscription_callback = Box::new(|_| ());
3234

35+
#[cfg(feature = "tracing")]
36+
let _flame_guard = {
37+
let (flame_layer, guard) = tracing_flame::FlameLayer::with_file("tracing.folded").unwrap();
38+
39+
let flame_layer = flame_layer.with_empty_samples(false);
40+
let subscriber = Registry::default().with(flame_layer);
41+
42+
tracing::subscriber::set_global_default(subscriber)
43+
.expect("Could not set global default tracing subscriber");
44+
45+
guard
46+
};
47+
3348
println!("Executing requests");
3449

3550
let start = Instant::now();

0 commit comments

Comments
 (0)