kezhenxu94 commented on code in PR #10449:
URL: https://github.com/apache/skywalking/pull/10449#discussion_r1118292694
##########
oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java:
##########
@@ -161,6 +163,54 @@ private static Map<Double, Long> buildBuckets(
return result;
}
+ /**
+ * ExponentialHistogram data points are an alternate representation to the
Histogram data point in OpenTelemetry
+ * metric
format(https://opentelemetry.io/docs/reference/specification/metrics/data-model/#exponentialhistogram).
+ * It uses scale, offset and bucket index to calculate the bound. Firstly,
calculate the base using scale by
+ * formula: base = 2**(2**(-scale)). Then the upperBound of specific
bucket can be calculated by formula:
+ * base**(offset+index+1). Above calculation way is about positive
buckets. For the negative case, we just
+ * map them by their absolute value into the negative range using the same
scale as the positive range. So the
+ * upperBound should be calculated as -base**(offset+index).
+ *
+ * @param positiveOffset corresponding to positive Buckets' offset
in ExponentialHistogramDataPoint
+ * @param positiveBucketCounts corresponding to positive Buckets'
bucket_counts in ExponentialHistogramDataPoint
+ * @param negativeOffset corresponding to negative Buckets' offset
in ExponentialHistogramDataPoint
+ * @param negativeBucketCounts corresponding to negative Buckets'
bucket_counts in ExponentialHistogramDataPoint
+ * @param scale corresponding to scale in
ExponentialHistogramDataPoint
+ * @return The map is a bucket set for histogram, the key is specific
bucket's upperBound, the value is item count
+ * in this bucket lower than or equals to key(upperBound)
+ */
+ 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<>();
Review Comment:
> I think I miss this part, I would like to assign its upper bound as the
lower bound of small positive, WDYT?
> From my understanding, zero means less than a threshold, no matter this is
less than which boundaries.
There is clear definition of zeros in OTEL data model, we can tackle the
zeros according to the definition, in short, the `zero_count` is the count of
bucket `(-threshold, +threshold)`, or count of samples that are approximately
`0` if `threshold` is not set.
> The ExponentialHistogram contains a special zero_count bucket and an
optional zero_threshold field where zero_count contains the count of values
whose absolute value is less than or equal to zero_threshold. The precise value
for the zero_threshold is arbitrary and not related to the scale.
> When zero_threshold is unset or 0, this bucket stores values that cannot
be expressed using the standard exponential formula as well as values that have
been rounded to zero.
--
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]