-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(metrics_exporter): expose pool iostats
Signed-off-by: Abhilash Shetty <[email protected]>
- Loading branch information
1 parent
ea97012
commit da89e0c
Showing
14 changed files
with
462 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ name = "metrics-exporter" | |
description = "Metrics Exporters" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["Sahil Raja <[email protected]>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
[[bin]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use super::{Cache, ResourceOps}; | ||
use crate::client::{ | ||
grpc_client::GrpcClient, | ||
pool_stat::{PoolIoStat, PoolIoStats}, | ||
}; | ||
use std::ops::DerefMut; | ||
use tracing::error; | ||
|
||
impl ResourceOps for PoolIoStats { | ||
type ResourceVec = Vec<PoolIoStat>; | ||
|
||
fn set(&mut self, val: Self::ResourceVec) { | ||
self.pool_stats = val | ||
} | ||
|
||
fn invalidate(&mut self) { | ||
self.pool_stats = vec![] | ||
} | ||
} | ||
|
||
/// To store pool iostat data in cache. | ||
pub(crate) async fn store_pool_stats_data(client: &GrpcClient) -> Result<(), ()> { | ||
let pool_stats = client.get_pool_iostat().await; | ||
let mut cache = match Cache::get_cache().lock() { | ||
Ok(cache) => cache, | ||
Err(error) => { | ||
error!(%error, "Error while getting cache resource"); | ||
return Err(()); | ||
} | ||
}; | ||
let pools_cache = cache.deref_mut(); | ||
match pool_stats { | ||
// set pools in the cache | ||
Ok(pools) => { | ||
pools_cache.pool_iostat_mut().set(pools.pool_stats); | ||
} | ||
// invalidate cache in case of error | ||
Err(error) => { | ||
error!(?error, "Error getting pools data, invalidating pools cache"); | ||
pools_cache.pool_iostat_mut().invalidate(); | ||
return Err(()); | ||
} | ||
}; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.