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

wankai 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 3acad529f5 fix BanyanDB debugging trace (#12418)
3acad529f5 is described below

commit 3acad529f5cdbb44060bc0ef3d49fe7bc080cbe8
Author: Wan Kai <wankai...@foxmail.com>
AuthorDate: Mon Jul 8 12:27:28 2024 +0800

    fix BanyanDB debugging trace (#12418)
---
 .../query/type/debugging/DebuggingTraceContext.java | 21 +++++++++++++++++++--
 .../plugin/banyandb/stream/AbstractBanyanDBDAO.java |  2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/debugging/DebuggingTraceContext.java
 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/debugging/DebuggingTraceContext.java
index 704fc5dfc2..0c2d5b9726 100644
--- 
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/debugging/DebuggingTraceContext.java
+++ 
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/debugging/DebuggingTraceContext.java
@@ -36,14 +36,17 @@ public class DebuggingTraceContext {
         this.dumpStorageRsp = dumpStorageRsp;
     }
 
+    /**
+     * Create a new span for OAP internal debugging trace and start.
+     * @param operation operation
+     * @return DebuggingSpan
+     */
     public DebuggingSpan createSpan(String operation) {
         DebuggingSpan span = new DebuggingSpan(spanIdGenerator++, operation);
         if (debug) {
-            //default start time, could be overwritten by setStartTime 
(BanyanDB Trace)
             span.setStartTime(System.nanoTime());
             DebuggingSpan parentSpan = spanStack.isEmpty() ? null : 
spanStack.peek();
             if (parentSpan != null) {
-                //default parent span id, could be overwritten by 
setParentSpanId (BanyanDB Trace)
                 span.setParentSpanId(parentSpan.getSpanId());
             } else {
                 span.setParentSpanId(-1);
@@ -54,6 +57,20 @@ public class DebuggingTraceContext {
         return span;
     }
 
+    /**
+     * Use for transform the other Span to DebuggingSpan, such as BanyanDB 
trace span.
+     * The start time , end time, duration, parent span id should be set 
manually.
+     * @param operation operation
+     * @return DebuggingSpan
+     */
+    public DebuggingSpan createSpanForTransform(String operation) {
+        DebuggingSpan span = new DebuggingSpan(spanIdGenerator++, operation);
+        if (debug) {
+            execTrace.addSpan(span);
+        }
+        return span;
+    }
+
     public DebuggingSpan getParentSpan() {
         if (spanStack.isEmpty()) {
             return null;
diff --git 
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/AbstractBanyanDBDAO.java
 
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/AbstractBanyanDBDAO.java
index aa510226ca..4c49edf944 100644
--- 
a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/AbstractBanyanDBDAO.java
+++ 
b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/AbstractBanyanDBDAO.java
@@ -242,7 +242,7 @@ public abstract class AbstractBanyanDBDAO extends 
AbstractDAO<BanyanDBStorageCli
     }
 
     private void addDBSpan2DebuggingTrace(Span span, DebuggingTraceContext 
traceContext, DebuggingSpan parentSpan) {
-        DebuggingSpan debuggingSpan = traceContext.createSpan("BanyanDB: " + 
span.getMessage());
+        DebuggingSpan debuggingSpan = 
traceContext.createSpanForTransform("BanyanDB: " + span.getMessage());
         debuggingSpan.setStartTime(span.getStartTime().getSeconds() * 
1000_000_000 + span.getStartTime().getNanos());
         debuggingSpan.setEndTime(span.getEndTime().getSeconds() * 1000_000_000 
+ span.getEndTime().getNanos());
         debuggingSpan.setDuration(span.getDuration());

Reply via email to