Java Code Examples for io.micrometer.core.instrument.config.MeterFilterReply#DENY

The following examples show how to use io.micrometer.core.instrument.config.MeterFilterReply#DENY . 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: OnlyOnceLoggingDenyMeterFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
@Override
public MeterFilterReply accept(Meter.Id id) {
    if (logger.isWarnEnabled()
            && this.alreadyWarned.compareAndSet(false, true)) {
        logger.warn(this.message.get());
    }
    return MeterFilterReply.DENY;
}
 
Example 2
Source File: CommonMetricsFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
/**
 * Filter for "[PREFIX]_*"
 *
 * @param id
 * @return MeterFilterReply
 */
public MeterFilterReply accept(Meter.Id id) {
    if (!k8sMetricsProperties.isEnableCommonMetricsFilter()) {
        return MeterFilter.super.accept(id);
    }

    String metricName = id.getName();

    Boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, null);
    if (enabled != null) {
        return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
    }

    if (whitelist.contains(metricName)) {
        return MeterFilterReply.NEUTRAL;
    }
    if (blacklist.contains(metricName)) {
        return MeterFilterReply.DENY;
    }

    for(String prefix: prefixes) {
        if (metricName.startsWith(prefix)) {
            return MeterFilterReply.ACCEPT;
        }
    }

    for(String key: tagRules.keySet()) {
        String expectedValue = tagRules.get(key);
        if (expectedValue != null) {
            if (expectedValue.equals(id.getTag(key))) {
                return MeterFilterReply.ACCEPT;
            }
        }
    }

    return MeterFilterReply.DENY;
}
 
Example 3
Source File: CommonMetricsFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
/**
 * Filter for "[PREFIX]_*"
 *
 * @param id
 * @return MeterFilterReply
 */
public MeterFilterReply accept(Meter.Id id) {
    if (!k8sMetricsProperties.isEnableCommonMetricsFilter()) {
        return MeterFilter.super.accept(id);
    }

    String metricName = id.getName();

    Boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, null);
    if (enabled != null) {
        return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
    }

    if (whitelist.contains(metricName)) {
        return MeterFilterReply.NEUTRAL;
    }
    if (blacklist.contains(metricName)) {
        return MeterFilterReply.DENY;
    }

    for(String prefix: prefixes) {
        if (metricName.startsWith(prefix)) {
            return MeterFilterReply.ACCEPT;
        }
    }

    for(String key: tagRules.keySet()) {
        String expectedValue = tagRules.get(key);
        if (expectedValue != null) {
            if (expectedValue.equals(id.getTag(key))) {
                return MeterFilterReply.ACCEPT;
            }
        }
    }

    return MeterFilterReply.DENY;
}
 
Example 4
Source File: OnlyOnceLoggingDenyMeterFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
@Override
public MeterFilterReply accept(Meter.Id id) {
    if (logger.isWarnEnabled()
            && this.alreadyWarned.compareAndSet(false, true)) {
        logger.warn(this.message.get());
    }
    return MeterFilterReply.DENY;
}
 
Example 5
Source File: CommonMetricsFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
/**
 * Filter for "[PREFIX]_*"
 *
 * @param id
 * @return MeterFilterReply
 */
public MeterFilterReply accept(Meter.Id id) {
    if (!k8sMetricsProperties.isEnableCommonMetricsFilter()) {
        return MeterFilter.super.accept(id);
    }

    String metricName = id.getName();

    Boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, null);
    if (enabled != null) {
        return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
    }

    if (whitelist.contains(metricName)) {
        return MeterFilterReply.NEUTRAL;
    }
    if (blacklist.contains(metricName)) {
        return MeterFilterReply.DENY;
    }

    for(String prefix: prefixes) {
        if (metricName.startsWith(prefix)) {
            return MeterFilterReply.ACCEPT;
        }
    }

    for(String key: tagRules.keySet()) {
        String expectedValue = tagRules.get(key);
        if (expectedValue != null) {
            if (expectedValue.equals(id.getTag(key))) {
                return MeterFilterReply.ACCEPT;
            }
        }
    }

    return MeterFilterReply.DENY;
}
 
Example 6
Source File: CommonMetricsFilter.java    From foremast with Apache License 2.0 5 votes vote down vote up
/**
 * Filter for "[PREFIX]_*"
 *
 * @param id
 * @return MeterFilterReply
 */
public MeterFilterReply accept(Meter.Id id) {
    if (!k8sMetricsProperties.isEnableCommonMetricsFilter()) {
        return MeterFilter.super.accept(id);
    }

    String metricName = id.getName();

    Boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, null);
    if (enabled != null) {
        return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
    }

    if (whitelist.contains(metricName)) {
        return MeterFilterReply.NEUTRAL;
    }
    if (blacklist.contains(metricName)) {
        return MeterFilterReply.DENY;
    }

    for(String prefix: prefixes) {
        if (metricName.startsWith(prefix)) {
            return MeterFilterReply.ACCEPT;
        }
    }

    for(String key: tagRules.keySet()) {
        String expectedValue = tagRules.get(key);
        if (expectedValue != null) {
            if (expectedValue.equals(id.getTag(key))) {
                return MeterFilterReply.ACCEPT;
            }
        }
    }

    return MeterFilterReply.DENY;
}
 
Example 7
Source File: MeterRegistry.java    From micrometer with Apache License 2.0 5 votes vote down vote up
private boolean accept(Meter.Id id) {
    for (MeterFilter filter : filters) {
        MeterFilterReply reply = filter.accept(id);
        if (reply == MeterFilterReply.DENY) {
            return false;
        } else if (reply == MeterFilterReply.ACCEPT) {
            return true;
        }
    }
    return true;
}
 
Example 8
Source File: OnlyOnceLoggingDenyMeterFilter.java    From micrometer with Apache License 2.0 5 votes vote down vote up
@Override
public MeterFilterReply accept(Id id) {
    if (logger.isWarnEnabled() && this.alreadyWarned.compareAndSet(false, true)) {
        logger.warn(this.message.get());
    }
    return MeterFilterReply.DENY;
}
 
Example 9
Source File: HealthMeterRegistry.java    From micrometer with Apache License 2.0 5 votes vote down vote up
private boolean accept(Meter.Id id) {
    for (MeterFilter filter : serviceLevelObjectiveFilters) {
        MeterFilterReply reply = filter.accept(id);
        if (reply == MeterFilterReply.DENY) {
            return false;
        } else if (reply == MeterFilterReply.ACCEPT) {
            return true;
        }
    }
    return true;
}
 
Example 10
Source File: PropertiesMeterFilter.java    From foremast with Apache License 2.0 4 votes vote down vote up
@Override
public MeterFilterReply accept(Meter.Id id) {
    boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, true);
    return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
}
 
Example 11
Source File: PropertiesMeterFilter.java    From foremast with Apache License 2.0 4 votes vote down vote up
@Override
public MeterFilterReply accept(Meter.Id id) {
    boolean enabled = lookupWithFallbackToAll(this.properties.getEnable(), id, true);
    return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
}