From 2363c2d77056cc174f248a6b5d712418488db8e8 Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 14:32:44 +0800 Subject: [PATCH 1/9] Convert the redisson lock into a async span --- .../v3/RedissonHighLevelLockInterceptor.java | 14 ++++++++++++++ .../redisson/v3/RedissonLockInterceptor.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java index ef0a0585f5..0cf06dbff6 100644 --- a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java @@ -26,9 +26,11 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.redisson.api.RFuture; import org.redisson.api.RLock; import java.lang.reflect.Method; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; public class RedissonHighLevelLockInterceptor implements InstanceMethodsAroundInterceptor { @@ -48,7 +50,19 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { + AbstractSpan span = ContextManager.activeSpan(); + span.prepareForAsync(); ContextManager.stopSpan(); + + RFuture future = (RFuture) ret; + CompletableFuture completableFuture = future.toCompletableFuture(); + completableFuture.whenCompleteAsync((res, ex) -> { + if (ex != null) { + span.errorOccurred(); + span.log(ex); + } + span.asyncFinish(); + }); return ret; } diff --git a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java index 77a31a28a4..a673502e93 100644 --- a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java @@ -26,9 +26,11 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.redisson.api.RFuture; import org.redisson.api.RLock; import java.lang.reflect.Method; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; public class RedissonLockInterceptor implements InstanceMethodsAroundInterceptor { @@ -48,7 +50,19 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { + AbstractSpan span = ContextManager.activeSpan(); + span.prepareForAsync(); ContextManager.stopSpan(); + + RFuture future = (RFuture) ret; + CompletableFuture completableFuture = future.toCompletableFuture(); + completableFuture.whenCompleteAsync((res, ex) -> { + if (ex != null) { + span.errorOccurred(); + span.log(ex); + } + span.asyncFinish(); + }); return ret; } From 465278c8d39bb419c71d0519ae861ffca859eac7 Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 15:39:06 +0800 Subject: [PATCH 2/9] add changes log --- CHANGES.md | 1 + test/plugin/scenarios/redisson-scenario/support-version.list | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5225574210..990bcbb9a4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Release Notes. * Fix re-transform bug when plugin enhanced class proxy parent method. * Fix error HTTP status codes not recording as SLA failures in Vert.x plugins. * Support for HttpExchange request tracing +* Convert the Redisson lock span into an async span #### Documentation diff --git a/test/plugin/scenarios/redisson-scenario/support-version.list b/test/plugin/scenarios/redisson-scenario/support-version.list index 78009656c1..c095f6714c 100644 --- a/test/plugin/scenarios/redisson-scenario/support-version.list +++ b/test/plugin/scenarios/redisson-scenario/support-version.list @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.20.1 +3.16.3 3.11.5 3.10.7 3.9.1 From 5eca2ca20db1426d6d0b9b892e6c683f5800e8ce Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 16:30:06 +0800 Subject: [PATCH 3/9] fix redisson plugin test error --- .../scenarios/redisson-scenario/config/expectedData.yaml | 4 ++-- test/plugin/scenarios/redisson-scenario/support-version.list | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml index e925f320b2..b38d480279 100644 --- a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml @@ -66,7 +66,7 @@ segmentItems: - { key: cache.instance, value: not null } - { key: cache.cmd, value: EVAL } - { key: cache.key, value: not null } - skipAnalysis: 'false' + skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 @@ -98,7 +98,7 @@ segmentItems: - { key: cache.instance, value: not null } - { key: cache.cmd, value: EVAL } - { key: cache.key, value: not null } - skipAnalysis: 'false' + skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 diff --git a/test/plugin/scenarios/redisson-scenario/support-version.list b/test/plugin/scenarios/redisson-scenario/support-version.list index c095f6714c..d0c47874b0 100644 --- a/test/plugin/scenarios/redisson-scenario/support-version.list +++ b/test/plugin/scenarios/redisson-scenario/support-version.list @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.24.1 3.20.1 3.16.3 3.11.5 From 92fdf83a66c332d92761a4beae37b826e155701b Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 16:51:20 +0800 Subject: [PATCH 4/9] remove the redisson/eval test expected data --- .../config/expectedData.yaml | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml index b38d480279..4466cd212a 100644 --- a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml @@ -51,22 +51,6 @@ segmentItems: - {key: cache.instance, value: not null} - {key: cache.cmd, value: BATCH_EXECUTE} skipAnalysis: 'false' - - operationName: Redisson/EVAL - parentSpanId: 3 - spanId: nq 0 - spanLayer: Cache - startTime: not null - endTime: not null - componentId: 56 - isError: false - spanType: Exit - peer: not null - tags: - - { key: cache.type, value: Redis } - - { key: cache.instance, value: not null } - - { key: cache.cmd, value: EVAL } - - { key: cache.key, value: not null } - skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 @@ -83,22 +67,6 @@ segmentItems: - { key: lease.time, value: not null } - { key: thread.id, value: not null } skipAnalysis: false - - operationName: Redisson/EVAL - parentSpanId: 5 - spanId: nq 0 - spanLayer: Cache - startTime: not null - endTime: not null - componentId: 56 - isError: false - spanType: Exit - peer: not null - tags: - - { key: cache.type, value: Redis } - - { key: cache.instance, value: not null } - - { key: cache.cmd, value: EVAL } - - { key: cache.key, value: not null } - skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 From 2b1a324bc2c7f96db5fd261de77806318151264b Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 17:34:50 +0800 Subject: [PATCH 5/9] Revert "remove the redisson/eval test expected data" This reverts commit 92fdf83a66c332d92761a4beae37b826e155701b. --- .../config/expectedData.yaml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml index 4466cd212a..b38d480279 100644 --- a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml @@ -51,6 +51,22 @@ segmentItems: - {key: cache.instance, value: not null} - {key: cache.cmd, value: BATCH_EXECUTE} skipAnalysis: 'false' + - operationName: Redisson/EVAL + parentSpanId: 3 + spanId: nq 0 + spanLayer: Cache + startTime: not null + endTime: not null + componentId: 56 + isError: false + spanType: Exit + peer: not null + tags: + - { key: cache.type, value: Redis } + - { key: cache.instance, value: not null } + - { key: cache.cmd, value: EVAL } + - { key: cache.key, value: not null } + skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 @@ -67,6 +83,22 @@ segmentItems: - { key: lease.time, value: not null } - { key: thread.id, value: not null } skipAnalysis: false + - operationName: Redisson/EVAL + parentSpanId: 5 + spanId: nq 0 + spanLayer: Cache + startTime: not null + endTime: not null + componentId: 56 + isError: false + spanType: Exit + peer: not null + tags: + - { key: cache.type, value: Redis } + - { key: cache.instance, value: not null } + - { key: cache.cmd, value: EVAL } + - { key: cache.key, value: not null } + skipAnalysis: 'true' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 From 907e70b29dc893205fa04dbe47fbc34540aa613e Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 17:34:55 +0800 Subject: [PATCH 6/9] Revert "fix redisson plugin test error" This reverts commit 5eca2ca20db1426d6d0b9b892e6c683f5800e8ce. --- .../scenarios/redisson-scenario/config/expectedData.yaml | 4 ++-- test/plugin/scenarios/redisson-scenario/support-version.list | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml index b38d480279..e925f320b2 100644 --- a/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/redisson-scenario/config/expectedData.yaml @@ -66,7 +66,7 @@ segmentItems: - { key: cache.instance, value: not null } - { key: cache.cmd, value: EVAL } - { key: cache.key, value: not null } - skipAnalysis: 'true' + skipAnalysis: 'false' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 @@ -98,7 +98,7 @@ segmentItems: - { key: cache.instance, value: not null } - { key: cache.cmd, value: EVAL } - { key: cache.key, value: not null } - skipAnalysis: 'true' + skipAnalysis: 'false' - operationName: Redisson/LOCK parentSpanId: 0 spanId: nq 0 diff --git a/test/plugin/scenarios/redisson-scenario/support-version.list b/test/plugin/scenarios/redisson-scenario/support-version.list index d0c47874b0..c095f6714c 100644 --- a/test/plugin/scenarios/redisson-scenario/support-version.list +++ b/test/plugin/scenarios/redisson-scenario/support-version.list @@ -14,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -3.24.1 3.20.1 3.16.3 3.11.5 From c994ba7ede36f0e92d59f4b53b7e6dc98a1886cd Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 17:34:58 +0800 Subject: [PATCH 7/9] Revert "add changes log" This reverts commit 465278c8d39bb419c71d0519ae861ffca859eac7. --- CHANGES.md | 1 - test/plugin/scenarios/redisson-scenario/support-version.list | 2 -- 2 files changed, 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 990bcbb9a4..5225574210 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,6 @@ Release Notes. * Fix re-transform bug when plugin enhanced class proxy parent method. * Fix error HTTP status codes not recording as SLA failures in Vert.x plugins. * Support for HttpExchange request tracing -* Convert the Redisson lock span into an async span #### Documentation diff --git a/test/plugin/scenarios/redisson-scenario/support-version.list b/test/plugin/scenarios/redisson-scenario/support-version.list index c095f6714c..78009656c1 100644 --- a/test/plugin/scenarios/redisson-scenario/support-version.list +++ b/test/plugin/scenarios/redisson-scenario/support-version.list @@ -14,8 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -3.20.1 -3.16.3 3.11.5 3.10.7 3.9.1 From 2bc26760c428bf0d5ed991ba168e98f1b1010312 Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 17:35:32 +0800 Subject: [PATCH 8/9] add changes log --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 5225574210..990bcbb9a4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Release Notes. * Fix re-transform bug when plugin enhanced class proxy parent method. * Fix error HTTP status codes not recording as SLA failures in Vert.x plugins. * Support for HttpExchange request tracing +* Convert the Redisson lock span into an async span #### Documentation From a03bbdc56bf3fb81fcfeb4a65c32d0de0751f9fa Mon Sep 17 00:00:00 2001 From: peachisai <497533062@qq.com> Date: Sat, 20 Jan 2024 23:54:29 +0800 Subject: [PATCH 9/9] change the completableFuture whenCompleteAsync into whenComplete --- .../plugin/redisson/v3/RedissonHighLevelLockInterceptor.java | 2 +- .../apm/plugin/redisson/v3/RedissonLockInterceptor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java index 0cf06dbff6..99229d62fb 100644 --- a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonHighLevelLockInterceptor.java @@ -56,7 +56,7 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA RFuture future = (RFuture) ret; CompletableFuture completableFuture = future.toCompletableFuture(); - completableFuture.whenCompleteAsync((res, ex) -> { + completableFuture.whenComplete((res, ex) -> { if (ex != null) { span.errorOccurred(); span.log(ex); diff --git a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java index a673502e93..b8159d9a00 100644 --- a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/RedissonLockInterceptor.java @@ -56,7 +56,7 @@ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allA RFuture future = (RFuture) ret; CompletableFuture completableFuture = future.toCompletableFuture(); - completableFuture.whenCompleteAsync((res, ex) -> { + completableFuture.whenComplete((res, ex) -> { if (ex != null) { span.errorOccurred(); span.log(ex);