@Test public void testTimerMatch() { // create timer with id "testMetricAlerts" and register with metric registry, bump up value to // 4. Timer t = MetricsConfigurator.createTimer(metrics, "testTimerMatch", PIPELINE_NAME, REVISION); t.update(1000, TimeUnit.MILLISECONDS); t.update(2000, TimeUnit.MILLISECONDS); t.update(3000, TimeUnit.MILLISECONDS); MetricsRuleDefinition metricsRuleDefinition = new MetricsRuleDefinition( "testTimerMatch", "testTimerMatch", "testTimerMatch", MetricType.TIMER, MetricElement.TIMER_COUNT, "${value()>2}", false, true); MetricRuleEvaluator metricRuleEvaluator = new MetricRuleEvaluator( metricsRuleDefinition, metrics, new AlertManager( PIPELINE_NAME, REVISION, null, metrics, runtimeInfo, new EventListenerManager()), Collections.<String>emptyList()); metricRuleEvaluator.checkForAlerts(); // get alert gauge Gauge<Object> gauge = MetricsConfigurator.getGauge( metrics, AlertsUtil.getAlertGaugeName(metricsRuleDefinition.getId())); Assert.assertNotNull(gauge); Assert.assertEquals((long) 3, ((Map<String, Object>) gauge.getValue()).get("currentValue")); }
@Override public Timer createTimer(String name) { return MetricsConfigurator.createTimer( getMetrics(), CUSTOM_METRICS_PREFIX + instanceName + "." + name, pipelineName, rev); }