mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Restore HTTP API logging and add more metrics (#7225)
#7124 - Restores previous HTTP logging with tracing compatible syntax - Adds metrics for certain missing endpoints (and alphabetized the existing ones)
This commit is contained in:
@@ -215,35 +215,66 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
|
|||||||
|
|
||||||
// First line covers `POST /v1/beacon/blocks` only
|
// First line covers `POST /v1/beacon/blocks` only
|
||||||
equals("v1/beacon/blocks")
|
equals("v1/beacon/blocks")
|
||||||
.or_else(|| starts_with("v1/validator/blocks"))
|
.or_else(|| starts_with("v1/beacon/blob_sidecars"))
|
||||||
.or_else(|| starts_with("v2/validator/blocks"))
|
.or_else(|| starts_with("v1/beacon/blocks/head/root"))
|
||||||
.or_else(|| starts_with("v1/validator/blinded_blocks"))
|
.or_else(|| starts_with("v1/beacon/blinded_blocks"))
|
||||||
.or_else(|| starts_with("v1/validator/duties/attester"))
|
.or_else(|| starts_with("v1/beacon/deposit_snapshot"))
|
||||||
.or_else(|| starts_with("v1/validator/duties/proposer"))
|
.or_else(|| starts_with("v1/beacon/headers"))
|
||||||
.or_else(|| starts_with("v1/validator/duties/sync"))
|
.or_else(|| starts_with("v1/beacon/light_client"))
|
||||||
.or_else(|| starts_with("v1/validator/attestation_data"))
|
|
||||||
.or_else(|| starts_with("v1/validator/aggregate_attestation"))
|
|
||||||
.or_else(|| starts_with("v2/validator/aggregate_attestation"))
|
|
||||||
.or_else(|| starts_with("v1/validator/aggregate_and_proofs"))
|
|
||||||
.or_else(|| starts_with("v2/validator/aggregate_and_proofs"))
|
|
||||||
.or_else(|| starts_with("v1/validator/sync_committee_contribution"))
|
|
||||||
.or_else(|| starts_with("v1/validator/contribution_and_proofs"))
|
|
||||||
.or_else(|| starts_with("v1/validator/beacon_committee_subscriptions"))
|
|
||||||
.or_else(|| starts_with("v1/validator/sync_committee_subscriptions"))
|
|
||||||
.or_else(|| starts_with("v1/beacon/pool/attestations"))
|
.or_else(|| starts_with("v1/beacon/pool/attestations"))
|
||||||
.or_else(|| starts_with("v2/beacon/pool/attestations"))
|
.or_else(|| starts_with("v2/beacon/pool/attestations"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/pool/attester_slashings"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/pool/bls_to_execution_changes"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/pool/proposer_slashings"))
|
||||||
.or_else(|| starts_with("v1/beacon/pool/sync_committees"))
|
.or_else(|| starts_with("v1/beacon/pool/sync_committees"))
|
||||||
.or_else(|| starts_with("v1/beacon/blocks/head/root"))
|
.or_else(|| starts_with("v1/beacon/pool/voluntary_exits"))
|
||||||
.or_else(|| starts_with("v1/validator/prepare_beacon_proposer"))
|
.or_else(|| starts_with("v1/beacon/rewards/blocks"))
|
||||||
.or_else(|| starts_with("v1/validator/register_validator"))
|
.or_else(|| starts_with("v1/beacon/rewards/attestations"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/rewards/sync_committee"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/rewards"))
|
||||||
|
.or_else(|| starts_with("v1/beacon/states"))
|
||||||
.or_else(|| starts_with("v1/beacon/"))
|
.or_else(|| starts_with("v1/beacon/"))
|
||||||
.or_else(|| starts_with("v2/beacon/"))
|
.or_else(|| starts_with("v2/beacon/"))
|
||||||
|
.or_else(|| starts_with("v1/builder/states"))
|
||||||
|
.or_else(|| starts_with("v1/config/deposit_contract"))
|
||||||
|
.or_else(|| starts_with("v1/config/fork_schedule"))
|
||||||
|
.or_else(|| starts_with("v1/config/spec"))
|
||||||
.or_else(|| starts_with("v1/config/"))
|
.or_else(|| starts_with("v1/config/"))
|
||||||
.or_else(|| starts_with("v1/debug/"))
|
.or_else(|| starts_with("v1/debug/"))
|
||||||
.or_else(|| starts_with("v2/debug/"))
|
.or_else(|| starts_with("v2/debug/"))
|
||||||
|
.or_else(|| starts_with("v1/events"))
|
||||||
.or_else(|| starts_with("v1/events/"))
|
.or_else(|| starts_with("v1/events/"))
|
||||||
.or_else(|| starts_with("v1/node/"))
|
.or_else(|| starts_with("v1/node/health"))
|
||||||
|
.or_else(|| starts_with("v1/node/identity"))
|
||||||
|
.or_else(|| starts_with("v1/node/peers"))
|
||||||
|
.or_else(|| starts_with("v1/node/peer_count"))
|
||||||
|
.or_else(|| starts_with("v1/node/syncing"))
|
||||||
|
.or_else(|| starts_with("v1/node/version"))
|
||||||
|
.or_else(|| starts_with("v1/node"))
|
||||||
|
.or_else(|| starts_with("v1/validator/aggregate_and_proofs"))
|
||||||
|
.or_else(|| starts_with("v2/validator/aggregate_and_proofs"))
|
||||||
|
.or_else(|| starts_with("v1/validator/aggregate_attestation"))
|
||||||
|
.or_else(|| starts_with("v2/validator/aggregate_attestation"))
|
||||||
|
.or_else(|| starts_with("v1/validator/attestation_data"))
|
||||||
|
.or_else(|| starts_with("v1/validator/beacon_committee_subscriptions"))
|
||||||
|
.or_else(|| starts_with("v1/validator/blinded_blocks"))
|
||||||
|
.or_else(|| starts_with("v2/validator/blinded_blocks"))
|
||||||
|
.or_else(|| starts_with("v1/validator/blocks"))
|
||||||
|
.or_else(|| starts_with("v2/validator/blocks"))
|
||||||
|
.or_else(|| starts_with("v3/validator/blocks"))
|
||||||
|
.or_else(|| starts_with("v1/validator/contribution_and_proofs"))
|
||||||
|
.or_else(|| starts_with("v1/validator/duties/attester"))
|
||||||
|
.or_else(|| starts_with("v1/validator/duties/proposer"))
|
||||||
|
.or_else(|| starts_with("v1/validator/duties/sync"))
|
||||||
|
.or_else(|| starts_with("v1/validator/liveness"))
|
||||||
|
.or_else(|| starts_with("v1/validator/prepare_beacon_proposer"))
|
||||||
|
.or_else(|| starts_with("v1/validator/register_validator"))
|
||||||
|
.or_else(|| starts_with("v1/validator/sync_committee_contribution"))
|
||||||
|
.or_else(|| starts_with("v1/validator/sync_committee_subscriptions"))
|
||||||
.or_else(|| starts_with("v1/validator/"))
|
.or_else(|| starts_with("v1/validator/"))
|
||||||
|
.or_else(|| starts_with("v2/validator/"))
|
||||||
|
.or_else(|| starts_with("v3/validator/"))
|
||||||
|
.or_else(|| starts_with("lighthouse"))
|
||||||
.unwrap_or("other")
|
.unwrap_or("other")
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -256,6 +287,38 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a `warp` logging wrapper which we use to create `tracing` logs.
|
||||||
|
pub fn tracing_logging() -> warp::filters::log::Log<impl Fn(warp::filters::log::Info) + Clone> {
|
||||||
|
warp::log::custom(move |info| {
|
||||||
|
let status = info.status();
|
||||||
|
// Ensure elapsed time is in milliseconds.
|
||||||
|
let elapsed = info.elapsed().as_secs_f64() * 1000.0;
|
||||||
|
let path = info.path();
|
||||||
|
let method = info.method().to_string();
|
||||||
|
|
||||||
|
if status == StatusCode::OK
|
||||||
|
|| status == StatusCode::NOT_FOUND
|
||||||
|
|| status == StatusCode::PARTIAL_CONTENT
|
||||||
|
{
|
||||||
|
debug!(
|
||||||
|
elapsed_ms = %elapsed,
|
||||||
|
status = %status,
|
||||||
|
path = %path,
|
||||||
|
method = %method,
|
||||||
|
"Processed HTTP API request"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
elapsed_ms = %elapsed,
|
||||||
|
status = %status,
|
||||||
|
path = %path,
|
||||||
|
method = %method,
|
||||||
|
"Error processing HTTP API request"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates a server that will serve requests using information from `ctx`.
|
/// Creates a server that will serve requests using information from `ctx`.
|
||||||
///
|
///
|
||||||
/// The server will shut down gracefully when the `shutdown` future resolves.
|
/// The server will shut down gracefully when the `shutdown` future resolves.
|
||||||
@@ -4884,6 +4947,7 @@ pub fn serve<T: BeaconChainTypes>(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.recover(warp_utils::reject::handle_rejection)
|
.recover(warp_utils::reject::handle_rejection)
|
||||||
|
.with(tracing_logging())
|
||||||
.with(prometheus_metrics())
|
.with(prometheus_metrics())
|
||||||
// Add a `Server` header.
|
// Add a `Server` header.
|
||||||
.map(|reply| warp::reply::with_header(reply, "Server", &version_with_platform()))
|
.map(|reply| warp::reply::with_header(reply, "Server", &version_with_platform()))
|
||||||
|
|||||||
Reference in New Issue
Block a user