use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method ignoreTags.
@Test
void ignoreTags() {
MeterFilter filter = MeterFilter.ignoreTags("k1", "k2");
Meter.Id id = new Meter.Id("name", Tags.of("k1", "v1", "k2", "v2", "k3", "v3"), null, null, Meter.Type.COUNTER);
Meter.Id filteredId = filter.map(id);
assertThat(filteredId).has(tag("k3"));
assertThat(filteredId).doesNotHave(tag("k1"));
assertThat(filteredId).doesNotHave(tag("k2"));
}
use of io.micrometer.core.instrument.config.MeterFilter 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.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method commonTags.
@Test
void commonTags() {
MeterFilter filter = MeterFilter.commonTags(Tags.of("k2", "v2"));
Meter.Id id = new Meter.Id("name", Tags.of("k1", "v1"), null, null, Meter.Type.COUNTER);
Meter.Id filteredId = filter.map(id);
assertThat(filteredId).has(tag("k1", "v1"));
assertThat(filteredId).has(tag("k2", "v2"));
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method minExpectedOnSummary.
@Test
void minExpectedOnSummary() {
MeterFilter filter = MeterFilter.minExpected("name", 100);
Meter.Id timer = new Meter.Id("name", emptyList(), null, null, Meter.Type.DISTRIBUTION_SUMMARY);
assertThat(filter.configure(timer, DistributionStatisticConfig.DEFAULT)).satisfies(conf -> assertThat(conf.getMinimumExpectedValue()).isEqualTo(100));
}
use of io.micrometer.core.instrument.config.MeterFilter in project micrometer by micrometer-metrics.
the class MeterFilterTest method maximumAllowableMetrics.
@Test
void maximumAllowableMetrics() {
MeterFilter filter = MeterFilter.maximumAllowableMetrics(1);
Meter.Id id = new Meter.Id("name", emptyList(), null, null, Meter.Type.COUNTER);
Meter.Id id2 = new Meter.Id("name2", emptyList(), null, null, Meter.Type.COUNTER);
assertThat(filter.accept(id)).isEqualTo(MeterFilterReply.NEUTRAL);
assertThat(filter.accept(id)).isEqualTo(MeterFilterReply.NEUTRAL);
assertThat(filter.accept(id2)).isEqualTo(MeterFilterReply.DENY);
}
Aggregations