@@ -215,35 +215,66 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
215215
216216 // First line covers `POST /v1/beacon/blocks` only
217217 equals ( "v1/beacon/blocks" )
218- . or_else ( || starts_with ( "v1/validator/blocks" ) )
219- . or_else ( || starts_with ( "v2/validator/blocks" ) )
220- . or_else ( || starts_with ( "v1/validator/blinded_blocks" ) )
221- . or_else ( || starts_with ( "v1/validator/duties/attester" ) )
222- . or_else ( || starts_with ( "v1/validator/duties/proposer" ) )
223- . or_else ( || starts_with ( "v1/validator/duties/sync" ) )
224- . or_else ( || starts_with ( "v1/validator/attestation_data" ) )
225- . or_else ( || starts_with ( "v1/validator/aggregate_attestation" ) )
226- . or_else ( || starts_with ( "v2/validator/aggregate_attestation" ) )
227- . or_else ( || starts_with ( "v1/validator/aggregate_and_proofs" ) )
228- . or_else ( || starts_with ( "v2/validator/aggregate_and_proofs" ) )
229- . or_else ( || starts_with ( "v1/validator/sync_committee_contribution" ) )
230- . or_else ( || starts_with ( "v1/validator/contribution_and_proofs" ) )
231- . or_else ( || starts_with ( "v1/validator/beacon_committee_subscriptions" ) )
232- . or_else ( || starts_with ( "v1/validator/sync_committee_subscriptions" ) )
218+ . or_else ( || starts_with ( "v1/beacon/blob_sidecars" ) )
219+ . or_else ( || starts_with ( "v1/beacon/blocks/head/root" ) )
220+ . or_else ( || starts_with ( "v1/beacon/blinded_blocks" ) )
221+ . or_else ( || starts_with ( "v1/beacon/deposit_snapshot" ) )
222+ . or_else ( || starts_with ( "v1/beacon/headers" ) )
223+ . or_else ( || starts_with ( "v1/beacon/light_client" ) )
233224 . or_else ( || starts_with ( "v1/beacon/pool/attestations" ) )
234225 . or_else ( || starts_with ( "v2/beacon/pool/attestations" ) )
226+ . or_else ( || starts_with ( "v1/beacon/pool/attester_slashings" ) )
227+ . or_else ( || starts_with ( "v1/beacon/pool/bls_to_execution_changes" ) )
228+ . or_else ( || starts_with ( "v1/beacon/pool/proposer_slashings" ) )
235229 . or_else ( || starts_with ( "v1/beacon/pool/sync_committees" ) )
236- . or_else ( || starts_with ( "v1/beacon/blocks/head/root" ) )
237- . or_else ( || starts_with ( "v1/validator/prepare_beacon_proposer" ) )
238- . or_else ( || starts_with ( "v1/validator/register_validator" ) )
230+ . or_else ( || starts_with ( "v1/beacon/pool/voluntary_exits" ) )
231+ . or_else ( || starts_with ( "v1/beacon/rewards/blocks" ) )
232+ . or_else ( || starts_with ( "v1/beacon/rewards/attestations" ) )
233+ . or_else ( || starts_with ( "v1/beacon/rewards/sync_committee" ) )
234+ . or_else ( || starts_with ( "v1/beacon/rewards" ) )
235+ . or_else ( || starts_with ( "v1/beacon/states" ) )
239236 . or_else ( || starts_with ( "v1/beacon/" ) )
240237 . or_else ( || starts_with ( "v2/beacon/" ) )
238+ . or_else ( || starts_with ( "v1/builder/states" ) )
239+ . or_else ( || starts_with ( "v1/config/deposit_contract" ) )
240+ . or_else ( || starts_with ( "v1/config/fork_schedule" ) )
241+ . or_else ( || starts_with ( "v1/config/spec" ) )
241242 . or_else ( || starts_with ( "v1/config/" ) )
242243 . or_else ( || starts_with ( "v1/debug/" ) )
243244 . or_else ( || starts_with ( "v2/debug/" ) )
245+ . or_else ( || starts_with ( "v1/events" ) )
244246 . or_else ( || starts_with ( "v1/events/" ) )
245- . or_else ( || starts_with ( "v1/node/" ) )
247+ . or_else ( || starts_with ( "v1/node/health" ) )
248+ . or_else ( || starts_with ( "v1/node/identity" ) )
249+ . or_else ( || starts_with ( "v1/node/peers" ) )
250+ . or_else ( || starts_with ( "v1/node/peer_count" ) )
251+ . or_else ( || starts_with ( "v1/node/syncing" ) )
252+ . or_else ( || starts_with ( "v1/node/version" ) )
253+ . or_else ( || starts_with ( "v1/node" ) )
254+ . or_else ( || starts_with ( "v1/validator/aggregate_and_proofs" ) )
255+ . or_else ( || starts_with ( "v2/validator/aggregate_and_proofs" ) )
256+ . or_else ( || starts_with ( "v1/validator/aggregate_attestation" ) )
257+ . or_else ( || starts_with ( "v2/validator/aggregate_attestation" ) )
258+ . or_else ( || starts_with ( "v1/validator/attestation_data" ) )
259+ . or_else ( || starts_with ( "v1/validator/beacon_committee_subscriptions" ) )
260+ . or_else ( || starts_with ( "v1/validator/blinded_blocks" ) )
261+ . or_else ( || starts_with ( "v2/validator/blinded_blocks" ) )
262+ . or_else ( || starts_with ( "v1/validator/blocks" ) )
263+ . or_else ( || starts_with ( "v2/validator/blocks" ) )
264+ . or_else ( || starts_with ( "v3/validator/blocks" ) )
265+ . or_else ( || starts_with ( "v1/validator/contribution_and_proofs" ) )
266+ . or_else ( || starts_with ( "v1/validator/duties/attester" ) )
267+ . or_else ( || starts_with ( "v1/validator/duties/proposer" ) )
268+ . or_else ( || starts_with ( "v1/validator/duties/sync" ) )
269+ . or_else ( || starts_with ( "v1/validator/liveness" ) )
270+ . or_else ( || starts_with ( "v1/validator/prepare_beacon_proposer" ) )
271+ . or_else ( || starts_with ( "v1/validator/register_validator" ) )
272+ . or_else ( || starts_with ( "v1/validator/sync_committee_contribution" ) )
273+ . or_else ( || starts_with ( "v1/validator/sync_committee_subscriptions" ) )
246274 . or_else ( || starts_with ( "v1/validator/" ) )
275+ . or_else ( || starts_with ( "v2/validator/" ) )
276+ . or_else ( || starts_with ( "v3/validator/" ) )
277+ . or_else ( || starts_with ( "lighthouse" ) )
247278 . unwrap_or ( "other" )
248279 } ;
249280
@@ -256,6 +287,38 @@ pub fn prometheus_metrics() -> warp::filters::log::Log<impl Fn(warp::filters::lo
256287 } )
257288}
258289
290+ /// Creates a `warp` logging wrapper which we use to create `tracing` logs.
291+ pub fn tracing_logging ( ) -> warp:: filters:: log:: Log < impl Fn ( warp:: filters:: log:: Info ) + Clone > {
292+ warp:: log:: custom ( move |info| {
293+ let status = info. status ( ) ;
294+ // Ensure elapsed time is in milliseconds.
295+ let elapsed = info. elapsed ( ) . as_secs_f64 ( ) * 1000.0 ;
296+ let path = info. path ( ) ;
297+ let method = info. method ( ) . to_string ( ) ;
298+
299+ if status == StatusCode :: OK
300+ || status == StatusCode :: NOT_FOUND
301+ || status == StatusCode :: PARTIAL_CONTENT
302+ {
303+ debug ! (
304+ elapsed_ms = %elapsed,
305+ status = %status,
306+ path = %path,
307+ method = %method,
308+ "Processed HTTP API request"
309+ ) ;
310+ } else {
311+ warn ! (
312+ elapsed_ms = %elapsed,
313+ status = %status,
314+ path = %path,
315+ method = %method,
316+ "Error processing HTTP API request"
317+ ) ;
318+ }
319+ } )
320+ }
321+
259322/// Creates a server that will serve requests using information from `ctx`.
260323///
261324/// The server will shut down gracefully when the `shutdown` future resolves.
@@ -4884,6 +4947,7 @@ pub fn serve<T: BeaconChainTypes>(
48844947 ) ,
48854948 )
48864949 . recover ( warp_utils:: reject:: handle_rejection)
4950+ . with ( tracing_logging ( ) )
48874951 . with ( prometheus_metrics ( ) )
48884952 // Add a `Server` header.
48894953 . map ( |reply| warp:: reply:: with_header ( reply, "Server" , & version_with_platform ( ) ) )
0 commit comments