You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2023/02/19 23:18:43 UTC

[skywalking] branch master updated: Support process Sum metrics with AGGREGATION_TEMPORALITY_DELTA case (#10410)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 155d231111 Support process Sum metrics with AGGREGATION_TEMPORALITY_DELTA case (#10410)
155d231111 is described below

commit 155d2311114125a3f36e11526ab763f316585bb3
Author: 叶梦飞 <70...@users.noreply.github.com>
AuthorDate: Mon Feb 20 07:18:36 2023 +0800

    Support process Sum metrics with AGGREGATION_TEMPORALITY_DELTA case (#10410)
---
 docs/en/changes/changes.md                            |  1 +
 .../otlp/OpenTelemetryMetricRequestProcessor.java     | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index b7b15361ba..13ffdbab48 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -98,6 +98,7 @@
 * Migrate tests from junit 4 to junit 5.
 * Refactor http-based alarm plugins and extract common logic to `HttpAlarmCallback`.
 * Support Amazon Simple Storage Service (Amazon S3) metrics monitoring
+* Support process Sum metrics with AGGREGATION_TEMPORALITY_DELTA case
 
 #### UI
 
diff --git a/oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java b/oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java
index b1a3c9a183..e5302472b9 100644
--- a/oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java
+++ b/oap-server/server-receiver-plugin/otel-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/otel/otlp/OpenTelemetryMetricRequestProcessor.java
@@ -48,7 +48,8 @@ import org.apache.skywalking.oap.server.library.util.prometheus.metrics.Metric;
 import org.apache.skywalking.oap.server.library.util.prometheus.metrics.Summary;
 import org.apache.skywalking.oap.server.receiver.otel.OtelMetricReceiverConfig;
 
-import static io.opentelemetry.proto.metrics.v1.AggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE;
+import static io.opentelemetry.proto.metrics.v1.AggregationTemporality.AGGREGATION_TEMPORALITY_DELTA;
+import static io.opentelemetry.proto.metrics.v1.AggregationTemporality.AGGREGATION_TEMPORALITY_UNSPECIFIED;
 import static java.util.stream.Collectors.toList;
 import static java.util.stream.Collectors.toMap;
 
@@ -180,9 +181,23 @@ public class OpenTelemetryMetricRequestProcessor implements Service {
         if (metric.hasSum()) {
             final Sum sum = metric.getSum();
             if (sum
-                .getAggregationTemporality() != AGGREGATION_TEMPORALITY_CUMULATIVE) {
+                .getAggregationTemporality() == AGGREGATION_TEMPORALITY_UNSPECIFIED) {
                 return Stream.empty();
             }
+            if (sum
+                .getAggregationTemporality() == AGGREGATION_TEMPORALITY_DELTA) {
+                return sum.getDataPointsList().stream()
+                        .map(point -> new Gauge(
+                                metric.getName(),
+                                mergeLabels(
+                                    nodeLabels,
+                                    buildLabels(point.getAttributesList())
+                                ),
+                                point.hasAsDouble() ? point.getAsDouble()
+                                    : point.getAsInt(),
+                                point.getTimeUnixNano() / 1000000
+                        ));
+            }
             if (sum.getIsMonotonic()) {
                 return sum.getDataPointsList().stream()
                           .map(point -> new Counter(