Search in sources :

Example 6 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.

the class PushHttpMetricsReporter method init.

@Override
public void init(List<KafkaMetric> initMetrics) {
    synchronized (lock) {
        for (KafkaMetric metric : initMetrics) {
            log.debug("Adding metric {}", metric.metricName());
            metrics.put(metric.metricName(), metric);
        }
    }
}
Also used : KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric)

Example 7 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.

the class MeteredKeyValueBytesStoreTest method shouldWriteBytesToInnerStoreAndRecordPutMetric.

@Test
public void shouldWriteBytesToInnerStoreAndRecordPutMetric() {
    inner.put(EasyMock.eq(keyBytes), EasyMock.aryEq(valueBytes));
    EasyMock.expectLastCall();
    init();
    metered.put(key, value);
    final KafkaMetric metric = metric("put-rate");
    assertTrue(metric.value() > 0);
    EasyMock.verify(inner);
}
Also used : KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) Test(org.junit.Test)

Example 8 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.

the class MeteredKeyValueBytesStoreTest method shouldGetRangeFromInnerStoreAndRecordRangeMetric.

@Test
public void shouldGetRangeFromInnerStoreAndRecordRangeMetric() {
    EasyMock.expect(inner.range(keyBytes, keyBytes)).andReturn(new KeyValueIteratorStub<>(Collections.singletonList(KeyValue.pair(keyBytes, valueBytes)).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(metric.value() > 0);
    EasyMock.verify(inner);
}
Also used : KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) Test(org.junit.Test)

Example 9 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.

the class MeteredKeyValueBytesStoreTest method shouldFlushInnerWhenFlushTimeRecords.

@Test
public void shouldFlushInnerWhenFlushTimeRecords() {
    inner.flush();
    EasyMock.expectLastCall().once();
    init();
    metered.flush();
    final KafkaMetric metric = metric("flush-rate");
    assertTrue(metric.value() > 0);
    EasyMock.verify(inner);
}
Also used : KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) Test(org.junit.Test)

Example 10 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project apache-kafka-on-k8s by banzaicloud.

the class MeteredKeyValueBytesStoreTest method shouldGetBytesFromInnerStoreAndReturnGetMetric.

@Test
public void shouldGetBytesFromInnerStoreAndReturnGetMetric() {
    EasyMock.expect(inner.get(keyBytes)).andReturn(valueBytes);
    init();
    assertThat(metered.get(key), equalTo(value));
    final KafkaMetric metric = metric("get-rate");
    assertTrue(metric.value() > 0);
    EasyMock.verify(inner);
}
Also used : KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) Test(org.junit.Test)

Aggregations

KafkaMetric (org.apache.kafka.common.metrics.KafkaMetric)95 Test (org.junit.Test)73 MetricName (org.apache.kafka.common.MetricName)36 HashMap (java.util.HashMap)17 MemoryRecordsBuilder (org.apache.kafka.common.record.MemoryRecordsBuilder)14 LinkedHashMap (java.util.LinkedHashMap)12 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)12 Windowed (org.apache.kafka.streams.kstream.Windowed)12 Test (org.junit.jupiter.api.Test)11 TopicPartition (org.apache.kafka.common.TopicPartition)10 List (java.util.List)8 Cluster (org.apache.kafka.common.Cluster)8 Node (org.apache.kafka.common.Node)8 Sensor (org.apache.kafka.common.metrics.Sensor)8 LegacyRecord (org.apache.kafka.common.record.LegacyRecord)8 MemoryRecords (org.apache.kafka.common.record.MemoryRecords)8 Record (org.apache.kafka.common.record.Record)8 SimpleRecord (org.apache.kafka.common.record.SimpleRecord)8 Metrics (org.apache.kafka.common.metrics.Metrics)7 PartitionData (org.apache.kafka.common.requests.FetchRequest.PartitionData)7