Skip to content

Commit aa3ace5

Browse files
committed
Add more instrumentation
1 parent f62b7d2 commit aa3ace5

File tree

8 files changed

+328
-52
lines changed

8 files changed

+328
-52
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

linera-chain/src/chain.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use linera_views::{
3535
views::{ClonableView, CryptoHashView, RootView, View},
3636
};
3737
use serde::{Deserialize, Serialize};
38+
use tracing::instrument;
3839

3940
use crate::{
4041
block::{Block, ConfirmedBlock},
@@ -391,6 +392,10 @@ where
391392
self.context().extra().chain_id()
392393
}
393394

395+
#[instrument(target = "telemetry_only", skip_all, fields(
396+
chain_id = %self.chain_id(),
397+
next_block_height = %self.tip_state.get().next_block_height
398+
))]
394399
pub async fn query_application(
395400
&mut self,
396401
local_time: Timestamp,
@@ -408,6 +413,10 @@ where
408413
.with_execution_context(ChainExecutionContext::Query)
409414
}
410415

416+
#[instrument(target = "telemetry_only", skip_all, fields(
417+
chain_id = %self.chain_id(),
418+
application_id = %application_id
419+
))]
411420
pub async fn describe_application(
412421
&mut self,
413422
application_id: ApplicationId,
@@ -419,6 +428,11 @@ where
419428
.with_execution_context(ChainExecutionContext::DescribeApplication)
420429
}
421430

431+
#[instrument(target = "telemetry_only", skip_all, fields(
432+
chain_id = %self.chain_id(),
433+
target = %target,
434+
height = %height
435+
))]
422436
pub async fn mark_messages_as_received(
423437
&mut self,
424438
target: &ChainId,
@@ -506,6 +520,9 @@ where
506520

507521
/// Verifies that this chain is up-to-date and all the messages executed ahead of time
508522
/// have been properly received by now.
523+
#[instrument(target = "telemetry_only", skip_all, fields(
524+
chain_id = %self.chain_id()
525+
))]
509526
pub async fn validate_incoming_bundles(&self) -> Result<(), ChainError> {
510527
let chain_id = self.chain_id();
511528
let pairs = self.inboxes.try_load_all_entries().await?;
@@ -567,6 +584,11 @@ where
567584
/// round timeouts.
568585
///
569586
/// Returns `true` if incoming `Subscribe` messages created new outbox entries.
587+
#[instrument(target = "telemetry_only", skip_all, fields(
588+
chain_id = %self.chain_id(),
589+
origin = %origin,
590+
bundle_height = %bundle.height
591+
))]
570592
pub async fn receive_message_bundle(
571593
&mut self,
572594
origin: &ChainId,
@@ -661,6 +683,10 @@ where
661683
}
662684

663685
/// Removes the incoming message bundles in the block from the inboxes.
686+
#[instrument(target = "telemetry_only", skip_all, fields(
687+
chain_id = %self.chain_id(),
688+
timestamp = %timestamp
689+
))]
664690
pub async fn remove_bundles_from_inboxes(
665691
&mut self,
666692
timestamp: Timestamp,
@@ -750,6 +776,10 @@ where
750776

751777
/// Executes a block: first the incoming messages, then the main operation.
752778
/// Does not update chain state other than the execution state.
779+
#[instrument(target = "telemetry_only", skip_all, fields(
780+
chain_id = %block.chain_id,
781+
block_height = %block.height
782+
))]
753783
#[expect(clippy::too_many_arguments)]
754784
async fn execute_block_inner(
755785
chain: &mut ExecutionStateView<C>,
@@ -859,6 +889,10 @@ where
859889

860890
/// Executes a block: first the incoming messages, then the main operation.
861891
/// Does not update chain state other than the execution state.
892+
#[instrument(target = "telemetry_only", skip_all, fields(
893+
chain_id = %self.chain_id(),
894+
block_height = %block.height
895+
))]
862896
pub async fn execute_block(
863897
&mut self,
864898
block: &ProposedBlock,
@@ -919,6 +953,10 @@ where
919953
/// Applies an execution outcome to the chain, updating the outboxes, state hash and chain
920954
/// manager. This does not touch the execution state itself, which must be updated separately.
921955
/// Returns the set of event streams that were updated as a result of applying the block.
956+
#[instrument(target = "telemetry_only", skip_all, fields(
957+
chain_id = %self.chain_id(),
958+
block_height = %block.inner().inner().header.height
959+
))]
922960
pub async fn apply_confirmed_block(
923961
&mut self,
924962
block: &ConfirmedBlock,
@@ -953,6 +991,10 @@ where
953991

954992
/// Adds a block to `preprocessed_blocks`, and updates the outboxes where possible.
955993
/// Returns the set of streams that were updated as a result of preprocessing the block.
994+
#[instrument(target = "telemetry_only", skip_all, fields(
995+
chain_id = %self.chain_id(),
996+
block_height = %block.inner().inner().header.height
997+
))]
956998
pub async fn preprocess_block(
957999
&mut self,
9581000
block: &ConfirmedBlock,
@@ -979,6 +1021,10 @@ where
9791021
}
9801022

9811023
/// Verifies that the block is valid according to the chain's application permission settings.
1024+
#[instrument(target = "telemetry_only", skip_all, fields(
1025+
block_height = %block.height,
1026+
num_transactions = %block.transactions.len()
1027+
))]
9821028
fn check_app_permissions(
9831029
app_permissions: &ApplicationPermissions,
9841030
block: &ProposedBlock,
@@ -1021,6 +1067,10 @@ where
10211067
}
10221068

10231069
/// Returns the hashes of all blocks we have in the given range.
1070+
#[instrument(target = "telemetry_only", skip_all, fields(
1071+
chain_id = %self.chain_id(),
1072+
next_block_height = %self.tip_state.get().next_block_height
1073+
))]
10241074
pub async fn block_hashes(
10251075
&self,
10261076
range: impl RangeBounds<BlockHeight>,
@@ -1066,6 +1116,10 @@ where
10661116
/// Updates the outboxes with the messages sent in the block.
10671117
///
10681118
/// Returns the set of all recipients.
1119+
#[instrument(target = "telemetry_only", skip_all, fields(
1120+
chain_id = %self.chain_id(),
1121+
block_height = %block.header.height
1122+
))]
10691123
async fn process_outgoing_messages(
10701124
&mut self,
10711125
block: &Block,
@@ -1157,6 +1211,10 @@ where
11571211
/// Updates the event streams with events emitted by the block if they form a contiguous
11581212
/// sequence (might not be the case when preprocessing a block).
11591213
/// Returns the set of updated event streams.
1214+
#[instrument(target = "telemetry_only", skip_all, fields(
1215+
chain_id = %self.chain_id(),
1216+
block_height = %block.header.height
1217+
))]
11601218
async fn process_emitted_events(
11611219
&mut self,
11621220
block: &Block,

linera-core/src/chain_worker/actor.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@ where
243243

244244
/// Runs the worker until there are no more incoming requests.
245245
#[instrument(
246+
target = "telemetry_only",
246247
skip_all,
247-
fields(chain_id = format!("{:.8}", self.chain_id)),
248+
fields(chain_id = format!("{:.8}", self.chain_id), long_lived_services = %self.config.long_lived_services),
248249
)]
249250
async fn handle_requests(
250251
self,
@@ -276,6 +277,7 @@ where
276277
self.chain_id,
277278
service_runtime_endpoint,
278279
)
280+
.instrument(span.clone())
279281
.await?;
280282

281283
Box::pin(worker.handle_request(request).instrument(span)).await;

0 commit comments

Comments
 (0)