Skip to content

Commit

Permalink
[EASY] Revert logging changes (#2815)
Browse files Browse the repository at this point in the history
# Description
Reverts #2791 and #2792 since changing how we initialize the tracing
subscriber causes us to drop specific individual logs for an unknown
reason. I really want to get these 2 PRs back into the code base but
until this is figured out we can't deploy this change to prod.

Needs to be included in this weeks release.
  • Loading branch information
MartinquaXD authored Jul 16, 2024
1 parent 1ac9806 commit a9d9643
Show file tree
Hide file tree
Showing 25 changed files with 35 additions and 369 deletions.
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

147 changes: 0 additions & 147 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tempfile = "3.10.1"
time = { version = "0.3.36", features = ["macros"] }
thiserror = "1.0.61"
toml = "0.8.14"
tokio = { version = "1.38.0", features = ["tracing"] }
tokio = "1.38.0"
tokio-stream = { version = "0.1.15", features = ["sync"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand Down
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,6 @@ ANVIL_IP_ADDR=0.0.0.0 anvil \
--timestamp 1577836800
```

### Profiling

The most important binaries support [tokio-console](https://github.com/tokio-rs/console) to allow you a could look inside the tokio runtime.

Simply enable the feature by passing `--enable-tokio-console true` when running a binary and then in another shell, run

```
cargo install --locked tokio-console
tokio-console
```


### Changing Log Filters

It's possible to change the tracing log filter while the process is running. This can be useful to debug an error that requires more verbose logs but which might no longer appear after restarting the system.

Each process opens a UNIX socket at `/tmp/log_filter_override_<program_name>_<pid>.sock`. To change the log filter connect to it with `nc -U <path>` and enter a new log filter.
You can also reset the log filter to the filter the program was initially started with by entering `reset`.

See [here](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives) for documentation on the supported log filter format.

## Running the Services Locally

### Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion crates/alerter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ struct Arguments {

pub async fn start(args: impl Iterator<Item = String>) {
let args = Arguments::parse_from(args);
observe::tracing::initialize("alerter=debug", tracing::Level::ERROR.into(), false);
observe::tracing::initialize("alerter=debug", tracing::Level::ERROR.into());
observe::panic_hook::install();
observe::metrics::setup_registry(Some("gp_v2_alerter".to_string()), None);
tracing::info!("running alerter with {:#?}", args);
Expand Down
1 change: 0 additions & 1 deletion crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ pub async fn start(args: impl Iterator<Item = String>) {
observe::tracing::initialize(
args.shared.logging.log_filter.as_str(),
args.shared.logging.log_stderr_threshold,
args.shared.logging.enable_tokio_console,
);
observe::panic_hook::install();
tracing::info!("running autopilot with validated arguments:\n{}", args);
Expand Down
5 changes: 0 additions & 5 deletions crates/driver/src/infra/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ pub struct Args {
)]
pub log: String,

/// Captures metrics of the tokio runtime to inspect behavior of individual
/// tasks.
#[clap(long, env, action = clap::ArgAction::Set, default_value = "false")]
pub enable_tokio_console: bool,

/// The node RPC API endpoint.
#[clap(long, env)]
pub ethrpc: Url,
Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/infra/observe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ mod metrics;

/// Setup the observability. The log argument configures the tokio tracing
/// framework.
pub fn init(log: &str, with_tokio_console: bool) {
observe::tracing::initialize_reentrant(log, with_tokio_console);
pub fn init(log: &str) {
observe::tracing::initialize_reentrant(log);
metrics::init();
}

Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn run(
/// Run the driver. This function exists to avoid multiple monomorphizations of
/// the `run` code, which bloats the binaries and increases compile times.
async fn run_with(args: cli::Args, addr_sender: Option<oneshot::Sender<SocketAddr>>) {
crate::infra::observe::init(&args.log, args.enable_tokio_console);
crate::infra::observe::init(&args.log);

let ethrpc = ethrpc(&args).await;
let web3 = ethrpc.web3().clone();
Expand Down
1 change: 0 additions & 1 deletion crates/driver/src/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ impl Setup {
pub async fn done(self) -> Test {
observe::tracing::initialize_reentrant(
"driver=trace,driver::tests::setup::blockchain=debug",
false,
);

if let Some(name) = self.name.as_ref() {
Expand Down
2 changes: 1 addition & 1 deletion crates/e2e/src/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async fn run<F, Fut, T>(
Fut: Future<Output = ()>,
T: AsRef<str>,
{
observe::tracing::initialize_reentrant(&with_default_filters(filters).join(","), false);
observe::tracing::initialize_reentrant(&with_default_filters(filters).join(","));
observe::panic_hook::install();

// The mutex guarantees that no more than a test at a time is running on
Expand Down
2 changes: 1 addition & 1 deletion crates/ethrpc/src/current_block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ mod tests {
#[tokio::test]
#[ignore]
async fn mainnet() {
observe::tracing::initialize_reentrant("shared=debug", false);
observe::tracing::initialize_reentrant("shared=debug");
let node = std::env::var("NODE_URL").unwrap().parse().unwrap();
let receiver = current_block_stream(node, Duration::from_secs(1))
.await
Expand Down
3 changes: 1 addition & 2 deletions crates/observe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
atty = "0.2"
console-subscriber = "0.3.0"
atty = "0.2.14"
futures = { workspace = true }
once_cell = { workspace = true }
pin-project-lite = "0.2.14"
Expand Down
3 changes: 0 additions & 3 deletions crates/observe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ pub mod metrics;
pub mod panic_hook;
pub mod request_id;
pub mod tracing;

#[cfg(unix)]
mod tracing_reload_handler;
4 changes: 2 additions & 2 deletions crates/observe/src/panic_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod tests {
#[test]
#[ignore]
fn manual_thread() {
crate::tracing::initialize("info", tracing::level_filters::LevelFilter::OFF, false);
crate::tracing::initialize("info", tracing::level_filters::LevelFilter::OFF);

// Should print panic trace log but not kill the process.
let handle = std::thread::spawn(|| panic!("you should see this message"));
Expand All @@ -55,7 +55,7 @@ mod tests {
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn manual_tokio() {
crate::tracing::initialize("info", tracing::level_filters::LevelFilter::OFF, false);
crate::tracing::initialize("info", tracing::level_filters::LevelFilter::OFF);

let handle = tokio::task::spawn(async { panic!("you should see this message") });
assert!(handle.await.is_err());
Expand Down
Loading

0 comments on commit a9d9643

Please sign in to comment.