diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/NoTagsMeterFilter.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/NoTagsMeterFilter.java index d2011eb319..93f032b5e1 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/NoTagsMeterFilter.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/NoTagsMeterFilter.java @@ -1,30 +1,39 @@ package com.appsmith.server.configurations; import io.micrometer.core.instrument.Meter; +import io.micrometer.core.instrument.Tag; import io.micrometer.core.instrument.Tags; import io.micrometer.core.instrument.config.MeterFilter; import java.util.List; +import java.util.Map; public class NoTagsMeterFilter implements MeterFilter { - private static final List seriesExceptionList = List.of( - "appsmith.total.plugin.execution", "appsmith.total.server.execution", "appsmith.get.datasource.context"); + private static final Map> seriesExceptionMap = Map.of( + "appsmith.total.plugin.execution", List.of("plugin"), + "appsmith.total.server.execution", List.of("plugin"), + "appsmith.get.datasource.context", List.of("plugin")); @Override public Meter.Id map(Meter.Id id) { // Remove all tags from the metric - if (id.getName().startsWith("appsmith") && !startsWithPrefix(id.getName())) { - return id.replaceTags(Tags.empty()); - } - return id; - } + if (id.getName().startsWith("appsmith")) { + List allowedTags = seriesExceptionMap.get(id.getName()); - private boolean startsWithPrefix(String metricName) { - for (String prefix : seriesExceptionList) { - if (metricName.startsWith(prefix)) { - return true; + if (allowedTags != null) { + Tags filteredTags = Tags.empty(); + for (Tag tag : id.getTags()) { + if (allowedTags.contains(tag.getKey())) { + filteredTags = filteredTags.and(tag); + } + } + return id.replaceTags(filteredTags); + } else { + // Remove all tags for other metrics + return id.replaceTags(Tags.empty()); } + } else { + return id; } - return false; } }