You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/17 09:45:24 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #14723: [Broker] Improve SchemaRegistry logs and metrics

codelipenghui commented on a change in pull request #14723:
URL: https://github.com/apache/pulsar/pull/14723#discussion_r828931987



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryStats.java
##########
@@ -0,0 +1,157 @@
+/**
+ * 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.pulsar.broker.service.schema;
+
+import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.Counter;
+import io.prometheus.client.Summary;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+class SchemaRegistryStats implements AutoCloseable {
+    private static final String SCHEMA_ID = "schema";
+    private static final String STATUS = "status";
+    private static final String CLUSTER = "cluster";
+    private static final String STATUS_SUCCESS = "success";
+    private static final String STATUS_FAILED = "failed";
+    private static final double[] QUANTILES = {0.50, 0.75, 0.95, 0.99};
+    private static final AtomicBoolean CLOSED = new AtomicBoolean(false);
+
+    private final Counter delSchemaOps;
+    private final Counter getSchemaOps;
+    private final Counter putSchemaOps;
+
+    private final Counter schemaIncompatibleCount;
+    private final Counter schemaCompatibleCount;
+
+    private final Summary delSchemaLatency;
+    private final Summary getSchemaLatency;
+    private final Summary putSchemaLatency;
+    private final String clusterName;
+
+    private static volatile SchemaRegistryStats instance;
+
+    static synchronized SchemaRegistryStats getInstance(final int interval, final String cluster) {
+        if (null == instance) {
+            instance = new SchemaRegistryStats(interval, cluster);
+        }
+
+        return instance;
+    }
+
+    private SchemaRegistryStats(final int interval, final String cluster) {
+        this.clusterName = cluster;
+
+        this.delSchemaOps = Counter.build("pulsar_schema_del_ops_count", "-")
+                .labelNames(CLUSTER, SCHEMA_ID, STATUS)
+                .create()
+                .register();
+        this.getSchemaOps = Counter.build("pulsar_schema_get_ops_count", "-")
+                .labelNames(CLUSTER, SCHEMA_ID, STATUS)
+                .create()
+                .register();
+        this.putSchemaOps = Counter.build("pulsar_schema_put_ops_count", "-")
+                .labelNames(CLUSTER, SCHEMA_ID, STATUS)
+                .create()
+                .register();
+
+        this.schemaCompatibleCount = Counter.build("pulsar_schema_compatible_count", "-")
+                .labelNames(CLUSTER, SCHEMA_ID)
+                .create()
+                .register();
+        this.schemaIncompatibleCount = Counter.build("pulsar_schema_incompatible_count", "-")
+                .labelNames(CLUSTER, SCHEMA_ID)
+                .create()
+                .register();
+
+        this.delSchemaLatency = this.setQuantiles(
+                Summary.build("pulsar_schema_del_ops_latency", "-")
+                        .maxAgeSeconds(interval).labelNames(CLUSTER, SCHEMA_ID));
+        this.getSchemaLatency = this.setQuantiles(
+                Summary.build("pulsar_schema_get_ops_latency", "-")
+                        .maxAgeSeconds(interval).labelNames(CLUSTER, SCHEMA_ID));
+        this.putSchemaLatency = this.setQuantiles(
+                Summary.build("pulsar_schema_put_ops_latency", "-")
+                        .maxAgeSeconds(interval).labelNames(CLUSTER, SCHEMA_ID));

Review comment:
       If we use summary here, we don't need to add _count above? The summary should expose the _count and _sum.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryStats.java
##########
@@ -0,0 +1,157 @@
+/**
+ * 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.pulsar.broker.service.schema;
+
+import io.prometheus.client.CollectorRegistry;
+import io.prometheus.client.Counter;
+import io.prometheus.client.Summary;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+class SchemaRegistryStats implements AutoCloseable {
+    private static final String SCHEMA_ID = "schema";
+    private static final String STATUS = "status";
+    private static final String CLUSTER = "cluster";
+    private static final String STATUS_SUCCESS = "success";
+    private static final String STATUS_FAILED = "failed";
+    private static final double[] QUANTILES = {0.50, 0.75, 0.95, 0.99};

Review comment:
       ```suggestion
       private static final double[] QUANTILES = {0.50, 0.75, 0.95, 0.99, 0.999, 0.9999, 1};
   ```




-- 
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: commits-unsubscribe@pulsar.apache.org

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