use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project apache-kafka-on-k8s by banzaicloud.
the class ConnectMetricsTest method testGettingGroupMultipleTimes.
@Test
public void testGettingGroupMultipleTimes() {
MetricGroup group1 = metrics.group("name");
MetricGroup group2 = metrics.group("name");
assertNotNull(group1);
assertSame(group1, group2);
MetricGroup group3 = metrics.group("other");
assertNotNull(group3);
assertNotSame(group1, group3);
// Now with tags
MetricGroup group4 = metrics.group("name", "k1", "v1");
assertNotNull(group4);
assertNotSame(group1, group4);
assertNotSame(group2, group4);
assertNotSame(group3, group4);
MetricGroup group5 = metrics.group("name", "k1", "v1");
assertSame(group4, group5);
}
use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project kafka by apache.
the class ConnectMetricsTest method testGettingGroupWithTags.
@Test
public void testGettingGroupWithTags() {
MetricGroup group1 = metrics.group("name", "k1", "v1", "k2", "v2");
assertEquals("v1", group1.tags().get("k1"));
assertEquals("v2", group1.tags().get("k2"));
assertEquals(2, group1.tags().size());
}
use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project kafka by apache.
the class WorkerTest method assertStartupStatistics.
private void assertStartupStatistics(Worker worker, int connectorStartupAttempts, int connectorStartupFailures, int taskStartupAttempts, int taskStartupFailures) {
double connectStartupSuccesses = connectorStartupAttempts - connectorStartupFailures;
double taskStartupSuccesses = taskStartupAttempts - taskStartupFailures;
double connectStartupSuccessPct = 0.0d;
double connectStartupFailurePct = 0.0d;
double taskStartupSuccessPct = 0.0d;
double taskStartupFailurePct = 0.0d;
if (connectorStartupAttempts != 0) {
connectStartupSuccessPct = connectStartupSuccesses / connectorStartupAttempts;
connectStartupFailurePct = (double) connectorStartupFailures / connectorStartupAttempts;
}
if (taskStartupAttempts != 0) {
taskStartupSuccessPct = taskStartupSuccesses / taskStartupAttempts;
taskStartupFailurePct = (double) taskStartupFailures / taskStartupAttempts;
}
MetricGroup workerMetrics = worker.workerMetricsGroup().metricGroup();
assertEquals(connectorStartupAttempts, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-startup-attempts-total"), 0.0001d);
assertEquals(connectStartupSuccesses, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-startup-success-total"), 0.0001d);
assertEquals(connectorStartupFailures, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-startup-failure-total"), 0.0001d);
assertEquals(connectStartupSuccessPct, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-startup-success-percentage"), 0.0001d);
assertEquals(connectStartupFailurePct, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "connector-startup-failure-percentage"), 0.0001d);
assertEquals(taskStartupAttempts, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-startup-attempts-total"), 0.0001d);
assertEquals(taskStartupSuccesses, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-startup-success-total"), 0.0001d);
assertEquals(taskStartupFailures, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-startup-failure-total"), 0.0001d);
assertEquals(taskStartupSuccessPct, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-startup-success-percentage"), 0.0001d);
assertEquals(taskStartupFailurePct, MockConnectMetrics.currentMetricValueAsDouble(worker.metrics(), workerMetrics, "task-startup-failure-percentage"), 0.0001d);
}
use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project kafka by apache.
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");
}
use of org.apache.kafka.connect.runtime.ConnectMetrics.MetricGroup in project kafka by apache.
the class WorkerSinkTaskTest method taskMetricValue.
private double taskMetricValue(String metricName) {
MetricGroup taskGroup = workerTask.taskMetricsGroup().metricGroup();
double value = metrics.currentMetricValueAsDouble(taskGroup, metricName);
System.out.println("** " + metricName + "=" + value);
return value;
}
Aggregations