contrueCT commented on code in PR #7882:
URL: https://github.com/apache/incubator-seata/pull/7882#discussion_r2678463851


##########
namingserver/src/main/java/org/apache/seata/namingserver/metrics/NamingServerTagsContributor.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.seata.namingserver.metrics;
+
+import io.micrometer.common.KeyValue;
+import io.micrometer.common.KeyValues;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import 
org.springframework.http.server.observation.DefaultServerRequestObservationConvention;
+import 
org.springframework.http.server.observation.ServerRequestObservationContext;
+import org.springframework.stereotype.Component;
+
+/**
+ * Custom tags contributor for HTTP server request metrics.
+ * Adds Seata business dimensions (namespace, cluster, vgroup) to
+ * http.server.requests metrics.
+ */
+@Component
+@ConditionalOnProperty(name = "seata.namingserver.metrics.enabled", 
havingValue = "true")
+public class NamingServerTagsContributor extends 
DefaultServerRequestObservationConvention {
+
+    private static final String TAG_NAMESPACE = "namespace";
+    private static final String TAG_CLUSTER = "cluster";
+    private static final String TAG_VGROUP = "vgroup";
+    private static final String UNKNOWN = "unknown";
+
+    @Override
+    public KeyValues 
getLowCardinalityKeyValues(ServerRequestObservationContext context) {
+        KeyValues keyValues = super.getLowCardinalityKeyValues(context);

Review Comment:
   Now the NamingServerTagsContributor class and the 
PrometheusNamingMetricsManager class are work for different kind of metrics, 
the NamingServerTagsContributor class is only for adds custom tags (namespace, 
cluster, vgroup)
   to Spring Boot's built-in `http.server.requests` metric. The 
PrometheusNamingMetricsManager manages custom business metrics 
(seata_namingserver_cluster_node_count, seata_namingserver_watcher_count, 
etc.). These metrics get their tags directly from internal data structures, not 
from HTTP requests.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to