1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::metrics::{Descriptor, InstrumentKind, MetricsError, Number, NumberKind, Result};
mod array;
mod ddsketch;
mod histogram;
mod last_value;
mod min_max_sum_count;
mod sum;
pub use array::{array, ArrayAggregator};
pub use ddsketch::{ddsketch, DdSketchAggregator, DdSketchConfig};
pub use histogram::{histogram, HistogramAggregator};
pub use last_value::{last_value, LastValueAggregator};
pub use min_max_sum_count::{min_max_sum_count, MinMaxSumCountAggregator};
pub use sum::{sum, SumAggregator};
pub fn range_test(number: &Number, descriptor: &Descriptor) -> Result<()> {
if descriptor.number_kind() == &NumberKind::F64 && number.is_nan() {
return Err(MetricsError::NaNInput);
}
match descriptor.instrument_kind() {
InstrumentKind::Counter | InstrumentKind::SumObserver
if descriptor.number_kind() == &NumberKind::F64 =>
{
if number.is_negative(descriptor.number_kind()) {
return Err(MetricsError::NegativeInput);
}
}
_ => (),
};
Ok(())
}