You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iter_recorded() won't work when all the values recorded by the Histogram instance is 0.
Sample code to hit the issue:
let mut tracker = Histogram::<u64>::new(3).unwrap();
tracker += 0;
tracker += 0;
tracker += 0;
// print 3 as expected.
println!("{}", tracker.len());
let mut res = String::new();
for v in tracker.iter_recorded() {
res.push_str(format!("value {} and count {}", v.value_iterated_to(), v.count_at_value()).as_str());
}
// nothing is printed. Expected: value 0 and count 3
println!("{}", res);
We use the iterator to print out a certain format and emit to our log file. Is there a better way to do that for the logging purpose?
The text was updated successfully, but these errors were encountered:
It's been a while since I was in the guts of the data structure, but IIRC the hdrhistogram structure squashes everything below the lowest trackable number into the 0th internal slot which is then ignored because it doesn't obey the same scaling rules as all the other slots. The lowest trackable number is at least 1, so 0 would fall into the void, in the same way that if you configured a histogram with the lowest trackable number of 10000 then 44 would also get lost.
If you do need to record zeroes for your use case, a slightly unpleasant workaround would be to simply add 1 to everything at record time, then subtract it off at iteration time.
Ok. But if I continue to record another value, for example 1, to the above tracker, then it will be able to print out the result correctly. (value 0 and count 3 value 1 and count 1), Could you clarify that? Since as you said, 1 is below the lowest trackable number. I just want to make sure there would be no other corner cases for the iterator.
iter_recorded() won't work when all the values recorded by the Histogram instance is 0.
Sample code to hit the issue:
We use the iterator to print out a certain format and emit to our log file. Is there a better way to do that for the logging purpose?
The text was updated successfully, but these errors were encountered: