Skip to content

Commit

Permalink
style: use full path for tracing macros
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Delgado <[email protected]>
  • Loading branch information
LNSD committed Dec 20, 2024
1 parent ae4f43e commit f4d375a
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 108 deletions.
15 changes: 7 additions & 8 deletions crates/config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use serde::Deserialize;
use serde_repr::Deserialize_repr;
use serde_with::{serde_as, DurationSecondsWithFrac};
use thegraph_core::DeploymentId;
use tracing::warn;
use url::Url;

use crate::NonZeroGRT;
Expand Down Expand Up @@ -56,7 +55,7 @@ impl<'de> Deserialize<'de> for ConfigWrapper {
D: serde::Deserializer<'de>,
{
let config: Config = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown configuration field: {}", path);
tracing::warn!("Ignoring unknown configuration field: {}", path);
})?;

Ok(ConfigWrapper(config))
Expand Down Expand Up @@ -157,7 +156,7 @@ impl Config {
x if *x <= 1.into() => {
return Err("trigger_value_divisor must be greater than 1".to_string())
}
x if *x > 1.into() && *x < 10.into() => warn!(
x if *x > 1.into() && *x < 10.into() => tracing::warn!(
"It's recommended that trigger_value_divisor \
be a value greater than 10."
),
Expand All @@ -175,7 +174,7 @@ impl Config {
.to_u128()
.unwrap()
{
warn!(
tracing::warn!(
"Trigger value is too low, currently below 0.1 GRT. \
Please modify `max_amount_willing_to_lose_grt` or `trigger_value_divisor`. \
It is best to have a higher trigger value, ideally above 1 GRT. \
Expand All @@ -189,7 +188,7 @@ impl Config {
let usual_grt_price = BigDecimal::from_str("0.0001").unwrap() * ten;
if self.tap.max_amount_willing_to_lose_grt.get_value() < usual_grt_price.to_u128().unwrap()
{
warn!(
tracing::warn!(
"Your `max_amount_willing_to_lose_grt` value is too close to zero. \
This may deny the sender too often or even break the whole system. \
It's recommended it to be a value greater than 100x an usual query price."
Expand All @@ -199,7 +198,7 @@ impl Config {
if self.subgraphs.escrow.config.syncing_interval_secs < Duration::from_secs(10)
|| self.subgraphs.network.config.syncing_interval_secs < Duration::from_secs(10)
{
warn!(
tracing::warn!(
"Your `syncing_interval_secs` value it too low. \
This may overload your graph-node instance, \
a recommended value is about 60 seconds."
Expand All @@ -209,15 +208,15 @@ impl Config {
if self.subgraphs.escrow.config.syncing_interval_secs > Duration::from_secs(600)
|| self.subgraphs.network.config.syncing_interval_secs > Duration::from_secs(600)
{
warn!(
tracing::warn!(
"Your `syncing_interval_secs` value it too high. \
This may cause issues while reacting to updates in the blockchain. \
a recommended value is about 60 seconds."
);
}

if self.tap.rav_request.timestamp_buffer_secs < Duration::from_secs(10) {
warn!(
tracing::warn!(
"Your `tap.rav_request.timestamp_buffer_secs` value it too low. \
You may discart receipts in case of any synchronization issues, \
a recommended value is about 30 seconds."
Expand Down
3 changes: 1 addition & 2 deletions crates/monitor/src/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use indexer_allocation::Allocation;
use indexer_attestation::AttestationSigner;
use indexer_watcher::join_and_map_watcher;
use tokio::sync::watch::Receiver;
use tracing::warn;

use crate::{AllocationWatcher, DisputeManagerWatcher};

Expand Down Expand Up @@ -66,7 +65,7 @@ fn modify_sigers(
signers.insert(*id, signer);
}
Err(e) => {
warn!(
tracing::warn!(
"Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}",
allocation.id, allocation.subgraph_deployment.id,
allocation.created_at_epoch, e
Expand Down
15 changes: 8 additions & 7 deletions crates/monitor/src/client/subgraph_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use graphql_client::GraphQLQuery;
use reqwest::{header, Url};
use thegraph_core::DeploymentId;
use tokio::sync::watch::Receiver;
use tracing::warn;

use super::monitor::{monitor_deployment_status, DeploymentStatus};

Expand Down Expand Up @@ -202,7 +201,7 @@ impl SubgraphClient {
if let Some(ref local_client) = self.local_client {
match local_client.query::<Q>(variables.clone()).await {
Ok(response) => return Ok(response),
Err(err) => warn!(
Err(err) => tracing::warn!(
"Failed to query local subgraph deployment `{}`, trying remote deployment next: {}",
local_client.query_url, err
),
Expand All @@ -214,9 +213,10 @@ impl SubgraphClient {
.query::<Q>(variables)
.await
.map_err(|err| {
warn!(
tracing::warn!(
"Failed to query remote subgraph deployment `{}`: {}",
self.remote_client.query_url, err
self.remote_client.query_url,
err
);

err
Expand All @@ -229,7 +229,7 @@ impl SubgraphClient {
if let Some(ref local_client) = self.local_client {
match local_client.query_raw(query.clone()).await {
Ok(response) => return Ok(response),
Err(err) => warn!(
Err(err) => tracing::warn!(
"Failed to query local subgraph deployment `{}`, trying remote deployment next: {}",
local_client.query_url, err
),
Expand All @@ -238,9 +238,10 @@ impl SubgraphClient {

// Try the remote client
self.remote_client.query_raw(query).await.map_err(|err| {
warn!(
tracing::warn!(
"Failed to query remote subgraph deployment `{}`: {}",
self.remote_client.query_url, err
self.remote_client.query_url,
err
);

err
Expand Down
3 changes: 1 addition & 2 deletions crates/monitor/src/escrow_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use anyhow::{anyhow, Result};
use indexer_query::escrow_account::{self, EscrowAccountQuery};
use thiserror::Error;
use tokio::sync::watch::Receiver;
use tracing::{error, warn};

use crate::client::SubgraphClient;

Expand Down Expand Up @@ -133,7 +132,7 @@ async fn get_escrow_accounts(
U256::from_str(&account.total_amount_thawing)?,
)
.unwrap_or_else(|| {
warn!(
tracing::warn!(
"Balance minus total amount thawing underflowed for account {}. \
Setting balance to 0, no queries will be served for this sender.",
account.sender.id
Expand Down
3 changes: 1 addition & 2 deletions crates/service/src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ pub mod dips;
use std::time::Duration;

use sqlx::{postgres::PgPoolOptions, PgPool};
use tracing::debug;

const DATABASE_TIMEOUT: Duration = Duration::from_secs(30);
const DATABASE_MAX_CONNECTIONS: u32 = 50;

pub async fn connect(url: &str) -> PgPool {
debug!("Connecting to database");
tracing::debug!("Connecting to database");

PgPoolOptions::new()
.max_connections(DATABASE_MAX_CONNECTIONS)
Expand Down
5 changes: 2 additions & 3 deletions crates/service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use prometheus::{
};
use reqwest::StatusCode;
use tokio::net::TcpListener;
use tracing::{error, info};

lazy_static! {
/// Metric registered in global registry for
Expand All @@ -37,7 +36,7 @@ lazy_static! {
}

pub fn serve_metrics(host_and_port: SocketAddr) {
info!(address = %host_and_port, "Serving prometheus metrics");
tracing::info!(address = %host_and_port, "Serving prometheus metrics");

tokio::spawn(async move {
let router = Router::new().route(
Expand All @@ -49,7 +48,7 @@ pub fn serve_metrics(host_and_port: SocketAddr) {
match encoder.encode_to_string(&metric_families) {
Ok(s) => (StatusCode::OK, s),
Err(e) => {
error!("Error encoding metrics: {}", e);
tracing::error!("Error encoding metrics: {}", e);
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Error encoding metrics: {}", e),
Expand Down
3 changes: 1 addition & 2 deletions crates/service/src/routes/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use axum::{
};
use reqwest::header::CONTENT_TYPE;
use thegraph_core::DeploymentId;
use tracing::trace;

use crate::{error::SubgraphServiceError, middleware::AttestationInput, service::GraphNodeState};

Expand All @@ -20,7 +19,7 @@ pub async fn request_handler(
State(state): State<GraphNodeState>,
req: String,
) -> Result<impl IntoResponse, SubgraphServiceError> {
trace!("Handling request for deployment `{deployment}`");
tracing::trace!("Handling request for deployment `{deployment}`");

let deployment_url = state
.graph_node_query_base_url
Expand Down
3 changes: 1 addition & 2 deletions crates/service/src/routes/static_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use axum::{body::Bytes, extract::State, response::IntoResponse, Json};
use indexer_monitor::SubgraphClient;
use reqwest::StatusCode;
use serde_json::json;
use tracing::warn;

#[autometrics::autometrics]
pub async fn static_subgraph_request_handler(
Expand All @@ -18,7 +17,7 @@ pub async fn static_subgraph_request_handler(
response.status(),
response.headers().to_owned(),
response.text().await.inspect_err(|e| {
warn!("Failed to read response body: {}", e);
tracing::warn!("Failed to read response body: {}", e);
})?,
))
}
Expand Down
7 changes: 3 additions & 4 deletions crates/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use reqwest::Url;
use tap_core::tap_eip712_domain;
use tokio::{net::TcpListener, signal};
use tower_http::normalize_path::NormalizePath;
use tracing::{error, info};

use crate::{cli::Cli, database, metrics::serve_metrics};

Expand Down Expand Up @@ -41,7 +40,7 @@ pub async fn run() -> anyhow::Result<()> {
// Load the service configuration
let config = Config::parse(indexer_config::ConfigPrefix::Service, cli.config.as_ref())
.map_err(|e| {
error!(
tracing::error!(
"Invalid configuration file `{}`: {}, if a value is missing you can also use \
--config to fill the rest of the values",
cli.config.unwrap_or_default().display(),
Expand Down Expand Up @@ -108,7 +107,7 @@ pub async fn run() -> anyhow::Result<()> {

serve_metrics(config.metrics.get_socket_addr());

info!(
tracing::info!(
address = %host_and_port,
"Serving requests",
);
Expand Down Expand Up @@ -169,5 +168,5 @@ async fn shutdown_handler() {
_ = terminate => {},
}

info!("Signal received, starting graceful shutdown");
tracing::info!("Signal received, starting graceful shutdown");
}
11 changes: 5 additions & 6 deletions crates/service/src/service/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use tower_http::{
trace::TraceLayer,
validate_request::ValidateRequestHeaderLayer,
};
use tracing::{info, info_span, warn};
use typed_builder::TypedBuilder;

use super::{release::IndexerServiceRelease, GraphNodeState};
Expand Down Expand Up @@ -221,7 +220,7 @@ impl ServiceRouter {
self.network_subgraph.as_ref(),
) {
(Some(free_auth_token), true, Some((network_subgraph, _))) => {
info!("Serving network subgraph at /network");
tracing::info!("Serving network subgraph at /network");

let auth_layer = ValidateRequestHeaderLayer::bearer(free_auth_token);

Expand All @@ -234,7 +233,7 @@ impl ServiceRouter {
)
}
(_, true, _) => {
warn!("`serve_network_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
tracing::warn!("`serve_network_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
Router::new()
}
_ => Router::new(),
Expand All @@ -247,7 +246,7 @@ impl ServiceRouter {
self.escrow_subgraph,
) {
(Some(free_auth_token), true, Some((escrow_subgraph, _))) => {
info!("Serving escrow subgraph at /escrow");
tracing::info!("Serving escrow subgraph at /escrow");

let auth_layer = ValidateRequestHeaderLayer::bearer(free_auth_token);

Expand All @@ -260,7 +259,7 @@ impl ServiceRouter {
)
}
(_, true, _) => {
warn!("`serve_escrow_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
tracing::warn!("`serve_escrow_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
Router::new()
}
_ => Router::new(),
Expand Down Expand Up @@ -366,7 +365,7 @@ impl ServiceRouter {
.get::<MatchedPath>()
.map(MatchedPath::as_str);

info_span!(
tracing::info_span!(
"http_request",
%method,
%uri,
Expand Down
1 change: 0 additions & 1 deletion crates/service/src/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use tokio::sync::{
watch::Receiver,
};
use tokio_util::sync::CancellationToken;
use tracing::error;

use crate::tap::checks::{
allocation_eligible::AllocationEligible, deny_list_check::DenyListCheck,
Expand Down
3 changes: 1 addition & 2 deletions crates/service/src/tap/checks/deny_list_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use tap_core::receipt::{
state::Checking,
ReceiptWithState,
};
use tracing::error;

use crate::middleware::Sender;

Expand Down Expand Up @@ -134,7 +133,7 @@ impl DenyListCheck {
}
// UPDATE and TRUNCATE are not expected to happen. Reload the entire denylist.
_ => {
error!(
tracing::error!(
"Received an unexpected denylist table notification: {}. Reloading entire \
denylist.",
denylist_notification.tg_op
Expand Down
7 changes: 3 additions & 4 deletions crates/service/src/tap/checks/value_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use tap_core::receipt::{
Context, ReceiptWithState,
};
use thegraph_core::DeploymentId;
use tracing::error;

use crate::database::cost_model;

Expand Down Expand Up @@ -134,7 +133,7 @@ impl CostModelWatcher {
cost_model_write.insert(deployment_id, model);
}
Err(_) => {
error!(
tracing::error!(
"Received insert request for an invalid deployment_id: {}",
deployment_id
)
Expand All @@ -155,7 +154,7 @@ impl CostModelWatcher {
self.cost_models.write().unwrap().remove(&deployment_id);
}
Err(_) => {
error!(
tracing::error!(
"Received delete request for an invalid deployment_id: {}",
deployment_id
)
Expand All @@ -166,7 +165,7 @@ impl CostModelWatcher {
}

async fn handle_unexpected_notification(&self, payload: &str) {
error!(
tracing::error!(
"Received an unexpected cost model table notification: {}. Reloading entire \
cost model.",
payload
Expand Down
Loading

0 comments on commit f4d375a

Please sign in to comment.