use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class ActiveTaskCreatorTest method shouldConstructThreadProducerMetric.
private void shouldConstructThreadProducerMetric() {
createTasks();
final MetricName testMetricName = new MetricName("test_metric", "", "", new HashMap<>());
final Metric testMetric = new KafkaMetric(new Object(), testMetricName, (Measurable) (config, now) -> 0, null, new MockTime());
mockClientSupplier.producers.get(0).setMockMetrics(testMetricName, testMetric);
assertThat(mockClientSupplier.producers.size(), is(1));
final Map<MetricName, Metric> producerMetrics = activeTaskCreator.producerMetrics();
assertThat(producerMetrics.size(), is(1));
assertThat(producerMetrics.get(testMetricName), is(testMetric));
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldFlushInnerWhenFlushTimeRecords.
@Test
public void shouldFlushInnerWhenFlushTimeRecords() {
inner.flush();
expectLastCall().once();
init();
metered.flush();
final KafkaMetric metric = metric("flush-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldWriteBytesToInnerStoreAndRecordPutMetric.
@Test
public void shouldWriteBytesToInnerStoreAndRecordPutMetric() {
inner.put(eq(KEY_BYTES), aryEq(VALUE_BYTES));
expectLastCall();
init();
metered.put(KEY, VALUE);
final KafkaMetric metric = metric("put-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldGetRangeFromInnerStoreAndRecordRangeMetric.
@Test
public void shouldGetRangeFromInnerStoreAndRecordRangeMetric() {
expect(inner.range(KEY_BYTES, KEY_BYTES)).andReturn(new KeyValueIteratorStub<>(Collections.singletonList(BYTE_KEY_VALUE_PAIR).iterator()));
init();
final KeyValueIterator<String, String> iterator = metered.range(KEY, KEY);
assertThat(iterator.next().value, equalTo(VALUE));
assertFalse(iterator.hasNext());
iterator.close();
final KafkaMetric metric = metric("range-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
use of org.apache.kafka.common.metrics.KafkaMetric in project kafka by apache.
the class MeteredKeyValueStoreTest method shouldGetBytesFromInnerStoreAndReturnGetMetric.
@Test
public void shouldGetBytesFromInnerStoreAndReturnGetMetric() {
expect(inner.get(KEY_BYTES)).andReturn(VALUE_BYTES);
init();
assertThat(metered.get(KEY), equalTo(VALUE));
final KafkaMetric metric = metric("get-rate");
assertTrue((Double) metric.metricValue() > 0);
verify(inner);
}
Aggregations