Skip to content

Commit

Permalink
fix: metric bucket start time should be reset everytime it is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Feb 18, 2025
1 parent 4537811 commit 724823b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion unleash-yggdrasil/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pub struct EngineState {
compiled_state: Option<CompiledState>,
previous_state: ClientFeatures,
toggle_metrics: DashMap<String, Metric>,
toggle_metrics_start: DateTime<Utc>,
pub started: DateTime<Utc>,
}

Expand All @@ -233,6 +234,7 @@ impl Default for EngineState {
Self {
compiled_state: Default::default(),
toggle_metrics: Default::default(),
toggle_metrics_start: Utc::now(),
previous_state: Default::default(),
started: Utc::now(),
}
Expand Down Expand Up @@ -354,9 +356,11 @@ impl EngineState {
.collect();

if !metrics.is_empty() {
let start: DateTime<Utc> = self.toggle_metrics_start;
self.toggle_metrics_start = Utc::now();
Some(MetricBucket {
toggles: metrics,
start: self.started,
start,
stop: Utc::now(),
})
} else {
Expand Down

0 comments on commit 724823b

Please sign in to comment.