diff --git a/server/src/http.rs b/server/src/http.rs index 7b8f65d..4a8bed2 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -1,3 +1,5 @@ +use axum::extract::MatchedPath; +use axum::http::Request; use axum::response::{Html, Redirect}; use std::{net::SocketAddr, sync::Arc}; @@ -6,7 +8,7 @@ use tokio::net::TcpListener; use tokio_util::sync::CancellationToken; use tower_http::cors::CorsLayer; use tower_http::trace::TraceLayer; -use tracing::info; +use tracing::{info, info_span}; use crate::routes; use crate::state::AppState; @@ -77,7 +79,23 @@ pub fn setup(state: AppState) -> App { .route("/metrics", get(metrics::handle)) .fallback(routes::four_oh_four::handler) .layer(CorsLayer::permissive()) - .layer(TraceLayer::new_for_http()) + .layer( + TraceLayer::new_for_http().make_span_with(|request: &Request<_>| { + // Log the matched route's path (with placeholders not filled in). + // Use request.uri() or OriginalUri if you want the real path. + let matched_path = request + .extensions() + .get::() + .map(MatchedPath::as_str); + + info_span!( + "http_request", + method = ?request.method(), + matched_path, + some_other_field = tracing::field::Empty, + ) + }), + ) .with_state(Arc::new(state)); App { router } diff --git a/shared/src/core/resolvers/universal.rs b/shared/src/core/resolvers/universal.rs index 22dc098..c2e2a3b 100644 --- a/shared/src/core/resolvers/universal.rs +++ b/shared/src/core/resolvers/universal.rs @@ -1,20 +1,20 @@ use std::vec; +use ethers::prelude::ProviderError::JsonRpcClientError; use ethers::{ providers::namehash, - types::{Address, Bytes, transaction::eip2718::TypedTransaction}, + types::{transaction::eip2718::TypedTransaction, Address, Bytes}, }; -use ethers::prelude::ProviderError::JsonRpcClientError; use ethers_ccip_read::{CCIPReadMiddlewareError, CCIPRequest}; use ethers_core::abi; use ethers_core::abi::{ParamType, Token}; use ethers_core::types::H160; use hex_literal::hex; use lazy_static::lazy_static; -use tracing::instrument; +use tracing::{instrument, span}; -use crate::core::CCIPProvider; use crate::core::error::ProfileError; +use crate::core::CCIPProvider; use crate::models::lookup::ENSLookup; use crate::utils::dns::dns_encode; use crate::utils::vec::dedup_ord; @@ -66,6 +66,8 @@ pub async fn resolve_universal( typed_transaction.set_to(*universal_resolver); typed_transaction.set_data(Bytes::from(transaction_data)); + let span = span!(tracing::Level::INFO, "ccip_call", name = name); + // Call the transaction let (res, ccip_requests) = provider @@ -88,6 +90,8 @@ pub async fn resolve_universal( ProfileError::RPCError(provider_error) })?; + drop(span); + // Abi Decode let result = abi::decode( &[