peachisai commented on code in PR #13119:
URL: https://github.com/apache/skywalking/pull/13119#discussion_r2005158859


##########
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java:
##########
@@ -121,11 +121,24 @@ public void processMetricsRequest(final 
ExportMetricsServiceRequest requests) {
                                .flatMap(tryIt -> MetricConvert.log(tryIt, 
"Convert OTEL metric to prometheus metric"))
                            )
                 );
-                converters.forEach(convert -> convert.toMeter(sampleFamilies));
+
+                convertSampleFamiliesToMeter(sampleFamilies);
             });
         }
     }
 
+    private void convertSampleFamiliesToMeter(ImmutableMap<String, 
SampleFamily> sampleFamilies) {
+        if (sampleFamilies.isEmpty()) {
+            return;
+        }
+        SampleFamily firstValue = sampleFamilies.values().iterator().next();
+        for (MetricConvert converter : converters) {
+            if (converter.shouldConvert(firstValue)) {

Review Comment:
   > As it is a closure, how would you make sure of that? Are you going to 
provide a new function rather than a general closure?
   
   Every analyzer shares the same filter expression, We only need to use a 
single analyzer to filter the metrics. If none of the metrics meet the 
conditions, there is no need to execute the logic of other analyzers.
   And for the ```job_name``` label my idea is to use a pattern to parse the 
```jobName``` during the start phase and store it in ```FilterExpression```. 
This way, we only need to check one metric in  a analyzer, eliminating the need 
to filter all metrics.



-- 
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]

Reply via email to