Search in sources :

Example 6 with MeterFilter

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"));
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Test(org.junit.jupiter.api.Test)

Example 7 with MeterFilter

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);
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) MeterFilterReply(io.micrometer.core.instrument.config.MeterFilterReply) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.jupiter.api.Test)

Example 8 with MeterFilter

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"));
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Test(org.junit.jupiter.api.Test)

Example 9 with MeterFilter

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));
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Test(org.junit.jupiter.api.Test)

Example 10 with MeterFilter

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);
}
Also used : MeterFilter(io.micrometer.core.instrument.config.MeterFilter) Test(org.junit.jupiter.api.Test)

Aggregations

MeterFilter (io.micrometer.core.instrument.config.MeterFilter)20 Test (org.junit.jupiter.api.Test)14 Bean (org.springframework.context.annotation.Bean)4 DistributionStatisticConfig (io.micrometer.core.instrument.distribution.DistributionStatisticConfig)3 OnlyOnceLoggingDenyMeterFilter (org.springframework.boot.actuate.autoconfigure.metrics.OnlyOnceLoggingDenyMeterFilter)3 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)3 Order (org.springframework.core.annotation.Order)3 Meter (io.micrometer.core.instrument.Meter)2 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)2 MeterFilterReply (io.micrometer.core.instrument.config.MeterFilterReply)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 HttpData (com.linecorp.armeria.common.HttpData)1 HttpStatus (com.linecorp.armeria.common.HttpStatus)1 MediaType (com.linecorp.armeria.common.MediaType)1 ServerCacheControl (com.linecorp.armeria.common.ServerCacheControl)1 HttpService (com.linecorp.armeria.server.HttpService)1 RedirectService (com.linecorp.armeria.server.RedirectService)1 FileService (com.linecorp.armeria.server.file.FileService)1