summaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp')
-rw-r--r--staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp b/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp
index e0d456a5259..9062066fc84 100644
--- a/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp
+++ b/staging_vespalib/src/vespa/vespalib/metrics/bucket.cpp
@@ -20,8 +20,10 @@ mergeFromSamples(const StableStore<typename T::sample_type> &source)
Map map;
source.for_each([&map] (const Sample &sample) {
MetricIdentifier id = sample.idx;
- auto iter_check = map.emplace(id, Aggregator(id));
- iter_check.first->second.merge(sample);
+ auto iter_check = map.emplace(id, sample);
+ if (!iter_check.second) {
+ iter_check.first->second.merge(sample);
+ }
});
std::vector<typename T::aggregator_type> result;
for (const MapValue &entry : map) {
@@ -75,9 +77,10 @@ void Bucket::merge(const CurrentSamples &samples)
void Bucket::merge(const Bucket &other)
{
- assert(startTime <= other.startTime);
- assert(endTime <= other.endTime);
- endTime = other.endTime;
+ assert(genCnt < other.genCnt);
+ genCnt = other.genCnt;
+ startTime = std::min(startTime, other.startTime);
+ endTime = std::max(endTime, other.endTime);
std::vector<CounterAggregator> nextCounters = mergeVectors(counters, other.counters);
counters = std::move(nextCounters);