Search in sources :

Example 1 with SystemTime

use of io.confluent.common.utils.SystemTime in project ksql by confluentinc.

the class ConsumerCollectorTest method shouldDisplayRateThroughput.

@Test
public void shouldDisplayRateThroughput() throws Exception {
    // 
    ConsumerCollector collector = new ConsumerCollector();
    collector.configure(new Metrics(), "group", new SystemTime());
    for (int i = 0; i < 100; i++) {
        Map<TopicPartition, List<ConsumerRecord<Object, Object>>> records = ImmutableMap.of(new TopicPartition(TEST_TOPIC, 1), Arrays.asList(new ConsumerRecord<>(TEST_TOPIC, 1, i, 1l, TimestampType.CREATE_TIME, 1l, 10, 10, "key", "1234567890")));
        ConsumerRecords<Object, Object> consumerRecords = new ConsumerRecords<>(records);
        collector.onConsume(consumerRecords);
    }
    Collection<TopicSensors.Stat> stats = collector.stats(TEST_TOPIC, false);
    assertNotNull(stats);
    assertThat(stats.toString(), containsString("name=consumer-messages-per-sec,"));
    assertThat(stats.toString(), containsString("total-messages, value=100.0"));
}
Also used : ConsumerRecords(org.apache.kafka.clients.consumer.ConsumerRecords) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) Metrics(org.apache.kafka.common.metrics.Metrics) TopicPartition(org.apache.kafka.common.TopicPartition) SystemTime(io.confluent.common.utils.SystemTime) Test(org.junit.Test)

Aggregations

SystemTime (io.confluent.common.utils.SystemTime)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 ConsumerRecords (org.apache.kafka.clients.consumer.ConsumerRecords)1 TopicPartition (org.apache.kafka.common.TopicPartition)1 Metrics (org.apache.kafka.common.metrics.Metrics)1 Test (org.junit.Test)1