remove unneeded deps

This commit is contained in:
Chris Beck
2025-12-04 16:42:48 -07:00
parent c44b515ce0
commit 3bcdad62fc
8 changed files with 61 additions and 293 deletions
-1
View File
@@ -11,7 +11,6 @@ async-trait = { workspace = true }
chrono = { workspace = true }
displaydoc = { workspace = true }
reqwest = { workspace = true }
rust_decimal = { workspace = true }
serde = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
+1 -1
View File
@@ -29,7 +29,7 @@ pub use labels::{ExtractLabels, Labels};
mod messages;
use messages::PromResponse;
pub use messages::{
AlertInfo, AlertStatus, AlertsResponse, MetricTimeseries, MetricValue, PromData,
AlertInfo, AlertStatus, AlertsResponse, MetricTimeseries, MetricVal, MetricValue, PromData,
};
#[cfg(feature = "plot")]
+32 -5
View File
@@ -26,11 +26,38 @@
use crate::Error;
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use serde::{Deserialize, de::DeserializeOwned};
use std::{collections::HashMap, fmt::Debug};
use serde::{Deserialize, Deserializer, de::DeserializeOwned};
use std::{collections::HashMap, fmt::{self, Debug, Display}};
use tracing::warn;
/// Wrapper for f64 that deserializes from a string (prometheus returns numeric values as strings)
#[derive(Clone, Copy, Debug)]
pub struct MetricVal(pub f64);
impl Display for MetricVal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Display::fmt(&self.0, f)
}
}
impl AsRef<f64> for MetricVal {
fn as_ref(&self) -> &f64 {
&self.0
}
}
impl<'de> Deserialize<'de> for MetricVal {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = <&str>::deserialize(deserializer)?;
s.parse::<f64>()
.map(MetricVal)
.map_err(serde::de::Error::custom)
}
}
#[derive(Clone, Debug, Deserialize)]
#[serde(bound = "KV: DeserializeOwned")]
pub struct MetricValue<KV = HashMap<String, String>>
@@ -39,7 +66,7 @@ where
{
pub metric: KV,
#[serde(default)]
pub value: Option<(f64, Decimal)>,
pub value: Option<(f64, MetricVal)>,
// TODO: Include histograms
}
@@ -51,7 +78,7 @@ where
{
pub metric: KV,
#[serde(default)]
pub values: Vec<(f64, Decimal)>,
pub values: Vec<(f64, MetricVal)>,
// TODO: Include histograms
}
+1 -2
View File
@@ -1,7 +1,6 @@
use crate::{ExtractLabels, MetricTimeseries};
use chrono::{DateTime, FixedOffset, TimeZone, Utc};
use plotters::prelude::*;
use rust_decimal::prelude::ToPrimitive;
use std::{
borrow::Borrow,
error::Error,
@@ -235,7 +234,7 @@ impl PreparedPlot {
.iter()
.filter_map(|(k, v)| {
let x = f64_to_datetime(k)?;
let y = v.to_f64()?;
let y = *v.as_ref();
extend_range(&mut x_range, &x);
extend_range(&mut y_range, &y);