metrics capture

This commit is contained in:
Aniket Prajapati 2023-01-10 20:34:40 +05:30
parent 2faa23b9ad
commit e3a39d9a47
No known key found for this signature in database
GPG Key ID: D4346D8C9C5398F2
3 changed files with 8 additions and 8 deletions

View File

@ -34,6 +34,7 @@ pub struct LiteBridge {
pub tx_sender: TxSender,
pub finalized_block_listenser: BlockListener,
pub confirmed_block_listenser: BlockListener,
pub metrics_capture: MetricsCapture,
}
impl LiteBridge {
@ -146,13 +147,8 @@ impl LiteBridge {
#[jsonrpsee::core::async_trait]
impl LiteRpcServer for LiteBridge {
#[allow(unreachable_code)]
async fn get_metrics(&self) -> crate::rpc::Result<Metrics> {
#[cfg(feature = "metrics")]
{
return Ok(self.metrics.read().await.to_owned());
}
panic!("server not compiled with metrics support")
return Ok(self.metrics_capture.get_metrics().await);
}
async fn send_transaction(

View File

@ -32,6 +32,10 @@ impl MetricsCapture {
}
}
pub async fn get_metrics(&self) -> Metrics {
self.metrics.read().await.to_owned()
}
pub fn capture(self) -> JoinHandle<anyhow::Result<()>> {
let mut one_second = tokio::time::interval(std::time::Duration::from_secs(1));

View File

@ -1,9 +1,9 @@
mod block_listenser;
mod cleaner;
mod metrics;
mod metrics_capture;
mod tx_sender;
pub use block_listenser::*;
pub use cleaner::*;
pub use metrics::*;
pub use metrics_capture::*;
pub use tx_sender::*;