Struct telemetry::keyed::KeyedLinear
[−]
[src]
pub struct KeyedLinear<K, T> where T: Flatten {
// some fields omitted
}
Linear histograms.
Linear histograms classify numeric integer values into same-sized buckets. This type is typically used for percentages, or to store a relatively precise of the amount of resources (time, memory) used by a section.
With SerializationFormat::SimpleJson
, these histograms are
serialized as an object
js { key_1: array_1, key_2: array_2, ... }
where each array_i
is an array of numbers, one per bucket, in
the numeric order of buckets
Methods
impl<K, T> KeyedLinear<K, T> where K: ToString, T: Flatten
fn new(service: &Service, name: String, min: u32, max: u32, buckets: usize) -> KeyedLinear<K, T>
Create a new Linear histogram with a given name.
Argument name
is used as key when processing and exporting
the data. Each name
must be unique to the Service
.
min
is the minimal value expected to be entered in this
histogram. Any value lower than min
is rounded up to min
.
max
is the maximal value expected to be entered in this
histogram. Any value higher than max
is rounded up to max
.
buckets
is the number of buckets in this histogram. For
highest possible precision, use buckets = max - min + 1
.
In most cases, however, such precision is not needed, so you
should use a lower number of buckets.
Performance
Increasing the number of buckets increases the memory usage on the client by a few bytes per bucket per key. More importantly, it also increases the size of the payload, hence the total amount of data that the application will eventually upload to a central server. If your application has many clients and you wish to keep your server happy and your bandwidth costs manageable, don't use too many buckets.
Panics
If name
is already used by another histogram in service
.
If min >= max
.
If buckets < max - min + 1
.