Skip to content

Commit

Permalink
fix broken gauge merge behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz committed Jan 27, 2025
1 parent cbe09ad commit 0d1856f
Show file tree
Hide file tree
Showing 6 changed files with 400 additions and 31 deletions.
7 changes: 0 additions & 7 deletions lib/saluki-components/src/transforms/aggregate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,6 @@ impl AggregationState {
// This means we'll always remove all-closed/empty non-counter metrics, and we _may_ remove all-closed/empty
// counters.
if let Some(closed_bucket_values) = am.values.split_at_timestamp(split_timestamp) {
trace!(
metric_name = &**context.name(),
metric_tags = %context.tags(),
points = %closed_bucket_values,
"Flushing closed buckets."
);

// We got some closed bucket values, so flush those out.
transform_and_push_metric(
context.clone(),
Expand Down
36 changes: 36 additions & 0 deletions lib/saluki-event/src/metric/value/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ impl From<f64> for HistogramPoints {
}
}

impl From<(u64, f64)> for HistogramPoints {
fn from((ts, value): (u64, f64)) -> Self {
let mut histogram = Histogram::default();
histogram.insert(value, SampleRate::unsampled());

Self(TimestampedValue::from((ts, histogram)).into())
}
}

impl<const N: usize> From<[f64; N]> for HistogramPoints {
fn from(values: [f64; N]) -> Self {
let mut histogram = Histogram::default();
Expand All @@ -236,6 +245,33 @@ impl<const N: usize> From<[f64; N]> for HistogramPoints {
}
}

impl<const N: usize> From<(u64, [f64; N])> for HistogramPoints {
fn from((ts, values): (u64, [f64; N])) -> Self {
let mut histogram = Histogram::default();
for value in values {
histogram.insert(value, SampleRate::unsampled());
}

Self(TimestampedValue::from((ts, histogram)).into())
}
}

impl<const N: usize> From<[(u64, f64); N]> for HistogramPoints {
fn from(values: [(u64, f64); N]) -> Self {
Self(
values
.into_iter()
.map(|(ts, value)| {
let mut histogram = Histogram::default();
histogram.insert(value, SampleRate::unsampled());

(ts, histogram)
})
.into(),
)
}
}

impl<'a> From<&'a [f64]> for HistogramPoints {
fn from(values: &'a [f64]) -> Self {
let mut histogram = Histogram::default();
Expand Down
Loading

0 comments on commit 0d1856f

Please sign in to comment.