You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "mufiye (via GitHub)" <gi...@apache.org> on 2023/02/26 05:25:45 UTC

[GitHub] [skywalking] mufiye commented on a diff in pull request #10449: Adapt otel exponential histogram data

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


##########
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:
   Ok, I will add it.



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org