Integrate tracing (#6339)

Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (L297))


  - [x] replace slog & log with tracing throughout the codebase
- [x] implement custom crit log
- [x] make relevant changes in the formatter
- [x] replace sloggers
- [x] re-write SSE logging components

cc: @macladson @eserilev
This commit is contained in:
ThreeHrSleep
2025-03-13 04:01:05 +05:30
committed by GitHub
parent f23f984f85
commit d60c24ef1c
241 changed files with 9485 additions and 9328 deletions

View File

@@ -8,14 +8,17 @@ edition = { workspace = true }
[dependencies]
clap = { workspace = true }
env_logger = { workspace = true }
environment = { workspace = true }
eth2_network_config = { workspace = true }
execution_layer = { workspace = true }
futures = { workspace = true }
kzg = { workspace = true }
logging = { workspace = true }
node_test_rig = { path = "../node_test_rig" }
parking_lot = { workspace = true }
rayon = { workspace = true }
sensitive_url = { path = "../../common/sensitive_url" }
serde_json = { workspace = true }
tokio = { workspace = true }
tracing-subscriber = { workspace = true }
types = { workspace = true }

View File

@@ -13,6 +13,12 @@ use rayon::prelude::*;
use std::cmp::max;
use std::sync::Arc;
use std::time::Duration;
use environment::tracing_common;
use logging::MetricsLayer;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use tokio::time::sleep;
use types::{Epoch, EthSpec, MinimalEthSpec};
@@ -82,23 +88,47 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
})
.collect::<Vec<_>>();
let mut env = EnvironmentBuilder::minimal()
.initialize_logger(LoggerConfig {
let (
env_builder,
filter_layer,
_libp2p_discv5_layer,
file_logging_layer,
stdout_logging_layer,
_sse_logging_layer_opt,
logger_config,
_dependency_log_filter,
) = tracing_common::construct_logger(
LoggerConfig {
path: None,
debug_level: log_level.clone(),
logfile_debug_level: log_level.clone(),
debug_level: tracing_common::parse_level(&log_level.clone()),
logfile_debug_level: tracing_common::parse_level(&log_level.clone()),
log_format: None,
logfile_format: None,
log_color: false,
log_color: true,
logfile_color: true,
disable_log_timestamp: false,
max_log_size: 0,
max_log_number: 0,
compression: false,
is_restricted: true,
sse_logging: false,
})?
.multi_threaded_tokio_runtime()?
.build()?;
extra_info: false,
},
matches,
EnvironmentBuilder::minimal(),
);
if let Err(e) = tracing_subscriber::registry()
.with(filter_layer)
.with(file_logging_layer.with_filter(logger_config.logfile_debug_level))
.with(stdout_logging_layer.with_filter(logger_config.debug_level))
.with(MetricsLayer)
.try_init()
{
eprintln!("Failed to initialize dependency logging: {e}");
}
let mut env = env_builder.multi_threaded_tokio_runtime()?.build()?;
let mut spec = (*env.eth2_config.spec).clone();

View File

@@ -3,7 +3,9 @@ use crate::{checks, LocalNetwork};
use clap::ArgMatches;
use crate::retry::with_retry;
use environment::tracing_common;
use futures::prelude::*;
use logging::MetricsLayer;
use node_test_rig::{
environment::{EnvironmentBuilder, LoggerConfig},
testing_validator_config, ValidatorFiles,
@@ -13,8 +15,9 @@ use std::cmp::max;
use std::sync::Arc;
use std::time::Duration;
use tokio::time::sleep;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use types::{Epoch, EthSpec, MinimalEthSpec};
const END_EPOCH: u64 = 16;
const GENESIS_DELAY: u64 = 32;
const ALTAIR_FORK_EPOCH: u64 = 0;
@@ -89,23 +92,49 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
})
.collect::<Vec<_>>();
let mut env = EnvironmentBuilder::minimal()
.initialize_logger(LoggerConfig {
let (
env_builder,
filter_layer,
libp2p_discv5_layer,
file_logging_layer,
stdout_logging_layer,
_sse_logging_layer_opt,
logger_config,
dependency_log_filter,
) = tracing_common::construct_logger(
LoggerConfig {
path: None,
debug_level: log_level.clone(),
logfile_debug_level: log_level.clone(),
debug_level: tracing_common::parse_level(&log_level.clone()),
logfile_debug_level: tracing_common::parse_level(&log_level.clone()),
log_format: None,
logfile_format: None,
log_color: false,
log_color: true,
logfile_color: false,
disable_log_timestamp: false,
max_log_size: 0,
max_log_number: 0,
compression: false,
is_restricted: true,
sse_logging: false,
})?
.multi_threaded_tokio_runtime()?
.build()?;
extra_info: false,
},
matches,
EnvironmentBuilder::minimal(),
);
if let Err(e) = tracing_subscriber::registry()
.with(dependency_log_filter)
.with(filter_layer)
.with(file_logging_layer.with_filter(logger_config.logfile_debug_level))
.with(stdout_logging_layer.with_filter(logger_config.debug_level))
.with(libp2p_discv5_layer)
.with(MetricsLayer)
.try_init()
{
eprintln!("Failed to initialize dependency logging: {e}");
}
let mut env = env_builder.multi_threaded_tokio_runtime()?.build()?;
let mut spec = (*env.eth2_config.spec).clone();