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 2021/09/24 04:01:14 UTC

[skywalking] branch metric-accurate created (now 731ae46)

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

wusheng pushed a change to branch metric-accurate
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at 731ae46  Fix `Hour` and `Day` dimensionality metrics not accurate

This branch includes the following new commits:

     new 731ae46  Fix `Hour` and `Day` dimensionality metrics not accurate

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking] 01/01: Fix `Hour` and `Day` dimensionality metrics not accurate

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 731ae46ca0c030cc58f4e56eab23057e5b4f34a5
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Fri Sep 24 12:01:00 2021 +0800

    Fix `Hour` and `Day` dimensionality metrics not accurate
---
 CHANGES.md                                                     |  7 +++++--
 .../server/core/analysis/worker/MetricsPersistentWorker.java   |  5 +++--
 .../oap/server/core/analysis/worker/PersistenceWorker.java     | 10 +---------
 .../skywalking/oap/server/core/analysis/worker/TopNWorker.java |  7 ++-----
 4 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 750edca..5043458 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -8,7 +8,7 @@ Release Notes.
 #### Project
 
 * Split javaagent into skywalking-java repository. https://github.com/apache/skywalking-java
-* Merge `Dockerfile`s from apache/skywalking-docker into this codebase. 
+* Merge `Dockerfile`s from apache/skywalking-docker into this codebase.
 
 #### OAP Server
 
@@ -31,7 +31,8 @@ Release Notes.
 * [Break Change] Remove endpoint name in the backend log query condition. Only support `query by endpoint id`.
 * [Break Change] Fix typo for a column `page_path_id`(was `pate_path_id`) of storage entity `browser_error_log`.
 * Add component id for Python falcon plugin.
-* Add `rpcStatusCode` for `rpc.status_code` tag. The `responseCode` field is marked as deprecated and replaced by `httpResponseStatusCode` field. 
+* Add `rpcStatusCode` for `rpc.status_code` tag. The `responseCode` field is marked as deprecated and replaced
+  by `httpResponseStatusCode` field.
 * Remove the duplicated tags to reduce the storage payload.
 * Add a new API to test log analysis language.
 * Harden the security of Groovy-based DSL, MAL and LAL.
@@ -70,6 +71,8 @@ Release Notes.
 * Fix wrong service name when IP is node IP in `k8s-mesh`.
 * Support dynamic configurations for openAPI endpoint name grouping rule.
 * Add component definition for `Alibaba Druid` and `HikariCP`.
+* Fix `Hour` and `Day` dimensionality metrics not accurate, due to the cache read-then-clear mechanism conflicts with low
+  down metrics flush period added in 8.7.0.
 
 #### UI
 
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
index dbbc451..259cd87 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/MetricsPersistentWorker.java
@@ -19,7 +19,6 @@
 package org.apache.skywalking.oap.server.core.analysis.worker;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -160,11 +159,13 @@ public class MetricsPersistentWorker extends PersistenceWorker<Metrics> {
     }
 
     @Override
-    public List<PrepareRequest> prepareBatch(Collection<Metrics> lastCollection) {
+    public List<PrepareRequest> buildBatchRequests() {
         if (persistentCounter++ % persistentMod != 0) {
             return Collections.EMPTY_LIST;
         }
 
+        final List<Metrics> lastCollection = getCache().read();
+
         long start = System.currentTimeMillis();
         if (lastCollection.size() == 0) {
             return Collections.EMPTY_LIST;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/PersistenceWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/PersistenceWorker.java
index 2ce8725..ad14009 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/PersistenceWorker.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/PersistenceWorker.java
@@ -18,7 +18,6 @@
 
 package org.apache.skywalking.oap.server.core.analysis.worker;
 
-import java.util.Collection;
 import java.util.List;
 import lombok.AccessLevel;
 import lombok.Getter;
@@ -61,13 +60,6 @@ public abstract class PersistenceWorker<INPUT extends StorageData> extends Abstr
     /**
      * Prepare the batch persistence, transfer all prepared data to the executable data format based on the storage
      * implementations.
-     *
-     * @param lastCollection  the source of transformation, they are in memory object format.
      */
-    public abstract List<PrepareRequest> prepareBatch(Collection<INPUT> lastCollection);
-
-    public List<PrepareRequest> buildBatchRequests() {
-        final List<INPUT> dataList = getCache().read();
-        return prepareBatch(dataList);
-    }
+    public abstract List<PrepareRequest> buildBatchRequests();
 }
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/TopNWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/TopNWorker.java
index e224e62..4b9c407 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/TopNWorker.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/worker/TopNWorker.java
@@ -19,7 +19,6 @@
 package org.apache.skywalking.oap.server.core.analysis.worker;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -71,11 +70,9 @@ public class TopNWorker extends PersistenceWorker<TopN> {
             return Collections.EMPTY_LIST;
         }
         lastReportTimestamp = now;
-        return super.buildBatchRequests();
-    }
 
-    @Override
-    public List<PrepareRequest> prepareBatch(Collection<TopN> lastCollection) {
+        final List<TopN> lastCollection = getCache().read();
+
         List<PrepareRequest> prepareRequests = new ArrayList<>(lastCollection.size());
         lastCollection.forEach(record -> {
             try {