Skip to content

Commit 4a594c9

Browse files
committed
style: use fully qualified name for tracing macros
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent cffef46 commit 4a594c9

File tree

22 files changed

+99
-109
lines changed

22 files changed

+99
-109
lines changed

crates/config/src/config.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use serde::Deserialize;
2222
use serde_repr::Deserialize_repr;
2323
use serde_with::{serde_as, DurationSecondsWithFrac};
2424
use thegraph_core::DeploymentId;
25-
use tracing::warn;
2625
use url::Url;
2726

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

6261
Ok(ConfigWrapper(config))
@@ -157,7 +156,7 @@ impl Config {
157156
x if *x <= 1.into() => {
158157
return Err("trigger_value_divisor must be greater than 1".to_string())
159158
}
160-
x if *x > 1.into() && *x < 10.into() => warn!(
159+
x if *x > 1.into() && *x < 10.into() => tracing::warn!(
161160
"It's recommended that trigger_value_divisor \
162161
be a value greater than 10."
163162
),
@@ -175,7 +174,7 @@ impl Config {
175174
.to_u128()
176175
.unwrap()
177176
{
178-
warn!(
177+
tracing::warn!(
179178
"Trigger value is too low, currently below 0.1 GRT. \
180179
Please modify `max_amount_willing_to_lose_grt` or `trigger_value_divisor`. \
181180
It is best to have a higher trigger value, ideally above 1 GRT. \
@@ -189,7 +188,7 @@ impl Config {
189188
let usual_grt_price = BigDecimal::from_str("0.0001").unwrap() * ten;
190189
if self.tap.max_amount_willing_to_lose_grt.get_value() < usual_grt_price.to_u128().unwrap()
191190
{
192-
warn!(
191+
tracing::warn!(
193192
"Your `max_amount_willing_to_lose_grt` value is too close to zero. \
194193
This may deny the sender too often or even break the whole system. \
195194
It's recommended it to be a value greater than 100x an usual query price."
@@ -199,7 +198,7 @@ impl Config {
199198
if self.subgraphs.escrow.config.syncing_interval_secs < Duration::from_secs(10)
200199
|| self.subgraphs.network.config.syncing_interval_secs < Duration::from_secs(10)
201200
{
202-
warn!(
201+
tracing::warn!(
203202
"Your `syncing_interval_secs` value it too low. \
204203
This may overload your graph-node instance, \
205204
a recommended value is about 60 seconds."
@@ -209,15 +208,15 @@ impl Config {
209208
if self.subgraphs.escrow.config.syncing_interval_secs > Duration::from_secs(600)
210209
|| self.subgraphs.network.config.syncing_interval_secs > Duration::from_secs(600)
211210
{
212-
warn!(
211+
tracing::warn!(
213212
"Your `syncing_interval_secs` value it too high. \
214213
This may cause issues while reacting to updates in the blockchain. \
215214
a recommended value is about 60 seconds."
216215
);
217216
}
218217

219218
if self.tap.rav_request.timestamp_buffer_secs < Duration::from_secs(10) {
220-
warn!(
219+
tracing::warn!(
221220
"Your `tap.rav_request.timestamp_buffer_secs` value it too low. \
222221
You may discart receipts in case of any synchronization issues, \
223222
a recommended value is about 30 seconds."

crates/monitor/src/attestation.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use indexer_allocation::Allocation;
1212
use indexer_attestation::AttestationSigner;
1313
use indexer_watcher::join_and_map_watcher;
1414
use tokio::sync::watch::Receiver;
15-
use tracing::warn;
1615

1716
use crate::{AllocationWatcher, DisputeManagerWatcher};
1817

@@ -66,7 +65,7 @@ fn modify_sigers(
6665
signers.insert(*id, signer);
6766
}
6867
Err(e) => {
69-
warn!(
68+
tracing::warn!(
7069
"Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}",
7170
allocation.id, allocation.subgraph_deployment.id,
7271
allocation.created_at_epoch, e

crates/monitor/src/client/subgraph_client.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use graphql_client::GraphQLQuery;
77
use reqwest::{header, Url};
88
use thegraph_core::DeploymentId;
99
use tokio::sync::watch::Receiver;
10-
use tracing::warn;
1110

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

@@ -202,7 +201,7 @@ impl SubgraphClient {
202201
if let Some(ref local_client) = self.local_client {
203202
match local_client.query::<Q>(variables.clone()).await {
204203
Ok(response) => return Ok(response),
205-
Err(err) => warn!(
204+
Err(err) => tracing::warn!(
206205
"Failed to query local subgraph deployment `{}`, trying remote deployment next: {}",
207206
local_client.query_url, err
208207
),
@@ -214,9 +213,10 @@ impl SubgraphClient {
214213
.query::<Q>(variables)
215214
.await
216215
.map_err(|err| {
217-
warn!(
216+
tracing::warn!(
218217
"Failed to query remote subgraph deployment `{}`: {}",
219-
self.remote_client.query_url, err
218+
self.remote_client.query_url,
219+
err
220220
);
221221

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

239239
// Try the remote client
240240
self.remote_client.query_raw(query).await.map_err(|err| {
241-
warn!(
241+
tracing::warn!(
242242
"Failed to query remote subgraph deployment `{}`: {}",
243-
self.remote_client.query_url, err
243+
self.remote_client.query_url,
244+
err
244245
);
245246

246247
err

crates/monitor/src/escrow_accounts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use anyhow::{anyhow, Result};
1212
use indexer_query::escrow_account::{self, EscrowAccountQuery};
1313
use thiserror::Error;
1414
use tokio::sync::watch::Receiver;
15-
use tracing::{error, warn};
1615

1716
use crate::client::SubgraphClient;
1817

@@ -133,7 +132,7 @@ async fn get_escrow_accounts(
133132
U256::from_str(&account.total_amount_thawing)?,
134133
)
135134
.unwrap_or_else(|| {
136-
warn!(
135+
tracing::warn!(
137136
"Balance minus total amount thawing underflowed for account {}. \
138137
Setting balance to 0, no queries will be served for this sender.",
139138
account.sender.id

crates/service/src/database/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ pub mod dips;
77
use std::time::Duration;
88

99
use sqlx::{postgres::PgPoolOptions, PgPool};
10-
use tracing::debug;
1110

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

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

1817
PgPoolOptions::new()
1918
.max_connections(DATABASE_MAX_CONNECTIONS)

crates/service/src/metrics.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use prometheus::{
1010
};
1111
use reqwest::StatusCode;
1212
use tokio::net::TcpListener;
13-
use tracing::{error, info};
1413

1514
lazy_static! {
1615
/// Metric registered in global registry for
@@ -37,7 +36,7 @@ lazy_static! {
3736
}
3837

3938
pub fn serve_metrics(host_and_port: SocketAddr) {
40-
info!(address = %host_and_port, "Serving prometheus metrics");
39+
tracing::info!(address = %host_and_port, "Serving prometheus metrics");
4140

4241
tokio::spawn(async move {
4342
let router = Router::new().route(
@@ -49,7 +48,7 @@ pub fn serve_metrics(host_and_port: SocketAddr) {
4948
match encoder.encode_to_string(&metric_families) {
5049
Ok(s) => (StatusCode::OK, s),
5150
Err(e) => {
52-
error!("Error encoding metrics: {}", e);
51+
tracing::error!("Error encoding metrics: {}", e);
5352
(
5453
StatusCode::INTERNAL_SERVER_ERROR,
5554
format!("Error encoding metrics: {}", e),

crates/service/src/routes/request_handler.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use axum::{
88
};
99
use reqwest::header::CONTENT_TYPE;
1010
use thegraph_core::DeploymentId;
11-
use tracing::trace;
1211

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

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

2524
let deployment_url = state
2625
.graph_node_query_base_url

crates/service/src/routes/static_subgraph.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use axum::{body::Bytes, extract::State, response::IntoResponse, Json};
55
use indexer_monitor::SubgraphClient;
66
use reqwest::StatusCode;
77
use serde_json::json;
8-
use tracing::warn;
98

109
#[autometrics::autometrics]
1110
pub async fn static_subgraph_request_handler(
@@ -18,7 +17,7 @@ pub async fn static_subgraph_request_handler(
1817
response.status(),
1918
response.headers().to_owned(),
2019
response.text().await.inspect_err(|e| {
21-
warn!("Failed to read response body: {}", e);
20+
tracing::warn!("Failed to read response body: {}", e);
2221
})?,
2322
))
2423
}

crates/service/src/service.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use reqwest::Url;
1313
use tap_core::tap_eip712_domain;
1414
use tokio::{net::TcpListener, signal};
1515
use tower_http::normalize_path::NormalizePath;
16-
use tracing::{error, info};
1716

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

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

109108
serve_metrics(config.metrics.get_socket_addr());
110109

111-
info!(
110+
tracing::info!(
112111
address = %host_and_port,
113112
"Serving requests",
114113
);
@@ -169,5 +168,5 @@ async fn shutdown_handler() {
169168
_ = terminate => {},
170169
}
171170

172-
info!("Signal received, starting graceful shutdown");
171+
tracing::info!("Signal received, starting graceful shutdown");
173172
}

crates/service/src/service/router.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use tower_http::{
3434
trace::TraceLayer,
3535
validate_request::ValidateRequestHeaderLayer,
3636
};
37-
use tracing::{info, info_span, warn};
3837
use typed_builder::TypedBuilder;
3938

4039
use super::{release::IndexerServiceRelease, GraphNodeState};
@@ -221,7 +220,7 @@ impl ServiceRouter {
221220
self.network_subgraph.as_ref(),
222221
) {
223222
(Some(free_auth_token), true, Some((network_subgraph, _))) => {
224-
info!("Serving network subgraph at /network");
223+
tracing::info!("Serving network subgraph at /network");
225224

226225
let auth_layer = ValidateRequestHeaderLayer::bearer(free_auth_token);
227226

@@ -234,7 +233,7 @@ impl ServiceRouter {
234233
)
235234
}
236235
(_, true, _) => {
237-
warn!("`serve_network_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
236+
tracing::warn!("`serve_network_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
238237
Router::new()
239238
}
240239
_ => Router::new(),
@@ -247,7 +246,7 @@ impl ServiceRouter {
247246
self.escrow_subgraph,
248247
) {
249248
(Some(free_auth_token), true, Some((escrow_subgraph, _))) => {
250-
info!("Serving escrow subgraph at /escrow");
249+
tracing::info!("Serving escrow subgraph at /escrow");
251250

252251
let auth_layer = ValidateRequestHeaderLayer::bearer(free_auth_token);
253252

@@ -260,7 +259,7 @@ impl ServiceRouter {
260259
)
261260
}
262261
(_, true, _) => {
263-
warn!("`serve_escrow_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
262+
tracing::warn!("`serve_escrow_subgraph` is enabled but no `serve_auth_token` provided. Disabling it.");
264263
Router::new()
265264
}
266265
_ => Router::new(),
@@ -366,7 +365,7 @@ impl ServiceRouter {
366365
.get::<MatchedPath>()
367366
.map(MatchedPath::as_str);
368367

369-
info_span!(
368+
tracing::info_span!(
370369
"http_request",
371370
%method,
372371
%uri,

0 commit comments

Comments
 (0)