kezhenxu94 commented on code in PR #10449:
URL: https://github.com/apache/skywalking/pull/10449#discussion_r1117997973


##########
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java:
##########
@@ -161,6 +163,24 @@ private static Map<Double, Long> buildBuckets(
         return result;
     }
 
+    private static Map<Double, Long> buildBucketsFromExponentialHistogram(
+        int positiveOffset, final List<Long> positiveBucketCounts,
+        int negativeOffset, final List<Long> negativeBucketCounts, int scale) {
+
+        final Map<Double, Long> result = new HashMap<>();
+        double base = Math.pow(2.0, Math.pow(2.0, -scale));

Review Comment:
   Please check all power calculations whether they are overflowed and reject 
the data if so. 



##########
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java:
##########
@@ -161,6 +163,24 @@ private static Map<Double, Long> buildBuckets(
         return result;
     }
 
+    private static Map<Double, Long> buildBucketsFromExponentialHistogram(
+        int positiveOffset, final List<Long> positiveBucketCounts,
+        int negativeOffset, final List<Long> negativeBucketCounts, int scale) {
+
+        final Map<Double, Long> result = new HashMap<>();
+        double base = Math.pow(2.0, Math.pow(2.0, -scale));
+        double upperBound;
+        for (int i = 0; i < negativeBucketCounts.size(); i++) {
+            upperBound = -Math.pow(base, negativeOffset + i);
+            result.put(upperBound, negativeBucketCounts.get(i));
+        }
+        for (int i = 0; i < positiveBucketCounts.size(); i++) {
+            upperBound = Math.pow(base, positiveOffset + i + 1);
+            result.put(upperBound, positiveBucketCounts.get(i));
+        }

Review Comment:
   Looks like there missed a upper bound for +Infitite
   
   ```suggestion
           for (int i = 0; i < positiveBucketCounts.size() - 1; i++) {
               upperBound = Math.pow(base, positiveOffset + i + 1);
               result.put(upperBound, positiveBucketCounts.get(i));
           }
           result.put(Double.POSITIVE_INFINITY, 
positiveBucketCounts.get(positiveBucketCounts.size() - 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: [email protected]

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

Reply via email to