use of com.codahale.metrics.Histogram in project riposte by Nike-Inc.
the class SignalFxAwareCodahaleMetricsCollectorTest method kitchen_sink_constructor_throws_IllegalArgumentException_when_passed_null_arguments.
@DataProvider(value = { "NULL_METRIC_REGISTRY", "NULL_METRIC_METADATA", "NULL_TIMER_BUILDER", "NULL_HISTORGRAM_BUILDER" })
@Test
public void kitchen_sink_constructor_throws_IllegalArgumentException_when_passed_null_arguments(NullArgScenario scenario) {
// given
MetricRegistry registry = scenario.metricRegistryIsNull ? null : metricRegistryMock;
MetricMetadata metadata = scenario.metricMetadataIsNull ? null : metricMetadataMock;
MetricBuilder<Timer> timerBuilder = scenario.timerBuilderIsNull ? null : timerBuilderMock;
MetricBuilder<Histogram> histogramBuilder = scenario.histogramBuilderIsNull ? null : histogramBuilderMock;
// when
Throwable ex = catchThrowable(() -> new SignalFxAwareCodahaleMetricsCollector(registry, metadata, timerBuilder, histogramBuilder));
// then
assertThat(ex).isInstanceOf(IllegalArgumentException.class).hasMessage(scenario.expectedExceptionMessage);
}
use of com.codahale.metrics.Histogram in project Singularity by HubSpot.
the class SingularityTaskReconciliation method startReconciliation.
public ReconciliationState startReconciliation() {
if (statusUpdateHandler.getQueueFullness() >= configuration.getStatusQueueNearlyFull()) {
LOG.info("Queue is nearly full, not starting reconciliation");
return isRunningReconciliation.get() ? ReconciliationState.ALREADY_RUNNING : ReconciliationState.NO_DRIVER;
}
final long taskReconciliationStartedAt = System.currentTimeMillis();
if (!isRunningReconciliation.compareAndSet(false, true)) {
LOG.info("Reconciliation is already running, NOT starting a new reconciliation process");
return ReconciliationState.ALREADY_RUNNING;
}
if (!schedulerClient.isRunning()) {
LOG.trace("Not running reconciliation - no active scheduler present");
isRunningReconciliation.set(false);
return ReconciliationState.NO_DRIVER;
}
final List<SingularityTaskId> activeTaskIds = taskManager.getActiveTaskIds();
LOG.info("Starting a reconciliation cycle - {} current active tasks", activeTaskIds.size());
schedulerClient.reconcile(Collections.emptyList());
scheduleReconciliationCheck(taskReconciliationStartedAt, activeTaskIds, 0, new Histogram(new UniformReservoir()));
return ReconciliationState.STARTED;
}
use of com.codahale.metrics.Histogram in project torodb by torodb.
the class ConcurrentOplogBatchExecutorTest method testExecute.
@Test
public void testExecute() throws Exception {
int batchSize = 100;
int opsPerJob = 20;
int subBatchSize = 11;
int subBatchesPerJob = opsPerJob / subBatchSize + (opsPerJob % subBatchSize != 0 ? 1 : 0);
int expectedSize = batchSize * subBatchesPerJob;
//GIVEN
CudAnalyzedOplogBatch batch = mock(CudAnalyzedOplogBatch.class);
List<NamespaceJob> jobs = new ArrayList<>();
for (int i = 0; i < batchSize; i++) {
jobs.add(new NamespaceJob("db", "col", Lists.newArrayList(Stream.iterate(createAnalyzedOp(null), this::createAnalyzedOp).limit(opsPerJob).iterator())));
}
AtomicInteger callablesCounter = new AtomicInteger(0);
ApplierContext context = new ApplierContext.Builder().setReapplying(true).setUpdatesAsUpserts(true).build();
Histogram mockHistogram = mock(Histogram.class);
Meter mockMeter = mock(Meter.class);
given(batch.streamNamespaceJobs()).willReturn(jobs.stream());
given(subBatchHeuristic.getSubBatchSize(any())).willReturn(subBatchSize);
given(metrics.getSubBatchSizeHistogram()).willReturn(mockHistogram);
given(metrics.getSubBatchSizeMeter()).willReturn(mockMeter);
given(streamExecutor.execute(any())).willAnswer(new Answer<CompletableFuture<?>>() {
@Override
public CompletableFuture<?> answer(InvocationOnMock invocation) throws Throwable {
CompletableFuture<Object> completableFuture = new CompletableFuture<>();
completableFuture.complete(new Object());
Stream<Callable<?>> callables = invocation.getArgument(0);
callablesCounter.addAndGet((int) callables.count());
return completableFuture;
}
});
//WHEN
executor.execute(batch, context);
//THEN
then(mockHistogram).should().update(expectedSize);
then(mockMeter).should().mark(expectedSize);
assertEquals(expectedSize, callablesCounter.get());
}
use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.
the class SearchesTest method fieldStatsRecordsMetrics.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void fieldStatsRecordsMetrics() throws Exception {
FieldStatsResult result = searches.fieldStats("n", "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
assertThat(timer.getCount()).isEqualTo(1L);
Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
assertThat(histogram.getCount()).isEqualTo(1L);
assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.
the class SearchesTest method termsRecordsMetrics.
@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void termsRecordsMetrics() throws Exception {
TermsResult result = searches.terms("n", 25, "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
assertThat(timer.getCount()).isEqualTo(1L);
Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
assertThat(histogram.getCount()).isEqualTo(1L);
assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
Aggregations