Skip to content

Commit

Permalink
Correct a coercion bug in capture manager
Browse files Browse the repository at this point in the history
This commit corrects a bug whereby the capture manager did not coerce the
u64 values up from the registry storage into their f64 representation, meaning
we reported out to captures comically huge values.

Much obliged to @tobz who spotted the bug.

Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Dec 11, 2024
1 parent b2d5858 commit ef5f4e1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lading/src/captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,14 @@ impl CaptureManager {
// TODO we're allocating the same small strings over and over most likely
labels.insert(lbl.key().into(), lbl.value().into());
}
let value: f64 = f64::from_bits(counter.get_inner().load(Ordering::Relaxed));
let line = json::Line {
run_id: self.run_id,
time: now_ms,
fetch_index: self.fetch_index,
metric_name: key.name().into(),
metric_kind: json::MetricKind::Counter,
value: json::LineValue::Int(counter.get_inner().load(Ordering::Relaxed)),
value: json::LineValue::Float(value),
labels,
};
lines.push(line);
Expand All @@ -180,13 +181,14 @@ impl CaptureManager {
// TODO we're allocating the same small strings over and over most likely
labels.insert(lbl.key().into(), lbl.value().into());
}
let value: f64 = f64::from_bits(gauge.get_inner().load(Ordering::Relaxed));
let line = json::Line {
run_id: self.run_id,
time: now_ms,
fetch_index: self.fetch_index,
metric_name: key.name().into(),
metric_kind: json::MetricKind::Gauge,
value: json::LineValue::Int(gauge.get_inner().load(Ordering::Relaxed)),
value: json::LineValue::Float(value),
labels,
};
lines.push(line);
Expand Down

0 comments on commit ef5f4e1

Please sign in to comment.