Skip to content

Commit

Permalink
remove most high cardinality lettuce metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-signal committed Aug 10, 2023
1 parent a71dc48 commit f6b3500
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.micrometer.core.instrument.Metrics;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.instrument.config.MeterFilter;
import io.micrometer.core.instrument.config.MeterFilterReply;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.datadog.DatadogMeterRegistry;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -63,20 +64,25 @@ public DistributionStatisticConfig configure(final Meter.Id id, final Distributi
}
});

// Remove high-cardinality `command` tags from Lettuce metrics and prepend "chat." to meter names
datadogMeterRegistry.config().meterFilter(new MeterFilter() {
@Override
public Meter.Id map(final Meter.Id id) {
if (id.getName().startsWith("lettuce")) {
return id.withName(PREFIX + "." + id.getName())
.replaceTags(id.getTags().stream()
.filter(tag -> !"command".equals(tag.getKey()))
.toList());
}

return MeterFilter.super.map(id);
}
});
datadogMeterRegistry.config()
// Deny lettuce metrics, but leave command.completions.max
.meterFilter(MeterFilter.deny(id ->
id.getName().startsWith("lettuce") && !id.getName().contains("command.completions.max")
))
// Remove high-cardinality `command` tags from Lettuce metrics and prepend "chat." to meter names
.meterFilter(new MeterFilter() {
@Override
public Meter.Id map(final Meter.Id id) {
if (id.getName().startsWith("lettuce")) {
return id.withName(PREFIX + "." + id.getName())
.replaceTags(id.getTags().stream()
.filter(tag -> !"command".equals(tag.getKey()))
.toList());
}

return MeterFilter.super.map(id);
}
});

Metrics.addRegistry(datadogMeterRegistry);
}
Expand Down

0 comments on commit f6b3500

Please sign in to comment.