Skip to content

Commit

Permalink
chore: log error message instead of panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Millione authored and Forsworns committed Jan 14, 2024
1 parent cb9c00d commit 47057f6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions sentinel-core/src/core/stat/base/bucket_leap_array.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use super::{LeapArray, MetricBucket};
use crate::base::{MetricEvent, WriteStat, DEFAULT_STATISTIC_MAX_RT};
use crate::utils::curr_time_millis;
use crate::Result;
use crate::{logging, Result};
use std::cmp;

/// a specialization of `LeapArray<T>` with `MetricBucket`
pub type BucketLeapArray = LeapArray<MetricBucket>;

impl WriteStat for BucketLeapArray {
fn add_count(&self, event: MetricEvent, count: u64) {
self.add_count_with_time(curr_time_millis(), event, count)
.unwrap();
let now = curr_time_millis();
if let Err(err) = self.add_count_with_time(now, event, count) {
logging::error!(
"BucketLeapArray::add_count: {:?} Failed to get_bucket_of_time. Error: {:?}.",
now,
err
);
}
}

fn update_concurrency(&self, concurrency: u32) {
self.update_concurrency_with_time(curr_time_millis(), concurrency)
.unwrap();
let now = curr_time_millis();
if let Err(err) = self.update_concurrency_with_time(now, concurrency) {
logging::error!("BucketLeapArray::update_concurrency: {:?} Failed to get_bucket_of_time. Error: {:?}.", now, err);
}
}
}

Expand Down

0 comments on commit 47057f6

Please sign in to comment.