com.yammer.metrics.core.MetricProcessor Java Examples

The following examples show how to use com.yammer.metrics.core.MetricProcessor. 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: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Counter createCounter(long count) throws Exception {
  final Counter mock = mock(Counter.class);
  when(mock.count()).thenReturn(count);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processCounter(name, mock, context);
    }
  }));
}
 
Example #2
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Histogram createHistogram() throws Exception {
  final Histogram mock = mock(Histogram.class);
  setupSummarizableMock(mock);
  setupSamplingMock(mock);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processHistogram(name, mock, context);
    }
  }));
}
 
Example #3
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Gauge<Object> createGauge(Object value) throws Exception {
  @SuppressWarnings("unchecked")
  final Gauge<Object> mock = mock(Gauge.class);
  when(mock.value()).thenReturn(value);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processGauge(name, mock, context);
    }
  }));
}
 
Example #4
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Timer createTimer() throws Exception {
  final Timer mock = mock(Timer.class);
  when(mock.durationUnit()).thenReturn(TimeUnit.MILLISECONDS);
  setupSummarizableMock(mock);
  setupMeteredMock(mock);
  setupSamplingMock(mock);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processTimer(name, mock, context);
    }
  }));
}
 
Example #5
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
static Meter createMeter() throws Exception {
  final Meter mock = mock(Meter.class);
  setupMeteredMock(mock);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processMeter(name, mock, context);
    }
  }));
}
 
Example #6
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 5 votes vote down vote up
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
  @SuppressWarnings("unchecked")
  final MetricProcessor<Object> processor = (MetricProcessor<Object>) invocation.getArguments()[0];
  final MetricName name = (MetricName) invocation.getArguments()[1];
  final Object context = invocation.getArguments()[2];
  delegateToProcessor(processor, name, context);
  return null;
}
 
Example #7
Source File: AggregatedMeter.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Override
public <T2> void processWith(MetricProcessor<T2> processor, MetricName name, T2 context)
    throws Exception {
  for (T m : _meters) {
    m.processWith(processor, name, context);
  }
}
 
Example #8
Source File: AggregatedCounter.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Override
public <T> void processWith(MetricProcessor<T> processor, MetricName name, T context)
    throws Exception {
  for (Metric c : _counters) {
    c.processWith(processor, name, context);
  }
}
 
Example #9
Source File: AggregatedHistogram.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Override
public <T2> void processWith(MetricProcessor<T2> processor, MetricName name, T2 context)
    throws Exception {
  for (T h : _histograms) {
    if (h instanceof Metric) {
      ((Metric) h).processWith(processor, name, context);
    }
  }
}
 
Example #10
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
static <T extends Metric> T configureMatcher(T mock, Stubber stub) throws Exception {
  stub.when(mock).processWith(any(MetricProcessor.class), any(MetricName.class), any());
  return mock;
}
 
Example #11
Source File: StatsDReporterTest.java    From kafka-statsd-metrics2 with Apache License 2.0 votes vote down vote up
abstract void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception;