You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/07/12 08:04:09 UTC

[GitHub] [flink-kubernetes-operator] gyfora commented on a diff in pull request #310: [FLINK-28476] Add metrics for Kubernetes API server access

gyfora commented on code in PR #310:
URL: https://github.com/apache/flink-kubernetes-operator/pull/310#discussion_r918670067


##########
flink-kubernetes-operator/src/test/java/org/apache/flink/kubernetes/operator/metrics/KubernetesClientMetricsTest.java:
##########
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.kubernetes.operator.metrics;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.kubernetes.operator.TestUtils;
+import org.apache.flink.kubernetes.operator.config.FlinkConfigManager;
+import org.apache.flink.kubernetes.operator.utils.KubernetesClientUtils;
+import org.apache.flink.metrics.testutils.MetricListener;
+
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.kubernetes.client.KubernetesClientException;
+import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
+import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/** {@link KubernetesClientMetrics} tests. */
+@EnableKubernetesMockClient(crud = true)
+@TestMethodOrder(OrderAnnotation.class)
+public class KubernetesClientMetricsTest {
+    private KubernetesMockServer mockServer;
+    private final MetricListener listener = new MetricListener();
+
+    private static final String REQUEST_COUNTER = "KubeClient.HttpRequest.Count";
+    private static final String REQUEST_METER = "KubeClient.HttpRequest.NumPerSecond";
+    private static final String REQUEST_FAILED_METER = "KubeClient.HttpRequest.Failed.NumPerSecond";
+    private static final String REQUEST_POST_COUNTER = "KubeClient.HttpRequest.POST.Count";
+    private static final String REQUEST_DELETE_COUNTER = "KubeClient.HttpRequest.DELETE.Count";
+    private static final String REQUEST_FAILED_COUNTER = "KubeClient.HttpRequest.Failed.Count";
+    private static final String RESPONSE_COUNTER = "KubeClient.HttpResponse.Count";
+    private static final String RESPONSE_METER = "KubeClient.HttpResponse.NumPerSecond";
+    private static final String RESPONSE_200_COUNTER = "KubeClient.HttpResponse.200.Count";
+    private static final String RESPONSE_404_COUNTER = "KubeClient.HttpResponse.404.Count";
+    private static final String RESPONSE_LATENCY = "KubeClient.HttpResponse.LatencyNanos";

Review Comment:
   Instead of `LatencyNanos` could we simply call it `TimeNanos` ? I suggest standardize time based metric naming to `TimeUnit`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org