Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tracing #111

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions server/src/http.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use axum::extract::MatchedPath;
use axum::http::Request;
use axum::response::{Html, Redirect};
use std::{net::SocketAddr, sync::Arc};

Expand All @@ -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;
Expand Down Expand Up @@ -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::<MatchedPath>()
.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 }
Expand Down
12 changes: 8 additions & 4 deletions shared/src/core/resolvers/universal.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -88,6 +90,8 @@ pub async fn resolve_universal(
ProfileError::RPCError(provider_error)
})?;

drop(span);

// Abi Decode
let result = abi::decode(
&[
Expand Down
Loading