Copilot commented on code in PR #13692: URL: https://github.com/apache/skywalking/pull/13692#discussion_r2766909429
########## oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/metrics/adapters/ListenerMetricsAdapter.java: ########## @@ -0,0 +1,41 @@ +/* + * 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.skywalking.oap.server.receiver.envoy.metrics.adapters; + +import io.prometheus.client.Metrics; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +@RequiredArgsConstructor Review Comment: The @RequiredArgsConstructor annotation is unnecessary here since ListenerMetricsAdapter has no fields. This annotation generates a constructor for all final fields, but since there are no fields in this class, it only generates a no-args constructor, which is the default behavior in Java. The annotation should be removed for clarity, or the class could use a standard no-args constructor if needed. Note that ClusterManagerMetricsAdapter at line 33-36 has a final field 'config' which justifies its use of @RequiredArgsConstructor. ```suggestion import lombok.extern.slf4j.Slf4j; @Slf4j ``` ########## oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/MetricServiceGRPCHandler.java: ########## @@ -112,7 +113,7 @@ public void onNext(StreamMetricsMessage message) { counter.inc(); try (final HistogramMetrics.Timer ignored = histogram.createTimer()) { final ProtoMetricFamily2MetricsAdapter adapter = new ProtoMetricFamily2MetricsAdapter( - metricFamily, config.getClusterManagerMetricsAdapter()); + metricFamily, config.getClusterManagerMetricsAdapter(), new ListenerMetricsAdapter()); Review Comment: The ListenerMetricsAdapter is instantiated inline here, which is inconsistent with how ClusterManagerMetricsAdapter is handled. ClusterManagerMetricsAdapter is instantiated once in EnvoyMetricReceiverConfig and reused, but ListenerMetricsAdapter is created for each metric family in the loop. This creates unnecessary object allocations. Consider following the same pattern as ClusterManagerMetricsAdapter by adding a getter in EnvoyMetricReceiverConfig (similar to clusterManagerMetricsAdapter at line 69 of EnvoyMetricReceiverConfig.java) and using config.getListenerMetricsAdapter() here instead. ########## oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/metrics/adapters/ListenerMetricsAdapter.java: ########## @@ -0,0 +1,41 @@ +/* + * 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.skywalking.oap.server.receiver.envoy.metrics.adapters; + +import io.prometheus.client.Metrics; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +@Slf4j Review Comment: The @Slf4j annotation is unused in this class. There are no log statements in any of the methods. The annotation should be removed unless logging will be added in the future. For reference, ClusterManagerMetricsAdapter at line 52 uses logging (log.error) which justifies its @Slf4j annotation. ```suggestion ``` -- 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]
