io.micrometer.core.instrument.noop.NoopCounter Java Examples

The following examples show how to use io.micrometer.core.instrument.noop.NoopCounter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MeterRegistryTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #2
Source File: MeterRegistryTest.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Test
void overridingAcceptMeterFilter() {
    registry.config().meterFilter(MeterFilter.accept(m -> m.getName().startsWith("jvm.important")));
    registry.config().meterFilter(MeterFilter.deny(m -> m.getName().startsWith("jvm")));
	
    assertThat(registry.counter("jvm.my.counter")).isInstanceOf(NoopCounter.class);
    assertThat(registry.counter("jvm.important.counter")).isNotInstanceOf(NoopCounter.class);
    assertThat(registry.counter("my.counter")).isNotInstanceOf(NoopCounter.class);
}
 
Example #3
Source File: CompositeCounter.java    From micrometer with Apache License 2.0 4 votes vote down vote up
@Override
Counter newNoopMeter() {
    return new NoopCounter(getId());
}
 
Example #4
Source File: NoopMeterRegistry.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected Counter newCounter(final Meter.Id id) {
    return new NoopCounter(id);
}
 
Example #5
Source File: NoopMeterRegistry.java    From dolphin-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected Meter newMeter(final Meter.Id id, final Meter.Type type, final Iterable<Measurement> measurements) {
    return new NoopCounter(id);
}
 
Example #6
Source File: NoopMeterRegistry.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected Counter newCounter(Id id) {
    return new NoopCounter(id);
}
 
Example #7
Source File: MeterRegistry.java    From micrometer with Apache License 2.0 2 votes vote down vote up
/**
 * Only used by {@link Counter#builder(String)}.
 *
 * @param id The identifier for this counter.
 * @return A new or existing counter.
 */
Counter counter(Meter.Id id) {
    return registerMeterIfNecessary(Counter.class, id, this::newCounter, NoopCounter::new);
}