/** * This will only be invoked if using a fork of the metrics library with support * for filtering on a per-measurement basis - http://github.com/mspiegel/metrics. * Otherwise this method is not invoked. The @Override annotation is omitted so * that compilation is successful using either the metrics library or the fork of the * metrics library. */ public boolean matches(MetricName name, Metric metric, String measurement) { if ((meter != null) && (metric instanceof Meter)) { return allowMeasurement(name, measurement, meter, meterPatterns); } else if ((histogram != null) && (metric instanceof Histogram)) { return allowMeasurement(name, measurement, histogram, histogramPatterns); } else if ((timer != null) && (metric instanceof Timer)) { return allowMeasurement(name, measurement, timer, timerPatterns); } else { return true; } }
@Override public boolean matches(String name, Metric metric) { log.trace("Checking Metric name: {} {}", new Object[] {name, unqualifyMetricName(name)}); if (predicate.getUseQualifiedName()) { return predicate.allowString(name); } else { return predicate.allowString(unqualifyMetricName(name)); } }
public void setTimer(Measurement timer) { this.timer = timer; this.timerPatterns = createMeasurementPatterns(timer); }
public boolean allowMeasurement(MetricName name, String measurement, Measurement type, List<MeasurementPattern> patterns) { if (type.useQualifiedName) { return allowMeasurement(qualifyMetricName(name), measurement, type, patterns); } else { return allowMeasurement(name.getName(), measurement, type, patterns); } }
@Override public boolean matches(MetricName name, Metric metric) { log.trace("Checking Metric name: {} {}", new Object[] {name.getName(), qualifyMetricName(name)}); if (useQualifiedName) { return allowString(qualifyMetricName(name)); } else { return allowString(name.getName()); } }
if ((predicate.getMeter() != null) && (metric instanceof Meter)) return allowMeasurement(name, measurement, predicate.getMeter(), predicate.getMeterPatterns()); else if ((predicate.getHistogram() != null) && (metric instanceof Histogram)) return allowMeasurement(name, measurement, predicate.getHistogram(), predicate.getHistogramPatterns()); else if ((predicate.getTimer() != null) && (metric instanceof Timer)) return allowMeasurement(name, measurement, predicate.getTimer(), predicate.getTimerPatterns());
@Test public void empty() { PredicateConfig pc = new PredicateConfig("white", new ArrayList()); assertFalse(pc.allowString("foo")); pc = new PredicateConfig("black", new ArrayList()); assertTrue(pc.allowString("foo")); }
if ((predicate.getMeter() != null) && (metric instanceof Meter)) return allowMeasurement(name, measurement, predicate.getMeter(), predicate.getMeterPatterns()); else if ((predicate.getHistogram() != null) && (metric instanceof Histogram)) return allowMeasurement(name, measurement, predicate.getHistogram(), predicate.getHistogramPatterns()); else if ((predicate.getTimer() != null) && (metric instanceof Timer)) return allowMeasurement(name, measurement, predicate.getTimer(), predicate.getTimerPatterns());
@Test public void singleBlack() { PredicateConfig pc = new PredicateConfig("black", ImmutableList.of("^bad.+")); assertTrue(pc.allowString("foo")); assertTrue(pc.allowString("foobad")); assertFalse(pc.allowString("badFoo")); }
@Test public void multiWhite() { PredicateConfig pc = new PredicateConfig("white", ImmutableList.of("^good.+", ".*good$")); assertFalse(pc.allowString("foo")); assertFalse(pc.allowString("foobadfoo")); assertFalse(pc.allowString("foogoodfoo")); assertTrue(pc.allowString("goodFoo")); assertTrue(pc.allowString("foogood")); assertTrue(pc.allowString("goodfoogood")); }
private boolean allowMeasurement(String name, String measurement, PredicateConfig.Measurement type, List<PredicateConfig.MeasurementPattern> patterns) { if (type.getUseQualifiedName()) { return predicate.allowMeasurement(name, measurement, type, patterns); } else { return predicate.allowMeasurement(unqualifyMetricName(name), measurement, type, patterns); } }
@Override public boolean matches(MetricName name, Metric metric) { log.trace("Checking Metric name: {} {}", new Object[] {name.getName(), qualifyMetricName(name)}); if (predicate.getUseQualifiedName()) { return predicate.allowString(qualifyMetricName(name)); } else { return predicate.allowString(name.getName()); } }
public void setHistogram(Measurement histogram) { this.histogram = histogram; this.histogramPatterns = createMeasurementPatterns(histogram); }
@Test public void multiBlack() { PredicateConfig pc = new PredicateConfig("black", ImmutableList.of("^bad.+", ".*bad$")); assertTrue(pc.allowString("foo")); assertTrue(pc.allowString("foobadfoo")); assertFalse(pc.allowString("badFoo")); assertFalse(pc.allowString("foobad")); }
public boolean allowMeasurement(MetricName name, String measurement, PredicateConfig.Measurement type, List<PredicateConfig.MeasurementPattern> patterns) { if (type.getUseQualifiedName()) { return predicate.allowMeasurement(qualifyMetricName(name), measurement, type, patterns); } else { return predicate.allowMeasurement(name.getName(), measurement, type, patterns); } }
public void setMeter(Measurement meter) { this.meter = meter; this.meterPatterns = createMeasurementPatterns(meter); }
@Test public void singleWhite() { PredicateConfig pc = new PredicateConfig("white", ImmutableList.of("^good.+")); assertFalse(pc.allowString("foo")); assertFalse(pc.allowString("foogood")); assertTrue(pc.allowString("goodFoo")); }
@Test public void singleWhiteMeasurement() { MeasurementPattern pattern = new MeasurementPattern("^foo.+", "^bar.+"); List<MeasurementPattern> patternList = new ArrayList<MeasurementPattern>(); patternList.add(pattern); Measurement type = new Measurement("white", false); assertFalse(PredicateConfig.allowMeasurement("foo", "bar", type, patternList)); assertFalse(PredicateConfig.allowMeasurement("foo", "bars", type, patternList)); assertFalse(PredicateConfig.allowMeasurement("foos", "bar", type, patternList)); assertTrue(PredicateConfig.allowMeasurement("foos", "bars", type, patternList)); }
public void setTimer(Measurement timer) { this.timer = timer; this.timerPatterns = createMeasurementPatterns(timer); }
@Test public void jmxRegex() { PredicateConfig pc = new PredicateConfig("black", ImmutableList.of(".*JMXONLY$")); assertTrue(pc.allowString("foo")); assertTrue(pc.allowString("foobad")); assertTrue(pc.allowString("badFoo")); assertTrue(pc.allowString("com.example.foo.CoolMetric")); assertFalse(pc.allowString("com.example.foo.CoolMetric_JMXONLY")); }