blob: 526b7c7b5250218e12f16630439e53080b7682e1 (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "gauge_aggregator.h"
#include <assert.h>
#include <map>
namespace vespalib {
namespace metrics {
GaugeAggregator::GaugeAggregator(const Gauge::Measurement &sample)
: idx(sample.idx),
observedCount(1),
sumValue(sample.value),
minValue(sample.value),
maxValue(sample.value),
lastValue(sample.value)
{}
void
GaugeAggregator::merge(const GaugeAggregator &other)
{
assert(idx == other.idx);
minValue = std::min(minValue, other.minValue);
maxValue = std::max(maxValue, other.maxValue);
sumValue += other.sumValue;
lastValue = other.lastValue;
observedCount += other.observedCount;
}
} // namespace vespalib::metrics
} // namespace vespalib
|