keep lettuce metrics; strip remote tags
This commit is contained in:
parent
eeea97e2fe
commit
17d48b95ac
|
@ -77,7 +77,7 @@ public class MetricsUtil {
|
|||
return defaultDistributionStatisticConfig.merge(config);
|
||||
}
|
||||
})
|
||||
// Remove high-cardinality `command` tags from Lettuce metrics and prepend "chat." to meter names
|
||||
// Remove high-cardinality `command` and `remote` tags from Lettuce metrics and prepend "chat." to meter names
|
||||
.meterFilter(new MeterFilter() {
|
||||
@Override
|
||||
public Meter.Id map(final Meter.Id id) {
|
||||
|
@ -85,17 +85,13 @@ public class MetricsUtil {
|
|||
return id.withName(PREFIX + "." + id.getName())
|
||||
.replaceTags(id.getTags().stream()
|
||||
.filter(tag -> !"command".equals(tag.getKey()))
|
||||
.filter(tag -> !"remote".equals(tag.getKey()))
|
||||
.toList());
|
||||
}
|
||||
|
||||
return MeterFilter.super.map(id);
|
||||
}
|
||||
})
|
||||
// Deny lettuce metrics, but leave command.completions.max. Note that regardless of configured order, accept
|
||||
// filters are applied after map filters.
|
||||
.meterFilter(MeterFilter.deny(id ->
|
||||
id.getName().startsWith(PREFIX + ".lettuce") && !id.getName().contains("command.completion.max")
|
||||
))
|
||||
.meterFilter(MeterFilter.denyNameStartsWith(PushLatencyManager.TIMER_NAME + ".percentile"))
|
||||
.meterFilter(MeterFilter.denyNameStartsWith(MessageMetrics.DELIVERY_LATENCY_TIMER_NAME + ".percentile"));
|
||||
}
|
||||
|
|
|
@ -26,23 +26,18 @@ class MetricsUtilTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void lettuceRejection() {
|
||||
void lettuceTagRejection() {
|
||||
MeterRegistry registry = new SimpleMeterRegistry();
|
||||
MetricsUtil.configureMeterFilters(registry.config());
|
||||
|
||||
registry.counter("lettuce.command.completion.count").increment();
|
||||
registry.counter("lettuce.command.firstresponse.max").increment();
|
||||
registry.counter("lettuce.test").increment();
|
||||
assertThat(registry.getMeters()).isEmpty();
|
||||
|
||||
// this lettuce statistic is allow-listed
|
||||
registry.counter("lettuce.command.completion.max", "command", "hello", "remote", "world").increment();
|
||||
registry.counter("lettuce.command.completion.max", "command", "hello", "remote", "world", "allowed", "!").increment();
|
||||
final List<Meter> meters = registry.getMeters();
|
||||
assertThat(meters).hasSize(1);
|
||||
|
||||
Meter meter = meters.get(0);
|
||||
assertThat(meter.getId().getName()).isEqualTo("chat.lettuce.command.completion.max");
|
||||
assertThat(meter.getId().getTag("command")).isNull();
|
||||
assertThat(meter.getId().getTag("remote")).isNotNull();
|
||||
assertThat(meter.getId().getTag("remote")).isNull();
|
||||
assertThat(meter.getId().getTag("allowed")).isNotNull();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue