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

Adding instrucment #762

Merged
merged 12 commits into from
Mar 1, 2024
3 changes: 3 additions & 0 deletions fendermint/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ use tracing_appender::{
non_blocking::WorkerGuard,
rolling::{RollingFileAppender, Rotation},
};
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::{
fmt::{self, writer::MakeWriterExt},
layer::SubscriberExt,
};

mod cmd;

fn init_tracing(opts: &options::Options) -> Option<WorkerGuard> {
Expand Down Expand Up @@ -44,6 +46,7 @@ fn init_tracing(opts: &options::Options) -> Option<WorkerGuard> {
fmt::Layer::new()
.json()
.with_writer(non_blocking.with_max_level(log_level))
.with_span_events(FmtSpan::CLOSE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is a bit short in exact details, but I think if we use FmtSpan::CLOSE only like here then the generated event will also contain the total time the span was entered (+ time the span existed but was not entered).

.with_target(false)
.with_file(true)
.with_line_number(true),
Expand Down
4 changes: 4 additions & 0 deletions fendermint/vm/topdown/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use ipc_api::staking::StakingChangeRequest;
use ipc_api::subnet_id::SubnetID;
use ipc_provider::manager::{GetBlockHashResult, TopDownQueryPayload};
use ipc_provider::IpcProvider;
use tracing::instrument;

/// The interface to querying state of the parent
#[async_trait]
Expand Down Expand Up @@ -75,13 +76,15 @@ impl ParentQueryProxy for IPCProviderProxy {
}

/// Getting the block hash at the target height.
#[instrument(skip(self))]
async fn get_block_hash(&self, height: BlockHeight) -> anyhow::Result<GetBlockHashResult> {
self.ipc_provider
.get_block_hash(&self.parent_subnet, height as ChainEpoch)
.await
}

/// Get the top down messages from the starting to the ending height.
#[instrument(skip(self))]
async fn get_top_down_msgs(
&self,
height: BlockHeight,
Expand All @@ -97,6 +100,7 @@ impl ParentQueryProxy for IPCProviderProxy {
}

/// Get the validator set at the specified height.
#[instrument(skip(self))]
async fn get_validator_changes(
&self,
height: BlockHeight,
Expand Down
2 changes: 2 additions & 0 deletions fendermint/vm/topdown/src/sync/syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use async_stm::{atomically, atomically_or_err, StmError};
use ethers::utils::hex;
use fendermint_vm_event::{emit, EventType};
use std::sync::Arc;
use tracing::instrument;

/// Parent syncer that constantly poll parent. This struct handles lotus null blocks and deferred
/// execution. For ETH based parent, it should work out of the box as well.
Expand Down Expand Up @@ -257,6 +258,7 @@ where
Ok(data.0)
}

#[instrument(skip(self))]
async fn fetch_data(
&self,
height: BlockHeight,
Expand Down
Loading