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

@@ -18,8 +18,8 @@ reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
signing_method = { workspace = true }
slog = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
types = { workspace = true }
url = { workspace = true }
validator_dir = { workspace = true }

View File

@@ -22,13 +22,13 @@ use parking_lot::{MappedMutexGuard, Mutex, MutexGuard};
use reqwest::{Certificate, Client, Error as ReqwestError, Identity};
use serde::{Deserialize, Serialize};
use signing_method::SigningMethod;
use slog::{debug, error, info, warn, Logger};
use std::collections::{HashMap, HashSet};
use std::fs::{self, File};
use std::io::{self, Read};
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Duration;
use tracing::{debug, error, info, warn};
use types::graffiti::GraffitiString;
use types::{Address, Graffiti, Keypair, PublicKey, PublicKeyBytes};
use url::{ParseError, Url};
@@ -503,8 +503,6 @@ pub struct InitializedValidators {
validators: HashMap<PublicKeyBytes, InitializedValidator>,
/// The clients used for communications with a remote signer.
web3_signer_client_map: Option<HashMap<Web3SignerDefinition, Client>>,
/// For logging via `slog`.
log: Logger,
config: Config,
}
@@ -514,7 +512,6 @@ impl InitializedValidators {
definitions: ValidatorDefinitions,
validators_dir: PathBuf,
config: Config,
log: Logger,
) -> Result<Self, Error> {
let mut this = Self {
validators_dir,
@@ -522,7 +519,6 @@ impl InitializedValidators {
validators: HashMap::default(),
web3_signer_client_map: None,
config,
log,
};
this.update_validators().await?;
Ok(this)
@@ -1151,10 +1147,9 @@ impl InitializedValidators {
for uuid in cache.uuids() {
if !definitions_map.contains_key(uuid) {
debug!(
self.log,
"Resetting the key cache";
"keystore_uuid" => %uuid,
"reason" => "impossible to decrypt due to missing keystore",
keystore_uuid = %uuid,
reason = "impossible to decrypt due to missing keystore",
"Resetting the key cache"
);
return Ok(KeyCache::new());
}
@@ -1281,30 +1276,27 @@ impl InitializedValidators {
self.validators
.insert(init.voting_public_key().compress(), init);
info!(
self.log,
"Enabled validator";
"signing_method" => "local_keystore",
"voting_pubkey" => format!("{:?}", def.voting_public_key),
signing_method = "local_keystore",
voting_pubkey = format!("{:?}", def.voting_public_key),
"Enabled validator"
);
if let Some(lockfile_path) = existing_lockfile_path {
warn!(
self.log,
"Ignored stale lockfile";
"path" => lockfile_path.display(),
"cause" => "Ungraceful shutdown (harmless) OR \
path = ?lockfile_path.display(),
cause = "Ungraceful shutdown (harmless) OR \
non-Lighthouse client using this keystore \
(risky)"
(risky)",
"Ignored stale lockfile"
);
}
}
Err(e) => {
error!(
self.log,
"Failed to initialize validator";
"error" => format!("{:?}", e),
"signing_method" => "local_keystore",
"validator" => format!("{:?}", def.voting_public_key)
error = format!("{:?}", e),
signing_method = "local_keystore",
validator = format!("{:?}", def.voting_public_key),
"Failed to initialize validator"
);
// Exit on an invalid validator.
@@ -1327,19 +1319,17 @@ impl InitializedValidators {
.insert(init.voting_public_key().compress(), init);
info!(
self.log,
"Enabled validator";
"signing_method" => "remote_signer",
"voting_pubkey" => format!("{:?}", def.voting_public_key),
signing_method = "remote_signer",
voting_pubkey = format!("{:?}", def.voting_public_key),
"Enabled validator"
);
}
Err(e) => {
error!(
self.log,
"Failed to initialize validator";
"error" => format!("{:?}", e),
"signing_method" => "remote_signer",
"validator" => format!("{:?}", def.voting_public_key)
error = format!("{:?}", e),
signing_method = "remote_signer",
validator = format!("{:?}", def.voting_public_key),
"Failed to initialize validator"
);
// Exit on an invalid validator.
@@ -1364,9 +1354,8 @@ impl InitializedValidators {
}
info!(
self.log,
"Disabled validator";
"voting_pubkey" => format!("{:?}", def.voting_public_key)
voting_pubkey = format!("{:?}", def.voting_public_key),
"Disabled validator"
);
}
}
@@ -1378,23 +1367,18 @@ impl InitializedValidators {
}
let validators_dir = self.validators_dir.clone();
let log = self.log.clone();
if has_local_definitions && key_cache.is_modified() {
tokio::task::spawn_blocking(move || {
match key_cache.save(validators_dir) {
Err(e) => warn!(
log,
"Error during saving of key_cache";
"err" => format!("{:?}", e)
),
Ok(true) => info!(log, "Modified key_cache saved successfully"),
Err(e) => warn!(err = format!("{:?}", e), "Error during saving of key_cache"),
Ok(true) => info!("Modified key_cache saved successfully"),
_ => {}
};
})
.await
.map_err(Error::TokioJoin)?;
} else {
debug!(log, "Key cache not modified");
debug!("Key cache not modified");
}
// Update the enabled and total validator counts