funky-eyes commented on code in PR #7882: URL: https://github.com/apache/incubator-seata/pull/7882#discussion_r2667188429
########## 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: Is this only applicable to requests that include a namespace and vgroup? If so, how should the tags be added in the PrometheusNamingMetricsManager class? For example, when a vgroup under a specific namespace's cluster performs a watch operation, or when fetching cluster information. -- 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]
