From 0195a208840ed92285b43b7b29673c3fdd5d961d Mon Sep 17 00:00:00 2001 From: brharrington Date: Fri, 8 Mar 2024 11:41:08 -0600 Subject: [PATCH] avoid id mapping for aggregate functions (#1118) For simple aggregate functions the full set of tags are determined based on the expression. This means we can avoid mapping the id to a tag map. --- .../com/netflix/spectator/atlas/impl/Evaluator.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/Evaluator.java b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/Evaluator.java index 19918a10a..8f843b532 100644 --- a/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/Evaluator.java +++ b/spectator-reg-atlas/src/main/java/com/netflix/spectator/atlas/impl/Evaluator.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -172,8 +173,13 @@ public EvalPayload eval(long timestamp) { consolidator.update(timestamp, Double.NaN); final double v = consolidator.value(timestamp); if (!Double.isNaN(v)) { - Map tags = idMapper.apply(entry.getKey()); - tags.putAll(commonTags); + Map tags = Collections.emptyMap(); + if (!(expr instanceof DataExpr.AggregateFunction)) { + // Aggregation functions only use tags based on the expression. Avoid overhead of + // considering the tags for the data. + tags = idMapper.apply(entry.getKey()); + tags.putAll(commonTags); + } if (delayGaugeAggr && consolidator.isGauge()) { // When performing a group by, datapoints missing tag used for the grouping // should be ignored