Skip to content

Commit a58c416

Browse files
committed
refactor(logging): switch to structured tracing; fix typos and minor renames
• Replace string-interpolated logs with structured fields (tracing) for machine-parsable, consistent logs and lower formatting overhead. • main, metrics, routes, service: convert logs to structured fields (error, deployment, addr, config_path, etc.); fix typo “occoured” -> “occurred”. • tap-agent: • sender_account, sender_accounts_manager, sender_allocation, metrics, tracker/, tap/: widespread conversion to structured logs; clarify messages and add useful fields (allocation_id, sender, fees, counts, channel, code, etc.). • Derive Debug for DenyListVersion to improve log output. • No functional changes intended; only logging structure, readability, and typo fixes.
1 parent 0c20088 commit a58c416

23 files changed

+210
-239
lines changed

crates/monitor/src/allocations.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ pub async fn get_allocations(
8888
.collect();
8989

9090
tracing::info!(
91-
"Network subgraph query returned {} allocations for indexer {}",
92-
result.len(),
93-
indexer_address
91+
allocations = result.len(),
92+
indexer_address = ?indexer_address,
93+
"Network subgraph query returned allocations for indexer"
9494
);
9595

9696
Ok(result)

crates/monitor/src/attestation.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn attestation_signers(
3434
dispute_manager_rx,
3535
move |(allocation, dispute)| {
3636
let indexer_mnemonic = indexer_mnemonic.clone();
37-
modify_sigers(
37+
modify_signers(
3838
&indexer_mnemonic,
3939
chain_id,
4040
attestation_signers_map,
@@ -44,7 +44,7 @@ pub fn attestation_signers(
4444
},
4545
)
4646
}
47-
fn modify_sigers(
47+
fn modify_signers(
4848
indexer_mnemonic: &str,
4949
chain_id: ChainId,
5050
attestation_signers_map: &'static Mutex<HashMap<Address, AttestationSigner>>,
@@ -59,30 +59,34 @@ fn modify_sigers(
5959
for (id, allocation) in allocations.iter() {
6060
if !signers.contains_key(id) {
6161
tracing::debug!(
62-
"Attempting to create attestation signer for allocation {}, deployment {}, createdAtEpoch {}",
63-
allocation.id, allocation.subgraph_deployment.id, allocation.created_at_epoch
62+
allocation_id = ?allocation.id,
63+
deployment_id = ?allocation.subgraph_deployment.id,
64+
created_at_epoch = allocation.created_at_epoch,
65+
"Attempting to create attestation signer for allocation"
6466
);
6567

6668
let signer =
6769
AttestationSigner::new(indexer_mnemonic, allocation, chain_id, *dispute_manager);
6870
match signer {
6971
Ok(signer) => {
7072
tracing::debug!(
71-
"Successfully created attestation signer for allocation {}",
72-
allocation.id
73+
allocation_id = ?allocation.id,
74+
"Successfully created attestation signer for allocation"
7375
);
7476
signers.insert(*id, signer);
7577
}
7678
Err(e) => {
7779
tracing::warn!(
78-
"Failed to establish signer for allocation {}, deployment {}, createdAtEpoch {}: {}",
79-
allocation.id, allocation.subgraph_deployment.id,
80-
allocation.created_at_epoch, e
80+
allocation_id = ?allocation.id,
81+
deployment_id = ?allocation.subgraph_deployment.id,
82+
created_at_epoch = allocation.created_at_epoch,
83+
error = %e,
84+
"Failed to establish signer for allocation"
8185
);
8286
tracing::debug!(
83-
"Signer creation error details for allocation {}: {}",
84-
allocation.id,
85-
e
87+
allocation_id = ?allocation.id,
88+
error = %e,
89+
"Signer creation error details"
8690
);
8791
}
8892
}

crates/monitor/src/client/subgraph_client.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ impl SubgraphClient {
199199
match local_client.query::<Q>(variables.clone()).await {
200200
Ok(response) => return Ok(response),
201201
Err(err) => tracing::warn!(
202-
"Failed to query local subgraph deployment `{}`, trying remote deployment next: {}",
203-
local_client.query_url, err
202+
query_url = %local_client.query_url,
203+
error = %err,
204+
"Failed to query local subgraph deployment; trying remote deployment next"
204205
),
205206
}
206207
}
@@ -211,9 +212,9 @@ impl SubgraphClient {
211212
.await
212213
.map_err(|err| {
213214
tracing::warn!(
214-
"Failed to query remote subgraph deployment `{}`: {}",
215-
self.remote_client.query_url,
216-
err
215+
query_url = %self.remote_client.query_url,
216+
error = %err,
217+
"Failed to query remote subgraph deployment"
217218
);
218219

219220
err
@@ -227,18 +228,19 @@ impl SubgraphClient {
227228
match local_client.query_raw(query.clone()).await {
228229
Ok(response) => return Ok(response),
229230
Err(err) => tracing::warn!(
230-
"Failed to query local subgraph deployment `{}`, trying remote deployment next: {}",
231-
local_client.query_url, err
231+
query_url = %local_client.query_url,
232+
error = %err,
233+
"Failed to query local subgraph deployment; trying remote deployment next"
232234
),
233235
}
234236
}
235237

236238
// Try the remote client
237239
self.remote_client.query_raw(query).await.map_err(|err| {
238240
tracing::warn!(
239-
"Failed to query remote subgraph deployment `{}`: {}",
240-
self.remote_client.query_url,
241-
err
241+
query_url = %self.remote_client.query_url,
242+
error = %err,
243+
"Failed to query remote subgraph deployment"
242244
);
243245

244246
err

crates/monitor/src/escrow_accounts.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ async fn get_escrow_accounts_v2(
148148
reject_thawing_signers: bool,
149149
) -> anyhow::Result<EscrowAccounts> {
150150
tracing::trace!(
151-
"Loading V2 escrow accounts for indexer {}, reject_thawing_signers: {}",
152-
indexer_address,
153-
reject_thawing_signers
151+
indexer_address = ?indexer_address,
152+
reject_thawing_signers,
153+
"Loading V2 escrow accounts for indexer"
154154
);
155155
// Query V2 escrow accounts from the network subgraph which tracks PaymentsEscrow
156156
// and GraphTallyCollector contract events.
@@ -195,9 +195,8 @@ async fn get_escrow_accounts_v2(
195195
)
196196
.unwrap_or_else(|| {
197197
tracing::warn!(
198-
"Balance minus total amount thawing underflowed for V2 account {}. \
199-
Setting balance to 0, no V2 queries will be served for this payer.",
200-
account.payer.id
198+
payer = ?account.payer.id,
199+
"Balance minus total amount thawing underflowed for V2 account; setting balance to 0, no V2 queries will be served for this payer."
201200
);
202201
U256::from(0)
203202
});
@@ -261,9 +260,8 @@ async fn get_escrow_accounts_v1(
261260
)
262261
.unwrap_or_else(|| {
263262
tracing::warn!(
264-
"Balance minus total amount thawing underflowed for account {}. \
265-
Setting balance to 0, no queries will be served for this sender.",
266-
account.sender.id
263+
sender = ?account.sender.id,
264+
"Balance minus total amount thawing underflowed for account; setting balance to 0, no queries will be served for this sender."
267265
);
268266
U256::from(0)
269267
});
@@ -291,9 +289,9 @@ async fn get_escrow_accounts_v1(
291289
let escrow_accounts = EscrowAccounts::new(senders_balances.clone(), senders_to_signers.clone());
292290

293291
tracing::debug!(
294-
"V1 escrow accounts loaded: {} senders, {} signer->sender mappings",
295-
senders_balances.len(),
296-
escrow_accounts.signers_to_senders.len()
292+
senders = senders_balances.len(),
293+
mappings = escrow_accounts.signers_to_senders.len(),
294+
"V1 escrow accounts loaded"
297295
);
298296

299297
Ok(escrow_accounts)

crates/monitor/src/horizon_detection.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use indexer_query::horizon_detection::{self, HorizonDetectionQuery};
1111

1212
use crate::client::SubgraphClient;
1313

14+
1415
/// Detects if Horizon (V2) contracts are active in the network.
1516
///
1617
/// This function queries the network subgraph to check if any PaymentsEscrow accounts exist.
@@ -34,19 +35,11 @@ pub async fn is_horizon_active(network_subgraph: &SubgraphClient) -> Result<bool
3435

3536
let account_count = response.payments_escrow_accounts.len();
3637

37-
// If the query succeeds, Horizon schema is available
38-
// Account count doesn't matter - the watcher will detect accounts as they appear
3938
if account_count > 0 {
40-
tracing::info!(
41-
"Horizon (V2) schema available - found {} existing PaymentsEscrow accounts",
42-
account_count
43-
);
39+
tracing::info!(accounts = account_count, "Horizon (V2) schema available - found existing PaymentsEscrow accounts");
4440
} else {
45-
tracing::info!(
46-
"Horizon (V2) schema available - no accounts found at startup, but will detect new accounts automatically"
47-
);
41+
tracing::info!("Horizon (V2) schema available - no accounts found at startup, but will detect new accounts automatically");
4842
}
4943

50-
// Always return true if query succeeded (schema exists)
5144
Ok(true)
5245
}

crates/service/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ async fn main() -> ExitCode {
2121
// If profiling fails, log the error
2222
// but continue running the application
2323
// as profiling is just for development.
24-
tracing::error!("Failed to setup profiling: {e}");
24+
tracing::error!(error = %e, "Failed to setup profiling");
2525
} else {
2626
tracing::info!("Profiling setup complete.");
2727
}
2828

2929
if let Err(e) = run().await {
30-
tracing::error!("Indexer service error: {e}");
30+
tracing::error!(error = %e, "Indexer service error");
3131
return ExitCode::from(1);
3232
}
3333

crates/service/src/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn serve_metrics(host_and_port: SocketAddr) {
4949
match encoder.encode_to_string(&metric_families) {
5050
Ok(s) => (StatusCode::OK, s),
5151
Err(e) => {
52-
tracing::error!("Error encoding metrics: {}", e);
52+
tracing::error!(error = %e, "Error encoding metrics");
5353
(
5454
StatusCode::INTERNAL_SERVER_ERROR,
5555
format!("Error encoding metrics: {e}"),

crates/service/src/routes/request_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub async fn request_handler(
1919
State(state): State<GraphNodeState>,
2020
req: String,
2121
) -> Result<impl IntoResponse, SubgraphServiceError> {
22-
tracing::trace!("Handling request for deployment `{deployment}`");
22+
tracing::trace!(deployment = %deployment, "Handling request for deployment");
2323

2424
let deployment_url = state
2525
.graph_node_query_base_url

crates/service/src/routes/static_subgraph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub async fn static_subgraph_request_handler(
1717
response.status(),
1818
response.headers().to_owned(),
1919
response.text().await.inspect_err(|e| {
20-
tracing::warn!("Failed to read response body: {}", e);
20+
tracing::warn!(error = %e, "Failed to read response body");
2121
})?,
2222
))
2323
}
@@ -42,7 +42,7 @@ impl From<&StaticSubgraphError> for StatusCode {
4242

4343
impl IntoResponse for StaticSubgraphError {
4444
fn into_response(self) -> axum::response::Response {
45-
tracing::error!(%self, "StaticSubgraphError occoured.");
45+
tracing::error!(%self, "StaticSubgraphError occurred.");
4646
(
4747
StatusCode::from(&self),
4848
Json(json! {{

crates/service/src/service.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ pub async fn run() -> anyhow::Result<()> {
5353
let config = Config::parse(indexer_config::ConfigPrefix::Service, cli.config.as_ref())
5454
.map_err(|e| {
5555
tracing::error!(
56-
"Invalid configuration file `{}`: {}, if a value is missing you can also use \
57-
--config to fill the rest of the values",
58-
cli.config.unwrap_or_default().display(),
59-
e
56+
config_path = %cli.config.unwrap_or_default().display(),
57+
error = %e,
58+
"Invalid configuration file; you can use --config to fill missing values",
6059
);
6160
anyhow!(e)
6261
})?;
@@ -190,8 +189,8 @@ pub async fn run() -> anyhow::Result<()> {
190189
}
191190
Err(e) => {
192191
tracing::error!(
193-
"Failed to initialize V2 escrow accounts: {}. Service cannot continue.",
194-
e
192+
error = %e,
193+
"Failed to initialize V2 escrow accounts; service cannot continue",
195194
);
196195
std::process::exit(1);
197196
}
@@ -352,10 +351,10 @@ pub async fn run() -> anyhow::Result<()> {
352351
chain_id,
353352
};
354353

355-
info!("starting dips grpc server on {}", addr);
354+
info!(address = %addr, "Starting DIPS gRPC server");
356355

357356
tokio::spawn(async move {
358-
info!("starting dips grpc server on {}", addr);
357+
info!(address = %addr, "Starting DIPS gRPC server");
359358

360359
start_dips_server(addr, dips).await;
361360
});

0 commit comments

Comments
 (0)