Java Code Examples for org.eclipse.microprofile.metrics.MetricFilter#matches()

The following examples show how to use org.eclipse.microprofile.metrics.MetricFilter#matches() . 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: MetricsRegistryImpl.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public void removeMatching(MetricFilter metricFilter) {
    Iterator<Map.Entry<MetricID, Metric>> iterator = metricMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<MetricID, Metric> entry = iterator.next();
        if (metricFilter.matches(entry.getKey(), entry.getValue())) {
            remove(entry.getKey());
        }
    }
}
 
Example 2
Source File: MetricsRegistryImpl.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
@Override
public SortedMap<MetricID, Metric> getMetrics(MetricFilter filter) {
    SortedMap<MetricID, Metric> out = new TreeMap<>();
    for (Map.Entry<MetricID, Metric> entry : metricMap.entrySet()) {
        if (filter.matches(entry.getKey(), entry.getValue())) {
            out.put(entry.getKey(), entry.getValue());
        }
    }
    return out;
}
 
Example 3
Source File: MetricsRegistryImpl.java    From smallrye-metrics with Apache License 2.0 5 votes vote down vote up
private <T extends Metric> SortedMap<MetricID, T> getMetrics(MetricType type, MetricFilter filter) {
    SortedMap<MetricID, T> out = new TreeMap<>();

    for (Map.Entry<MetricID, Metric> entry : metricMap.entrySet()) {
        if (isSameType(entry.getValue(), type)) {
            if (filter.matches(entry.getKey(), entry.getValue())) {
                out.put(entry.getKey(), (T) entry.getValue());
            }
        }
    }
    return out;
}