chore: Improve network tracing messages (#237)
This commit is contained in:
parent
44465369be
commit
70355a687d
4 changed files with 19 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use gasket::messaging::SendAdapter;
|
||||
use tracing::{debug, error, instrument};
|
||||
use tracing::{error, info, instrument};
|
||||
|
||||
use pallas_crypto::hash::Hash;
|
||||
use pallas_miniprotocols::blockfetch;
|
||||
|
|
@ -39,14 +39,16 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(self))]
|
||||
#[instrument(skip(self), fields(slot, %hash))]
|
||||
fn fetch_block(&mut self, slot: u64, hash: Hash<32>) -> Result<Vec<u8>, gasket::error::Error> {
|
||||
info!("fetching block");
|
||||
|
||||
match self
|
||||
.client
|
||||
.fetch_single(Point::Specific(slot, hash.to_vec()))
|
||||
{
|
||||
Ok(x) => {
|
||||
debug!("block fetch succeded");
|
||||
info!("block fetch succeeded");
|
||||
Ok(x)
|
||||
}
|
||||
Err(blockfetch::Error::ChannelError(x)) => {
|
||||
|
|
@ -77,6 +79,7 @@ where
|
|||
let msg = match msg.payload {
|
||||
ChainSyncEvent::RollForward(s, h) => {
|
||||
let body = self.fetch_block(s, h)?;
|
||||
self.block_count.inc(1);
|
||||
BlockFetchEvent::RollForward(s, h, body)
|
||||
}
|
||||
ChainSyncEvent::Rollback(x) => BlockFetchEvent::Rollback(x),
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ pub struct Worker {
|
|||
channel3_out: Option<DemuxOutputPort>,
|
||||
demuxer: Option<Demuxer<GasketEgress>>,
|
||||
muxer: Option<Muxer<GasketIngress>>,
|
||||
ops_count: gasket::metrics::Counter,
|
||||
}
|
||||
|
||||
impl Worker {
|
||||
|
|
@ -110,6 +111,7 @@ impl Worker {
|
|||
channel3_out,
|
||||
demuxer: None,
|
||||
muxer: None,
|
||||
ops_count: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +143,9 @@ impl Worker {
|
|||
impl gasket::runtime::Worker for Worker {
|
||||
fn metrics(&self) -> gasket::metrics::Registry {
|
||||
// TODO: define networking metrics (bytes in / out, etc)
|
||||
gasket::metrics::Builder::new().build()
|
||||
gasket::metrics::Builder::new()
|
||||
.with_counter("ops_count", &self.ops_count)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn bootstrap(&mut self) -> Result<(), gasket::error::Error> {
|
||||
|
|
@ -196,6 +200,8 @@ impl gasket::runtime::Worker for Worker {
|
|||
mux_res.unwrap()?;
|
||||
demux_res.unwrap()?;
|
||||
|
||||
self.ops_count.inc(1);
|
||||
|
||||
Ok(gasket::runtime::WorkOutcome::Partial)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue