コード例 #1
1
  @Test
  public void testMeterDisabled() {
    // create timer with id "testMetricAlerts" and register with metric registry, bump up value to
    // 4.
    Meter m =
        MetricsConfigurator.createMeter(metrics, "testMeterDisabled", PIPELINE_NAME, REVISION);
    m.mark(1000);

    MetricsRuleDefinition metricsRuleDefinition =
        new MetricsRuleDefinition(
            "testMeterDisabled",
            "testMeterDisabled",
            "testMeterDisabled",
            MetricType.METER,
            MetricElement.METER_COUNT,
            "${value()>100}",
            false,
            false);
    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.assertNull(gauge);
  }
コード例 #2
0
 public static void updateDataRuleMeter(
     MetricRegistry metrics,
     DataRuleDefinition dataRuleDefinition,
     long matchingCount,
     String pipelineName,
     String revision) {
   if (dataRuleDefinition.isMeterEnabled() && matchingCount > 0) {
     Meter meter = MetricsConfigurator.getMeter(metrics, USER_PREFIX + dataRuleDefinition.getId());
     if (meter == null) {
       meter =
           MetricsConfigurator.createMeter(
               metrics, USER_PREFIX + dataRuleDefinition.getId(), pipelineName, revision);
     }
     meter.mark(matchingCount);
   }
 }
コード例 #3
0
 @Override
 public Meter createMeter(String name) {
   return MetricsConfigurator.createMeter(
       getMetrics(), CUSTOM_METRICS_PREFIX + instanceName + "." + name, pipelineName, rev);
 }