-
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.
chore(bors): merge pull request #400
400: expose pool io stats from exporter r=abhilashshetty04 a=abhilashshetty04 This PR changes cache update behavior of Metrics node exporter. It would update cache when /metrics is called as opposed to having its own `pool_cycle` for cache update. We will remove poll_period arg from helm also in the same PR. Co-authored-by: Abhilash Shetty <[email protected]>
- Loading branch information
Showing
15 changed files
with
487 additions
and
285 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(()) | ||
} |
Oops, something went wrong.