use of io.micrometer.core.instrument.config.MeterFilterReply in project micrometer by micrometer-metrics.
the class MeterFilterTest method maximumAllowableTags.
@Test
void maximumAllowableTags() {
AtomicInteger n = new AtomicInteger(0);
MeterFilter filter = MeterFilter.maximumAllowableTags("name", "k", 2, new MeterFilter() {
@Override
public MeterFilterReply accept(Meter.Id id) {
n.incrementAndGet();
return MeterFilterReply.NEUTRAL;
}
});
Meter.Id id = new Meter.Id("name", Tags.of("k", "1"), null, null, Meter.Type.COUNTER);
Meter.Id id2 = new Meter.Id("name", Tags.of("k", "2"), null, null, Meter.Type.COUNTER);
Meter.Id id3 = new Meter.Id("name", Tags.of("k", "3"), null, null, Meter.Type.COUNTER);
filter.accept(id);
filter.accept(id);
filter.accept(id2);
filter.accept(id);
filter.accept(id3);
assertThat(n.get()).isEqualTo(1);
}
use of io.micrometer.core.instrument.config.MeterFilterReply in project micrometer by micrometer-metrics.
the class MeterRegistryTest method acceptMeterFilter.
@Test
void acceptMeterFilter() {
registry.config().meterFilter(new MeterFilter() {
@Override
public MeterFilterReply accept(Meter.Id id) {
return id.getName().contains("jvm") ? MeterFilterReply.DENY : MeterFilterReply.NEUTRAL;
}
});
assertThat(registry.counter("jvm.my.counter")).isInstanceOf(NoopCounter.class);
assertThat(registry.counter("my.counter")).isNotInstanceOf(NoopCounter.class);
}
Aggregations