mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
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:
@@ -10,12 +10,13 @@ beacon_chain = { workspace = true }
|
||||
health_metrics = { workspace = true }
|
||||
lighthouse_network = { workspace = true }
|
||||
lighthouse_version = { workspace = true }
|
||||
logging = { workspace = true }
|
||||
malloc_utils = { workspace = true }
|
||||
metrics = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
slog = { workspace = true }
|
||||
slot_clock = { workspace = true }
|
||||
store = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
warp = { workspace = true }
|
||||
warp_utils = { workspace = true }
|
||||
|
||||
|
||||
@@ -6,12 +6,13 @@ mod metrics;
|
||||
use beacon_chain::{BeaconChain, BeaconChainTypes};
|
||||
use lighthouse_network::prometheus_client::registry::Registry;
|
||||
use lighthouse_version::version_with_platform;
|
||||
use logging::crit;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use slog::{crit, info, Logger};
|
||||
use std::future::Future;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tracing::info;
|
||||
use warp::{http::Response, Filter};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -41,7 +42,6 @@ pub struct Context<T: BeaconChainTypes> {
|
||||
pub db_path: Option<PathBuf>,
|
||||
pub freezer_db_path: Option<PathBuf>,
|
||||
pub gossipsub_registry: Option<std::sync::Mutex<Registry>>,
|
||||
pub log: Logger,
|
||||
}
|
||||
|
||||
/// Configuration for the HTTP server.
|
||||
@@ -86,7 +86,6 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
shutdown: impl Future<Output = ()> + Send + Sync + 'static,
|
||||
) -> Result<(SocketAddr, impl Future<Output = ()>), Error> {
|
||||
let config = &ctx.config;
|
||||
let log = ctx.log.clone();
|
||||
|
||||
// Configure CORS.
|
||||
let cors_builder = {
|
||||
@@ -103,7 +102,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
// Sanity check.
|
||||
if !config.enabled {
|
||||
crit!(log, "Cannot start disabled metrics HTTP server");
|
||||
crit!("Cannot start disabled metrics HTTP server");
|
||||
return Err(Error::Other(
|
||||
"A disabled metrics server should not be started".to_string(),
|
||||
));
|
||||
@@ -144,9 +143,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
)?;
|
||||
|
||||
info!(
|
||||
log,
|
||||
"Metrics HTTP server started";
|
||||
"listen_address" => listening_socket.to_string(),
|
||||
listen_address = listening_socket.to_string(),
|
||||
"Metrics HTTP server started"
|
||||
);
|
||||
|
||||
Ok((listening_socket, server))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use beacon_chain::test_utils::EphemeralHarnessType;
|
||||
use http_metrics::Config;
|
||||
use logging::test_logger;
|
||||
use logging::create_test_tracing_subscriber;
|
||||
use reqwest::header::HeaderValue;
|
||||
use reqwest::StatusCode;
|
||||
use std::net::{IpAddr, Ipv4Addr};
|
||||
@@ -12,9 +12,8 @@ type Context = http_metrics::Context<EphemeralHarnessType<MainnetEthSpec>>;
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn returns_200_ok() {
|
||||
create_test_tracing_subscriber();
|
||||
async {
|
||||
let log = test_logger();
|
||||
|
||||
let context = Arc::new(Context {
|
||||
config: Config {
|
||||
enabled: true,
|
||||
@@ -27,7 +26,6 @@ async fn returns_200_ok() {
|
||||
db_path: None,
|
||||
freezer_db_path: None,
|
||||
gossipsub_registry: None,
|
||||
log,
|
||||
});
|
||||
|
||||
let ctx = context.clone();
|
||||
|
||||
Reference in New Issue
Block a user