Skip to content

Commit

Permalink
rename ClusterMetricsData to ClusterMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Mar 22, 2023
1 parent ad7f58f commit fdb8f2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bin/src/ctl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use anyhow::{self, bail, Context};
use prettytable::{Row, Table};

use sozu_command_lib::response::{
AggregatedMetrics, ClusterMetricsData, FilteredData, ListedFrontends, ListenersList,
AggregatedMetrics, ClusterMetrics, FilteredData, ListedFrontends, ListenersList,
QueryAnswerCertificate, QueryAnswerMetrics, ResponseContent, Route, WorkerInfo, WorkerMetrics,
};

Expand Down Expand Up @@ -240,7 +240,7 @@ fn print_proxy_metrics(proxy_metrics: &Option<BTreeMap<String, FilteredData>>) {
}
}

fn print_cluster_metrics(cluster_metrics: &Option<BTreeMap<String, ClusterMetricsData>>) {
fn print_cluster_metrics(cluster_metrics: &Option<BTreeMap<String, ClusterMetrics>>) {
if let Some(cluster_metrics) = cluster_metrics {
for (cluster_id, cluster_metrics_data) in cluster_metrics.iter() {
println!("\nCluster {cluster_id}\n--------");
Expand Down
6 changes: 3 additions & 3 deletions command/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,12 @@ pub struct WorkerMetrics {
/// Metrics of the worker process, key -> value
pub proxy: Option<BTreeMap<String, FilteredData>>,
/// cluster_id -> cluster_metrics
pub clusters: Option<BTreeMap<String, ClusterMetricsData>>,
pub clusters: Option<BTreeMap<String, ClusterMetrics>>,
}

/// the metrics of a given cluster, with several backends
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ClusterMetricsData {
pub struct ClusterMetrics {
/// metric name -> metric value
pub cluster: Option<BTreeMap<String, FilteredData>>,
/// backend_id -> (metric name-> metric value)
Expand Down Expand Up @@ -710,7 +710,7 @@ mod tests {
clusters: Some(
[(
String::from("cluster_1"),
ClusterMetricsData {
ClusterMetrics {
cluster: Some(
[(
String::from("request_time"),
Expand Down
14 changes: 7 additions & 7 deletions lib/src/metrics/local_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hdrhistogram::Histogram;

use crate::sozu_command::{
request::{MetricsConfiguration, QueryMetricsOptions},
response::{ClusterMetricsData, FilteredData, Percentiles, QueryAnswerMetrics, WorkerMetrics},
response::{ClusterMetrics, FilteredData, Percentiles, QueryAnswerMetrics, WorkerMetrics},
};

use super::{MetricData, Subscriber};
Expand Down Expand Up @@ -246,7 +246,7 @@ impl LocalDrain {
pub fn dump_cluster_metrics(
&mut self,
metric_names: &Vec<String>,
) -> anyhow::Result<BTreeMap<String, ClusterMetricsData>> {
) -> anyhow::Result<BTreeMap<String, ClusterMetrics>> {
let mut cluster_data = BTreeMap::new();

for cluster_id in self.get_cluster_ids() {
Expand All @@ -265,7 +265,7 @@ impl LocalDrain {
&self,
cluster_id: &str,
metric_names: &Vec<String>,
) -> anyhow::Result<ClusterMetricsData> {
) -> anyhow::Result<ClusterMetrics> {
let raw_metrics = self
.cluster_metrics
.get(cluster_id)
Expand All @@ -292,7 +292,7 @@ impl LocalDrain {
))?;
backends.insert(backend_id.to_owned(), backend_metrics);
}
Ok(ClusterMetricsData {
Ok(ClusterMetrics {
cluster: Some(cluster),
backends: Some(backends),
})
Expand Down Expand Up @@ -329,7 +329,7 @@ impl LocalDrain {
metric_names: &Vec<String>,
) -> anyhow::Result<WorkerMetrics> {
debug!("Querying cluster with ids: {:?}", cluster_ids);
let mut clusters: BTreeMap<String, ClusterMetricsData> = BTreeMap::new();
let mut clusters: BTreeMap<String, ClusterMetrics> = BTreeMap::new();

for cluster_id in cluster_ids {
clusters.insert(
Expand All @@ -350,7 +350,7 @@ impl LocalDrain {
backend_ids: &Vec<String>,
metric_names: &Vec<String>,
) -> anyhow::Result<WorkerMetrics> {
let mut clusters: BTreeMap<String, ClusterMetricsData> = BTreeMap::new();
let mut clusters: BTreeMap<String, ClusterMetrics> = BTreeMap::new();

for backend_id in backend_ids {
let cluster_id = self
Expand All @@ -367,7 +367,7 @@ impl LocalDrain {

clusters.insert(
cluster_id,
ClusterMetricsData {
ClusterMetrics {
cluster: None,
backends: Some(backend_map),
},
Expand Down

0 comments on commit fdb8f2e

Please sign in to comment.