Search in sources :

Example 66 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project ksql by confluentinc.

the class SlidingWindowRateLimiterTest method getRemaining.

private double getRemaining(final Metrics metrics, final Map<String, String> tags) {
    final MetricName remainingMetricName = new MetricName(METRIC_PREFIX + "-bandwidth-limit-remaining", "_confluent-ksql-limits", "The current value of the bandwidth limiter", tags);
    final KafkaMetric remainingMetric = metrics.metrics().get(remainingMetricName);
    return (double) remainingMetric.metricValue();
}
Also used : MetricName(org.apache.kafka.common.MetricName) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric)

Example 67 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project ksql by confluentinc.

the class SlidingWindowRateLimiterTest method getReject.

private double getReject(final Metrics metrics, final Map<String, String> tags) {
    final MetricName rejectMetricName = new MetricName(METRIC_PREFIX + "-bandwidth-limit-reject-count", "_confluent-ksql-limits", "The number of requests rejected by this limiter", tags);
    final KafkaMetric rejectMetric = metrics.metrics().get(rejectMetricName);
    return (double) rejectMetric.metricValue();
}
Also used : MetricName(org.apache.kafka.common.MetricName) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric)

Example 68 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project ksql by confluentinc.

the class ConcurrencyLimiterTest method getReject.

private double getReject(final Metrics metrics, final Map<String, String> tags) {
    final MetricName rejectMetricName = new MetricName("pull-concurrency-limit-reject-count", "_confluent-ksql-limits", "The number of requests rejected by this limiter", tags);
    final KafkaMetric rejectMetric = metrics.metrics().get(rejectMetricName);
    return (double) rejectMetric.metricValue();
}
Also used : MetricName(org.apache.kafka.common.MetricName) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric)

Example 69 with KafkaMetric

use of org.apache.kafka.common.metrics.KafkaMetric in project ksql by confluentinc.

the class RateLimiterTest method getReject.

private double getReject(final Metrics metrics, final Map<String, String> tags) {
    final MetricName rejectMetricName = new MetricName(METRIC_NAMESPACE + "-rate-limit-reject-count", "_confluent-ksql-limits", "The number of requests rejected by this limiter", tags);
    final KafkaMetric rejectMetric = metrics.metrics().get(rejectMetricName);
    return (double) rejectMetric.metricValue();
}
Also used : MetricName(org.apache.kafka.common.MetricName) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric)

Example 70 with KafkaMetric

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

the class MeteredKeyValueBytesStoreTest method shouldPutAllToInnerStoreAndRecordPutAllMetric.

@SuppressWarnings("unchecked")
@Test
public void shouldPutAllToInnerStoreAndRecordPutAllMetric() {
    inner.putAll(EasyMock.anyObject(List.class));
    EasyMock.expectLastCall();
    init();
    metered.putAll(Collections.singletonList(KeyValue.pair(key, value)));
    final KafkaMetric metric = metric("put-all-rate");
    assertTrue(metric.value() > 0);
    EasyMock.verify(inner);
}
Also used : List(java.util.List) KafkaMetric(org.apache.kafka.common.metrics.KafkaMetric) Test(org.junit.Test)

Aggregations

KafkaMetric (org.apache.kafka.common.metrics.KafkaMetric)129 Test (org.junit.Test)84 MetricName (org.apache.kafka.common.MetricName)59 HashMap (java.util.HashMap)30 LinkedHashMap (java.util.LinkedHashMap)24 Test (org.junit.jupiter.api.Test)23 Map (java.util.Map)18 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)16 Metric (org.apache.kafka.common.Metric)15 MemoryRecordsBuilder (org.apache.kafka.common.record.MemoryRecordsBuilder)14 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)13 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)12 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)12 Value (org.apache.kafka.common.metrics.stats.Value)12 Windowed (org.apache.kafka.streams.kstream.Windowed)12 Sensor (org.apache.kafka.common.metrics.Sensor)11 TopicPartition (org.apache.kafka.common.TopicPartition)10 Metrics (org.apache.kafka.common.metrics.Metrics)10 List (java.util.List)8 Cluster (org.apache.kafka.common.Cluster)8