Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce tracing #37

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d2e89ca
feat: add tracing crates
Karrenbelt Sep 4, 2024
66d053a
feat: replace `log` with `tracing` crate in grandine/src/main.rs
Karrenbelt Sep 4, 2024
558b6ae
feat: improve tracing setup and add stdout writer
Karrenbelt Sep 4, 2024
b14b17b
feat: replace all log with tracing in grandine module
Karrenbelt Sep 4, 2024
9596fa0
chore: cleanup unused imports
Karrenbelt Sep 4, 2024
eff1618
feat: replace all log with tracing in attestation_verifier module
Karrenbelt Sep 4, 2024
6e387dd
feat: replace all log with tracing in ad_hoc_bench module
Karrenbelt Sep 4, 2024
1292575
feat: replace all log with tracing in block_producer module
Karrenbelt Sep 4, 2024
f4e4cfa
feat: replace all log with tracing in builder_api module
Karrenbelt Sep 4, 2024
8ccce1c
feat: replace all log with tracing in database module
Karrenbelt Sep 4, 2024
69f3fd5
feat: replace all log with tracing in eth1 module
Karrenbelt Sep 4, 2024
bc412e2
feat: replace all log with tracing in eth1_api module
Karrenbelt Sep 4, 2024
a84660c
feat: replace all log with tracing in fork_choice_control module
Karrenbelt Sep 4, 2024
50af7a7
feat: replace all log with tracing in http_api module
Karrenbelt Sep 4, 2024
0b63a36
feat: replace all log with tracing in http_api_utils module
Karrenbelt Sep 4, 2024
27229c5
feat: replace all log with tracing in keymanager module
Karrenbelt Sep 4, 2024
682d74f
feat: replace all log with tracing in liveness_tracker module
Karrenbelt Sep 4, 2024
afb5bcb
feat: replace all log with tracing in metrics module
Karrenbelt Sep 4, 2024
dbd466d
feat: replace all log with tracing in operation_pools module
Karrenbelt Sep 4, 2024
34dd77d
feat: replace all log with tracing in prometheus_metrics module
Karrenbelt Sep 4, 2024
5fb013d
feat: replace all log with tracing in runtime module
Karrenbelt Sep 4, 2024
4bc3bc2
feat: replace all log with tracing in signer module
Karrenbelt Sep 4, 2024
cde29c0
feat: replace all log with tracing in slasher module
Karrenbelt Sep 4, 2024
d8f8f7e
feat: replace all log with tracing in slashing_protection module
Karrenbelt Sep 4, 2024
99390a4
feat: replace all log with tracing in state_cache module
Karrenbelt Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 128 additions & 29 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ tokio-util = { version = '0.7', features = ['codec', 'compat', 'time'] }
tower = { version = '0.4.13', features = ['timeout'] }
tower-http = { version = '0.5.2', features = ['cors', 'trace'] }
tracing = '0.1.40'
tracing-appender = "0.2.3"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
triomphe = '0.1.13'
tynm = '0.1.10'
typenum = '1.17.0'
Expand Down
2 changes: 1 addition & 1 deletion ad_hoc_bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ fork_choice_control = { workspace = true }
fork_choice_store = { workspace = true }
futures = { workspace = true }
jemalloc-ctl = { workspace = true }
log = { workspace = true }
rand = { workspace = true }
tracing = { workspace = true }
types = { workspace = true }
2 changes: 1 addition & 1 deletion ad_hoc_bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use eth2_cache_utils::{goerli, holesky, holesky_devnet, mainnet, medalla, withdr
use fork_choice_control::AdHocBenchController;
use fork_choice_store::StoreConfig;
use jemalloc_ctl::Result as JemallocResult;
use log::info;
use tracing::info;
use rand::seq::SliceRandom as _;
use types::{
combined::{BeaconState, SignedBeaconBlock},
Expand Down
2 changes: 1 addition & 1 deletion attestation_verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fork_choice_store = { workspace = true }
futures = { workspace = true }
helper_functions = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
prometheus_metrics = { workspace = true }
rayon = { workspace = true }
std_ext = { workspace = true }
tracing = {workspace = true }
types = { workspace = true }
2 changes: 1 addition & 1 deletion attestation_verifier/src/attestation_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use helper_functions::{
verifier::{MultiVerifier, Triple, Verifier},
};
use itertools::Either;
use log::{debug, warn};
use tracing::{debug, warn};
use prometheus_metrics::Metrics;
use rayon::iter::{IntoParallelIterator as _, ParallelBridge as _, ParallelIterator as _};
use std_ext::ArcExt as _;
Expand Down
2 changes: 1 addition & 1 deletion block_producer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ futures = { workspace = true }
helper_functions = { workspace = true }
itertools = { workspace = true }
keymanager = { workspace = true }
log = { workspace = true }
nonzero_ext = { workspace = true }
operation_pools = { workspace = true }
prometheus_metrics = { workspace = true }
Expand All @@ -36,6 +35,7 @@ std_ext = { workspace = true }
tap = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
transition_functions = { workspace = true }
try_from_iterator = { workspace = true }
tynm = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion block_producer/src/block_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use futures::{
use helper_functions::{accessors, misc, predicates};
use itertools::{Either, Itertools as _};
use keymanager::ProposerConfigs;
use log::{error, info, warn};
use tracing::{error, info, warn};
use nonzero_ext::nonzero;
use operation_pools::{
AttestationAggPool, BlsToExecutionChangePool, PoolAdditionOutcome, PoolRejectionReason,
Expand Down
2 changes: 1 addition & 1 deletion block_producer/src/eth1_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use deposit_tree::DepositTree;
use eth1::{DepositEvent, Eth1Block, Eth1Chain};
use helper_functions::misc::compute_timestamp_at_slot;
use itertools::Itertools as _;
use log::{error, warn};
use tracing::{error, warn};
use prometheus_metrics::Metrics;
use ssz::ContiguousList;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion builder_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ derive_more = { workspace = true }
helper_functions = { workspace = true }
hex-literal = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
prometheus_metrics = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_utils = { workspace = true }
ssz = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
typenum = { workspace = true }
types = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion builder_api/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bls::PublicKeyBytes;
use derive_more::Constructor;
use helper_functions::signing::SignForAllForks;
use itertools::Itertools as _;
use log::{debug, info};
use tracing::{debug, info};
use prometheus_metrics::Metrics;
use reqwest::{Client, Response, StatusCode, Url};
use ssz::SszHash as _;
Expand Down
2 changes: 1 addition & 1 deletion database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ fs-err = { workspace = true }
im = { workspace = true }
itertools = { workspace = true }
libmdbx = { workspace = true }
log = { workspace = true }
snap = { workspace = true }
std_ext = { workspace = true }
tap = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
unwrap_none = { workspace = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bytesize::ByteSize;
use im::OrdMap;
use itertools::Either;
use libmdbx::{DatabaseFlags, Environment, Geometry, WriteFlags};
use log::info;
use tracing::info;
use snap::raw::{Decoder, Encoder};
use std_ext::ArcExt as _;
use tap::Pipe as _;
Expand Down
2 changes: 1 addition & 1 deletion eth1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ fs-err = { workspace = true }
futures = { workspace = true }
genesis = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
prometheus_metrics = { workspace = true }
reqwest = { workspace = true }
ssz = { workspace = true }
std_ext = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tokio-stream = { workspace = true }
tracing = { workspace = true }
tynm = { workspace = true }
types = { workspace = true }
url = { workspace = true }
2 changes: 1 addition & 1 deletion eth1/src/download_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::{Context as _, Result};
use eth1_api::{Eth1Api, Eth1ApiToMetrics, Eth1Block};
use futures::channel::mpsc::UnboundedSender;
use log::{info, warn};
use tracing::{info, warn};
use prometheus_metrics::Metrics;
use reqwest::Client;
use std_ext::ArcExt as _;
Expand Down
2 changes: 1 addition & 1 deletion eth1/src/eth1_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use futures::{
channel::mpsc::UnboundedSender,
stream::{Stream, TryStreamExt as _},
};
use log::{error, info};
use tracing::{error, info};
use prometheus_metrics::Metrics;
use reqwest::Client;
use std_ext::ArcExt as _;
Expand Down
2 changes: 1 addition & 1 deletion eth1/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chrono::{Local, TimeZone as _};
use eth1_api::{DepositEvent, Eth1Block};
use futures::stream::{Stream, TryStreamExt as _};
use genesis::Incremental;
use log::info;
use tracing::info;
use ssz::{SszRead as _, SszWrite as _};
use thiserror::Error;
use types::{
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ futures = { workspace = true }
hex = { workspace = true }
hex-literal = { workspace = true }
jwt-simple = { workspace = true }
log = { workspace = true }
memoffset = { workspace = true }
panics = { workspace = true }
prometheus_metrics = { workspace = true }
Expand All @@ -33,6 +32,7 @@ static_assertions = { workspace = true }
std_ext = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
typenum = { workspace = true }
types = { workspace = true }
web3 = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/eth1_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use execution_engine::{
ForkChoiceUpdatedResponse, PayloadAttributes, PayloadId, PayloadStatusV1,
};
use futures::{channel::mpsc::UnboundedSender, lock::Mutex, Future};
use log::warn;
use tracing::warn;
use prometheus_metrics::Metrics;
use reqwest::{header::HeaderMap, Client, Url};
use serde::{de::DeserializeOwned, Deserialize};
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/eth1_execution_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use derive_more::Constructor;
use either::Either;
use execution_engine::{ExecutionEngine, PayloadAttributes, PayloadId, PayloadStatusV1};
use futures::channel::{mpsc::UnboundedSender, oneshot::Sender};
use log::{info, warn};
use tracing::{info, warn};
use tokio::runtime::{Builder, Handle};
use types::{
combined::{ExecutionPayload, ExecutionPayloadParams},
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/execution_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use either::Either;
use execution_engine::{ForkChoiceUpdatedResponse, PayloadAttributes, PayloadStatusV1};
use fork_choice_control::Wait;
use futures::{channel::mpsc::UnboundedReceiver, StreamExt as _};
use log::warn;
use tracing::warn;
use types::{
combined::{ExecutionPayload, ExecutionPayloadParams},
nonstandard::Phase,
Expand Down
2 changes: 1 addition & 1 deletion eth1_api/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use either::Either;
use execution_engine::{PayloadAttributes, PayloadId, PayloadStatusV1};
use futures::channel::{mpsc::UnboundedSender, oneshot::Sender};
use log::debug;
use tracing::debug;
use types::{
combined::{ExecutionPayload, ExecutionPayloadParams},
nonstandard::Phase,
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ genesis = { workspace = true }
helper_functions = { workspace = true }
http_api_utils = { workspace = true }
itertools = { workspace = true }
log = { workspace = true }
mime = { workspace = true }
nonzero_ext = { workspace = true }
num_cpus = { workspace = true }
Expand All @@ -42,6 +41,7 @@ std_ext = { workspace = true }
strum = { workspace = true }
tap = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
transition_functions = { workspace = true }
tynm = { workspace = true }
types = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/checkpoint_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;
use anyhow::{bail, Result};
use helper_functions::misc;
use http_api_utils::{BlockId, StateId};
use log::info;
use tracing::info;
use mime::APPLICATION_OCTET_STREAM;
use reqwest::{header::ACCEPT, Client, StatusCode, Url};
use ssz::SszRead;
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use fork_choice_store::{
ChainLink, Store,
};
use helper_functions::{accessors, misc};
use log::debug;
use tracing::debug;
use serde::Serialize;
use tap::Pipe as _;
use types::{
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use fork_choice_store::{
use futures::channel::{mpsc::Sender as MultiSender, oneshot::Sender as OneshotSender};
use helper_functions::{accessors, misc, predicates, verifier::NullVerifier};
use itertools::{Either, Itertools as _};
use log::{debug, error, info, warn};
use tracing::{debug, error, info, warn};
use prometheus_metrics::Metrics;
use ssz::SszHash as _;
use std_ext::ArcExt as _;
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use fork_choice_store::{ChainLink, Store};
use genesis::AnchorCheckpointProvider;
use helper_functions::{accessors, misc};
use itertools::Itertools as _;
use log::{debug, info, warn};
use tracing::{debug, info, warn};
use nonzero_ext::nonzero;
use reqwest::{Client, Url};
use ssz::{Ssz, SszRead, SszReadDefault as _, SszWrite};
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/storage_back_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arithmetic::U64Ext as _;
use features::Feature;
use genesis::AnchorCheckpointProvider;
use helper_functions::misc;
use log::{info, warn};
use tracing::{info, warn};
use ssz::SszHash as _;
use std_ext::ArcExt as _;
use transition_functions::combined;
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/storage_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};

use anyhow::Result;
use genesis::AnchorCheckpointProvider;
use log::info;
use tracing::info;
use ssz::{SszHash as _, SszRead, SszWrite as _};
use std_ext::ArcExt as _;
use thiserror::Error;
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use helper_functions::{
accessors, misc,
verifier::{MultiVerifier, NullVerifier},
};
use log::{debug, warn};
use tracing::{debug, warn};
use prometheus_metrics::Metrics;
use types::{
combined::SignedBeaconBlock,
Expand Down
2 changes: 1 addition & 1 deletion fork_choice_control/src/thread_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use anyhow::Result;
use derivative::Derivative;
use derive_more::From;
use execution_engine::ExecutionEngine;
use log::debug;
use tracing::debug;
use parking_lot::{Condvar, Mutex};
use std_ext::ArcExt as _;
use types::preset::Preset;
Expand Down
2 changes: 1 addition & 1 deletion grandine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ hex-literal = { workspace = true }
http_api = { workspace = true }
itertools = { workspace = true }
keymanager = { workspace = true }
log = { workspace = true }
logging = { workspace = true }
metrics = { workspace = true }
p2p = { workspace = true }
Expand All @@ -59,6 +58,7 @@ tap = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tower-http = { workspace = true }
tracing = {workspace = true}
types = { workspace = true }
validator = { workspace = true }
validator_key_cache = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion grandine/src/grandine_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use fork_choice_store::{StoreConfig, DEFAULT_CACHE_LOCK_TIMEOUT_MILLIS};
use grandine_version::{APPLICATION_NAME, APPLICATION_NAME_AND_VERSION, APPLICATION_VERSION};
use http_api::HttpApiConfig;
use itertools::{EitherOrBoth, Itertools as _};
use log::warn;
use tracing::warn;
use metrics::{MetricsServerConfig, MetricsServiceConfig};
use p2p::{Enr, Multiaddr, NetworkConfig};
use prometheus_metrics::{Metrics, METRICS};
Expand Down
9 changes: 4 additions & 5 deletions grandine/src/grandine_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use builder_api::BuilderConfig;
use eth1_api::AuthOptions;
use features::Feature;
use http_api::HttpApiConfig;
use itertools::Itertools as _;
use log::info;
use p2p::NetworkConfig;
use reqwest::Url;
use runtime::{MetricsConfig, StorageConfig};
use signer::Web3SignerConfig;
use tracing::info;
use types::{
config::Config as ChainConfig,
phase0::primitives::{ExecutionAddress, ExecutionBlockNumber, Slot, H256},
Expand Down Expand Up @@ -110,7 +109,7 @@ impl GrandineConfig {
storage_config.eth1_db_size.to_string_as(true),
);

info!("Eth1 RPC URLs: [{}]", eth1_rpc_urls.iter().format(", "));
info!("Eth1 RPC URLs: {:?}", eth1_rpc_urls);
Comment on lines -113 to +112
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is required when switching from the log to the tracing crate, because otherwise a panic ensues

thread 'main' panicked at /home/zarathustra/.cargo/registry/src/index.crates.io-6f17d22bba15001f/itertools-0.13.0/src/format.rs:95:21:
Format: was already formatted once

This is important to note, because this is not a compilation but a runtime error, which entails that in case of this being an issue elsewhere - meaning where log has been exchanged for tracing - the invocation of any of the associated macro's may cause the program to panic.

This leads me to ponder the question how we can best ensure this doesn't occur. There are cumbersome ways of achieving this, by writing individual tests for modules, or by gathering all log messages through the execution of the test suite (i.e. file, line, level, message) and ensuring that all those present in the code are found in the logs. A better approach seems to me to assess the test coverage (as in which lines are of the code are ran during execution of the test suite) and then making sure that all lines with tracing macro's have been covered; this would mean they must have logged, and in case of a panic the test would not have passed.

info!("graffiti: {graffiti:?}");
info!("HTTP API address: {}", http_api_config.address);

Expand Down Expand Up @@ -151,8 +150,8 @@ impl GrandineConfig {

if !web3signer_config.urls.is_empty() {
info!(
"using Web3Signer API to sign validator messages (API URLs: [{}])",
web3signer_config.urls.iter().format(", "),
"using Web3Signer API to sign validator messages (API URLs: {:?})",
web3signer_config.urls,
);
}

Expand Down
6 changes: 4 additions & 2 deletions grandine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ use fork_choice_store::StoreConfig;
use genesis::AnchorCheckpointProvider;
use grandine_version::APPLICATION_VERSION_WITH_PLATFORM;
use http_api::HttpApiConfig;
use log::{error, info, warn};
use logging::PEER_LOG_METRICS;
use logging::{setup_tracing, PEER_LOG_METRICS};
use metrics::MetricsServerConfig;
use p2p::{ListenAddr, NetworkConfig};
use reqwest::{Client, ClientBuilder, Url};
Expand All @@ -32,6 +31,7 @@ use ssz::SszRead as _;
use std_ext::ArcExt as _;
use thiserror::Error;
use tokio::runtime::Builder;
use tracing::{error, info, warn};
use types::{
config::Config as ChainConfig,
phase0::primitives::{ExecutionBlockNumber, Slot},
Expand Down Expand Up @@ -308,6 +308,8 @@ enum Error {
}

fn main() -> ExitCode {
let _guard = setup_tracing();
info!("Grandine firing up...");
if let Err(error) = try_main() {
error.downcast_ref().map(ClapError::exit);
error!("{error:?}");
Expand Down
Loading