Expected Behavior
Per the Javadoc for MetricSet.partialClone():
"Aggregate metrics are currently not carried over and will not be present in the returned set."
Counter metrics (aggregate metrics) should not appear when there's no data in the current time window.
Actual Behavior
Counter metrics are padded back from DimensionCache and appear with count=0.
Root Cause Analysis
DimensionCache.padMetric() pads all cached metrics regardless of type:
https://github.com/vespa-engine/vespa/blob/master/container-core/src/main/java/com/yahoo/metrics/simple/DimensionCache.java#L89-L92
if ( ! toPresent.hasIdentifier(id)) {
toPresent.put(id, leastOld.getValue().metric.pruneData()); // Pads all types
--toAdd;
}
This happens upstream of MetricSet.partialClone(), so counters are included before the filtering logic can exclude them.
Suggested Resolution
Either:
- Fix the code - Skip counters in DimensionCache.padMetric():
if ( ! toPresent.hasIdentifier(id)) {
if (!leastOld.getValue().metric.isCounter()) {
toPresent.put(id, leastOld.getValue().metric.pruneData());
--toAdd;
}
}
- Fix the Javadoc - If this behavior is intentional, update
MetricSet.partialClone() documentation to clarify that counters may appear with count=0 when padded from the dimension cache.
Vespa version
8.526.15
Thank you! :)