Search in sources :

Example 1 with MetricGroup

use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.

the class WorkerSinkTaskTest method assertTaskMetricValue.

private void assertTaskMetricValue(String name, String expected) {
    MetricGroup taskGroup = workerTask.taskMetricsGroup().metricGroup();
    String measured = metrics.currentMetricValueAsString(taskGroup, name);
    assertEquals(expected, measured);
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)

Example 2 with MetricGroup

use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.

the class WorkerSinkTaskTest method assertTaskMetricValue.

private void assertTaskMetricValue(String name, double expected) {
    MetricGroup taskGroup = workerTask.taskMetricsGroup().metricGroup();
    double measured = metrics.currentMetricValueAsDouble(taskGroup, name);
    assertEquals(expected, measured, 0.001d);
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)

Example 3 with MetricGroup

use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.

the class WorkerSinkTaskTest method assertMetrics.

private void assertMetrics(int minimumPollCountExpected) {
    MetricGroup sinkTaskGroup = workerTask.sinkTaskMetricsGroup().metricGroup();
    MetricGroup taskGroup = workerTask.taskMetricsGroup().metricGroup();
    double readRate = metrics.currentMetricValueAsDouble(sinkTaskGroup, "sink-record-read-rate");
    double readTotal = metrics.currentMetricValueAsDouble(sinkTaskGroup, "sink-record-read-total");
    double sendRate = metrics.currentMetricValueAsDouble(sinkTaskGroup, "sink-record-send-rate");
    double sendTotal = metrics.currentMetricValueAsDouble(sinkTaskGroup, "sink-record-send-total");
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)

Example 4 with MetricGroup

use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.

the class WorkerTest method assertStatistics.

private void assertStatistics(Worker worker, int connectors, int tasks) {
    MetricGroup workerMetrics = worker.workerMetricsGroup().metricGroup();
    assertEquals(connectors, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-count"), 0.0001d);
    assertEquals(tasks, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-count"), 0.0001d);
    assertEquals(tasks, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-count"), 0.0001d);
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)

Example 5 with MetricGroup

use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.

the class ConnectMetricsTest method addToGroup.

private int addToGroup(ConnectMetrics connectMetrics, boolean shouldClose) {
    ConnectMetricsRegistry registry = connectMetrics.registry();
    ConnectMetrics.MetricGroup metricGroup = connectMetrics.group(registry.taskGroupName(), registry.connectorTagName(), "conn_name");
    if (shouldClose) {
        metricGroup.close();
    }
    Sensor sensor = metricGroup.sensor("my_sensor");
    sensor.add(metricName("x1"), new Max());
    sensor.add(metricName("y2"), new Avg());
    return metricGroup.metrics().metrics().size();
}
Also used : MetricGroup(org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup) Avg(org.apache.kafka.common.metrics.stats.Avg) Max(org.apache.kafka.common.metrics.stats.Max) Sensor(org.apache.kafka.common.metrics.Sensor)

Aggregations

MetricGroup (org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup)29 Test (org.junit.Test)4 Sensor (org.apache.kafka.common.metrics.Sensor)2 Avg (org.apache.kafka.common.metrics.stats.Avg)2 Max (org.apache.kafka.common.metrics.stats.Max)2 HerderMetrics (org.apache.kafka.connect.runtime.distributed.DistributedHerder.HerderMetrics)2