From ec84c2ddfd2d11adefd110816b241dfc1862d161 Mon Sep 17 00:00:00 2001 From: yongwuhe Date: Tue, 10 Sep 2024 15:33:48 +0800 Subject: [PATCH] feat: add repeat record log --- .../runtime/context/RepeatedCollectManager.java | 8 +++++++- .../io/arex/inst/runtime/util/IgnoreUtils.java | 2 +- .../context/RepeatedCollectManagerTest.java | 14 +++++++++++--- .../AbstractEntityPersisterInstrumentation.java | 6 +++--- .../database/hibernate/LoaderInstrumentation.java | 2 +- ...bstractEntityPersisterInstrumentationTest.java | 15 ++++++++------- .../hibernate/LoaderInstrumentationTest.java | 4 ++-- .../database/mongo/AggregateInstrumentation.java | 3 ++- .../mongo/ListIndexesInstrumentation.java | 2 +- .../mongo/ReadOperationInstrumentation.java | 2 +- .../mongo/WriteOperationInstrumentation.java | 4 ++-- .../mybatis3/ExecutorInstrumentation.java | 4 ++-- .../mybatis3/ExecutorInstrumentationTest.java | 11 +++++++---- .../alibaba/DubboConsumerInstrumentation.java | 2 +- .../alibaba/DubboConsumerInstrumentationTest.java | 5 +++-- .../apache/v2/DubboConsumerInstrumentation.java | 2 +- .../v2/DubboConsumerInstrumentationTest.java | 5 +++-- .../apache/v3/DubboConsumerInstrumentation.java | 2 +- .../DubboStreamConsumerInstrumentation.java | 2 +- .../v3/DubboConsumerInstrumentationTest.java | 4 ++-- .../DubboStreamConsumerInstrumentationTest.java | 4 ++-- .../inst/cache/arex/ArexMockInstrumentation.java | 2 +- .../caffeine/CaffeineAsyncInstrumentation.java | 2 +- .../caffeine/CaffeineSyncInstrumentation.java | 2 +- .../cache/guava/GuavaCacheInstrumentation.java | 2 +- .../cache/spring/SpringCacheInstrumentation.java | 2 +- .../cache/arex/ArexMockInstrumentationTest.java | 4 ++-- .../guava/GuavaCacheInstrumentationTest.java | 2 +- .../spring/SpringCacheInstrumentationTest.java | 2 +- .../inst/dynamic/DynamicClassInstrumentation.java | 2 +- .../dynamic/DynamicClassInstrumentationTest.java | 2 +- .../sync/InternalHttpClientInstrumentation.java | 2 +- .../InternalHttpClientInstrumentationTest.java | 2 +- .../feign/FeignClientInstrumentation.java | 2 +- .../feign/FeignClientInstrumentationTest.java | 2 +- .../ning/AsyncHttpClientInstrumentation.java | 2 +- .../ning/AsyncHttpClientInstrumentationTest.java | 2 +- .../okhttp/v3/OkHttpCallInstrumentation.java | 2 +- .../resttemplate/RestTemplateInstrumentation.java | 2 +- .../RestTemplateInstrumentationTest.java | 4 ++-- .../webclient/v5/WebClientInstrumentation.java | 4 ++-- .../v5/WebClientInstrumentationTest.java | 4 ++-- .../java/io/arex/inst/jedis/v2/JedisWrapper.java | 4 ++-- .../java/io/arex/inst/jedis/v4/JedisWrapper.java | 4 ++-- .../lettuce/wrapper/RedisCommandWrapper.java | 2 +- .../inst/redisson/v3/RedissonWrapperCommon.java | 2 +- .../spring/data/redis/RedisTemplateProvider.java | 2 +- .../data/redis/RedisTemplateProviderTest.java | 6 +++--- 48 files changed, 97 insertions(+), 76 deletions(-) diff --git a/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/context/RepeatedCollectManager.java b/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/context/RepeatedCollectManager.java index 1fdee665b..e3e0254a5 100644 --- a/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/context/RepeatedCollectManager.java +++ b/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/context/RepeatedCollectManager.java @@ -2,6 +2,8 @@ import io.arex.agent.bootstrap.ctx.ArexThreadLocal; import io.arex.agent.bootstrap.internal.CallDepth; +import io.arex.inst.runtime.config.Config; +import io.arex.inst.runtime.log.LogManager; /** * Avoid collecting data multiple times on the call chain @@ -22,7 +24,7 @@ public static boolean validate() { return Context.get() == null; } - public static boolean exitAndValidate() { + public static boolean exitAndValidate(String repeatMessage) { CallDepth callDepth = Context.get(); if (callDepth == null) { return true; @@ -32,6 +34,10 @@ public static boolean exitAndValidate() { Context.remove(); return true; } + + if (Config.get().isEnableDebug()) { + LogManager.info("repeat", repeatMessage); + } return false; } diff --git a/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/util/IgnoreUtils.java b/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/util/IgnoreUtils.java index 19c518856..b5a2507a5 100644 --- a/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/util/IgnoreUtils.java +++ b/arex-instrumentation-api/src/main/java/io/arex/inst/runtime/util/IgnoreUtils.java @@ -66,7 +66,7 @@ public static boolean excludeOperation(String targetName) { Set excludeServiceOperations = Config.get().excludeServiceOperations(); boolean isOperationMatched = operationMatched(targetName, excludeServiceOperations); if (isOperationMatched && ContextManager.needReplay()) { - LogManager.warn("replay.hitBlockList", StringUtil.format("Hit block list, target name: %s", targetName)); + LogManager.info("replay.hitBlockList", StringUtil.format("Hit block list, target name: %s", targetName)); } return isOperationMatched; } diff --git a/arex-instrumentation-api/src/test/java/io/arex/inst/runtime/context/RepeatedCollectManagerTest.java b/arex-instrumentation-api/src/test/java/io/arex/inst/runtime/context/RepeatedCollectManagerTest.java index 66533c83f..72572e73d 100644 --- a/arex-instrumentation-api/src/test/java/io/arex/inst/runtime/context/RepeatedCollectManagerTest.java +++ b/arex-instrumentation-api/src/test/java/io/arex/inst/runtime/context/RepeatedCollectManagerTest.java @@ -2,18 +2,23 @@ import static org.junit.jupiter.api.Assertions.*; +import io.arex.inst.runtime.config.ConfigBuilder; +import io.arex.inst.runtime.log.LogManager; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; import org.mockito.Mockito; /** * @since 2024/1/12 */ class RepeatedCollectManagerTest { + private static MockedStatic logManagerMockedStatic; @BeforeAll static void setUp() { Mockito.mockStatic(ContextManager.class); + logManagerMockedStatic = Mockito.mockStatic(LogManager.class); } @AfterAll static void tearDown() { @@ -23,12 +28,15 @@ static void tearDown() { @Test void test() { assertTrue(RepeatedCollectManager.validate()); - assertTrue(RepeatedCollectManager.exitAndValidate()); + assertTrue(RepeatedCollectManager.exitAndValidate("test")); Mockito.when(ContextManager.needRecord()).thenReturn(true); RepeatedCollectManager.enter(); RepeatedCollectManager.enter(); - assertFalse(RepeatedCollectManager.exitAndValidate()); - assertTrue(RepeatedCollectManager.exitAndValidate()); + // enable debug + ConfigBuilder.create("test").enableDebug(true).build(); + assertFalse(RepeatedCollectManager.exitAndValidate("test")); + logManagerMockedStatic.verify(() -> LogManager.info("repeat", "test")); + assertTrue(RepeatedCollectManager.exitAndValidate("test")); } } diff --git a/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentation.java b/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentation.java index 57fe7cd13..825daea57 100644 --- a/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentation.java +++ b/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentation.java @@ -89,7 +89,7 @@ public static void onExit( @Advice.Thrown(readOnly = false) Throwable throwable, @Advice.Local("mockResult") MockResult mockResult, @Advice.Local("extractor") DatabaseExtractor extractor) { - if (!RepeatedCollectManager.exitAndValidate()) { + if (!RepeatedCollectManager.exitAndValidate("db insert repeat record")) { return; } @@ -139,7 +139,7 @@ public static void onExit( @Advice.Argument(8) String sql, @Advice.Thrown(readOnly = false) Throwable throwable, @Advice.Local("mockResult") MockResult mockResult) { - if (!RepeatedCollectManager.exitAndValidate()) { + if (!RepeatedCollectManager.exitAndValidate("db update repeat record")) { return; } @@ -184,7 +184,7 @@ public static void onExit( @Advice.Argument(4) String sql, @Advice.Thrown(readOnly = false) Throwable throwable, @Advice.Local("mockResult") MockResult mockResult) { - if (!RepeatedCollectManager.exitAndValidate()) { + if (!RepeatedCollectManager.exitAndValidate("db delete repeat record")) { return; } diff --git a/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/LoaderInstrumentation.java b/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/LoaderInstrumentation.java index 7018ffa51..ae2c3a403 100644 --- a/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/LoaderInstrumentation.java +++ b/arex-instrumentation/database/arex-database-hibernate/src/main/java/io/arex/inst/database/hibernate/LoaderInstrumentation.java @@ -63,7 +63,7 @@ public static void onExit(@Advice.This Loader loader, @Advice.Return(readOnly = false) List list, @Advice.Local("mockResult") MockResult mockResult, @Advice.Local("extractor") DatabaseExtractor extractor) throws HibernateException { - if (!RepeatedCollectManager.exitAndValidate()) { + if (!RepeatedCollectManager.exitAndValidate("db query repeat record")) { return; } diff --git a/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentationTest.java b/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentationTest.java index 6b1fa6eb2..8b8bf04e4 100644 --- a/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentationTest.java +++ b/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/AbstractEntityPersisterInstrumentationTest.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.params.provider.Arguments.arguments; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.isA; @ExtendWith(MockitoExtension.class) @@ -77,10 +78,10 @@ void onInsertExit(Runnable mocker, Throwable throwable, MockResult mockResult, P static Stream onInsertExitCase() { Runnable emptyMocker = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(false); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(false); }; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -126,7 +127,7 @@ static Stream onUpdateOrInsertEnterCase() { @MethodSource("onUpdateOrInsertExitCase") void onUpdateOrInsertExit(Runnable recordType, Object mockResult) { AtomicReference mo = new AtomicReference<>(); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(true); Mockito.when(ContextManager.needRecord()).thenReturn(true); try (MockedConstruction mocked = Mockito.mockConstruction(DatabaseExtractor.class, (mock, context) -> { mo.set(mock); @@ -149,7 +150,7 @@ static Stream onUpdateOrInsertExitCase() { void updateOrInsertExitReplayThrowable() { MockResult mock = Mockito.mock(MockResult.class); Mockito.when(ContextManager.needReplay()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(true); Throwable throwable = new Throwable(); Mockito.doReturn(true).when(mock).notIgnoreMockResult(); Mockito.doReturn(throwable).when(mock).getThrowable(); @@ -184,7 +185,7 @@ static Stream onDeleteEnterCase() { @MethodSource("onDeleteExitCase") void onDeleteExit(Runnable recordType, Object mockResult) { AtomicReference mo = new AtomicReference<>(); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(true); Mockito.when(ContextManager.needRecord()).thenReturn(true); try (MockedConstruction mocked = Mockito.mockConstruction(DatabaseExtractor.class, (mock, context) -> { mo.set(mock); @@ -207,11 +208,11 @@ static Stream onDeleteExitCase() { void deleteExitReplayThrowable() { MockResult mock = Mockito.mock(MockResult.class); Mockito.when(ContextManager.needReplay()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(anyString())).thenReturn(true); Throwable throwable = new Throwable(); Mockito.doReturn(true).when(mock).notIgnoreMockResult(); Mockito.doReturn(throwable).when(mock).getThrowable(); AbstractEntityPersisterInstrumentation.DeleteAdvice.onExit(null, null, throwable, mock); Mockito.verify(mock, Mockito.times(2)).getThrowable(); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/LoaderInstrumentationTest.java b/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/LoaderInstrumentationTest.java index eae3fd1ae..1fa969401 100644 --- a/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/LoaderInstrumentationTest.java +++ b/arex-instrumentation/database/arex-database-hibernate/src/test/java/io/arex/inst/database/hibernate/LoaderInstrumentationTest.java @@ -77,7 +77,7 @@ void onExit(Runnable mocker, HibernateException exception, MockResult mockResult static Stream onExitCase() { Runnable emptyMocker = () -> {}; - Runnable exitAndValidate = () -> Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Runnable exitAndValidate = () -> Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); Runnable needRecord = () -> Mockito.when(ContextManager.needRecord()).thenReturn(true); Predicate predicate1 = Objects::isNull; Predicate predicate2 = Objects::nonNull; @@ -88,4 +88,4 @@ static Stream onExitCase() { arguments(needRecord, null, null, predicate1) ); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/AggregateInstrumentation.java b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/AggregateInstrumentation.java index 93a775522..fd11889c6 100644 --- a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/AggregateInstrumentation.java +++ b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/AggregateInstrumentation.java @@ -67,7 +67,8 @@ public static void onExit(@Enter boolean needReplay, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mongo aggregate repeat record")) { MongoHelper.record("Aggregate", namespace, pipeline, result, throwable); } } diff --git a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ListIndexesInstrumentation.java b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ListIndexesInstrumentation.java index af9f0470d..fca22a73e 100644 --- a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ListIndexesInstrumentation.java +++ b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ListIndexesInstrumentation.java @@ -61,7 +61,7 @@ public static void onExit(@Advice.Enter boolean needReplay, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mongo listIndexes repeat record.")) { MongoHelper.record("ListIndexes", namespace, null, result, throwable); } } diff --git a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ReadOperationInstrumentation.java b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ReadOperationInstrumentation.java index cfdb46bb8..1576dcc5e 100644 --- a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ReadOperationInstrumentation.java +++ b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/ReadOperationInstrumentation.java @@ -72,7 +72,7 @@ public static void onExit(@Advice.Enter boolean needReplay, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mongo read operation repeat record.")) { MongoHelper.record(thiz.getClass().getSimpleName(), namespace, filter, result, throwable); } } diff --git a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/WriteOperationInstrumentation.java b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/WriteOperationInstrumentation.java index dd14e6c9b..1e3af4a45 100644 --- a/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/WriteOperationInstrumentation.java +++ b/arex-instrumentation/database/arex-database-mongo/src/main/java/io/arex/inst/database/mongo/WriteOperationInstrumentation.java @@ -58,7 +58,7 @@ public static boolean onEnter() { @Advice.OnMethodExit(suppress = Throwable.class) public static void onExit() { if (ContextManager.needRecord()) { - RepeatedCollectManager.exitAndValidate(); + RepeatedCollectManager.exitAndValidate("mongo void operation repeat record"); } } } @@ -97,7 +97,7 @@ public static void onExit(@Advice.Origin Method method, return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mongo write operation repeat record")) { MongoHelper.record(methodName, namespace, filter, result, throwable); } } diff --git a/arex-instrumentation/database/arex-database-mybatis3/src/main/java/io/arex/inst/database/mybatis3/ExecutorInstrumentation.java b/arex-instrumentation/database/arex-database-mybatis3/src/main/java/io/arex/inst/database/mybatis3/ExecutorInstrumentation.java index 558a0bac5..197bf14f1 100644 --- a/arex-instrumentation/database/arex-database-mybatis3/src/main/java/io/arex/inst/database/mybatis3/ExecutorInstrumentation.java +++ b/arex-instrumentation/database/arex-database-mybatis3/src/main/java/io/arex/inst/database/mybatis3/ExecutorInstrumentation.java @@ -105,7 +105,7 @@ public static void onExit(@Advice.Argument(0) MappedStatement var1, return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mybatis query repeat record")) { InternalExecutor.record(extractor, var2, result, throwable); } } @@ -162,7 +162,7 @@ public static void onExit(@Advice.Argument(0) MappedStatement var1, return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("mybatis update repeat record")) { InternalExecutor.record(extractor, var1, var2, result, throwable); } } diff --git a/arex-instrumentation/database/arex-database-mybatis3/src/test/java/io/arex/inst/database/mybatis3/ExecutorInstrumentationTest.java b/arex-instrumentation/database/arex-database-mybatis3/src/test/java/io/arex/inst/database/mybatis3/ExecutorInstrumentationTest.java index fd8dd9f3d..5a30bf52f 100644 --- a/arex-instrumentation/database/arex-database-mybatis3/src/test/java/io/arex/inst/database/mybatis3/ExecutorInstrumentationTest.java +++ b/arex-instrumentation/database/arex-database-mybatis3/src/test/java/io/arex/inst/database/mybatis3/ExecutorInstrumentationTest.java @@ -7,6 +7,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; + +import net.bytebuddy.matcher.ElementMatchers; import org.apache.ibatis.builder.StaticSqlSource; import org.apache.ibatis.executor.BatchExecutor; import org.apache.ibatis.executor.BatchResult; @@ -21,6 +23,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @@ -81,10 +84,10 @@ void onExit(Runnable mocker, MockResult mockResult, Predicate predic static Stream onExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(false); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(false); }; Runnable needRecord = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(true); Mockito.when(ContextManager.needRecord()).thenReturn(true); }; Predicate predicate1 = Objects::isNull; @@ -107,10 +110,10 @@ void onUpdateExit(Runnable mocker, DatabaseExtractor extractor, MockResult mockR static Stream onUpdateExitCase() { Runnable needReplay = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(false); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(false); }; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); diff --git a/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/main/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentation.java b/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/main/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentation.java index fec79a8e9..ee4ff36ef 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/main/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentation.java +++ b/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/main/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentation.java @@ -57,7 +57,7 @@ public static boolean onEnter(@Advice.This Invoker invoker, public static void onExit(@Advice.Return(readOnly = false) Result result, @Advice.Local("extractor") DubboConsumerExtractor extractor, @Advice.Local("mockResult") MockResult mockResult) { - if (extractor == null || !RepeatedCollectManager.exitAndValidate()) { + if (extractor == null || !RepeatedCollectManager.exitAndValidate("dubbo consumer repeat record")) { return; } diff --git a/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/test/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentationTest.java b/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/test/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentationTest.java index ba0c11cfa..5124d3106 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/test/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentationTest.java +++ b/arex-instrumentation/dubbo/arex-dubbo-alibaba/src/test/java/io/arex/inst/dubbo/alibaba/DubboConsumerInstrumentationTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentMatchers; import org.mockito.MockedConstruction; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @@ -74,7 +75,7 @@ void onExit(Runnable mocker, MockResult mockResult, Predicate predic static Stream onExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -87,4 +88,4 @@ static Stream onExitCase() { arguments(needRecord, null, predicate1) ); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/main/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentation.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/main/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentation.java index 04bae9e46..3eff31ed8 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/main/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentation.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/main/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentation.java @@ -59,7 +59,7 @@ public static boolean onEnter(@Advice.This Invoker invoker, public static void onExit(@Advice.Return(readOnly = false) Result result, @Advice.Local("extractor") DubboConsumerExtractor extractor, @Advice.Local("mockResult") MockResult mockResult) { - if (extractor == null || !RepeatedCollectManager.exitAndValidate()) { + if (extractor == null || !RepeatedCollectManager.exitAndValidate("dubbo consumer repeat record")) { return; } diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/test/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentationTest.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/test/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentationTest.java index f32a384ee..fe240f8ab 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/test/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentationTest.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v2/src/test/java/io/arex/inst/dubbo/apache/v2/DubboConsumerInstrumentationTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.ArgumentMatchers; import org.mockito.MockedConstruction; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @@ -74,7 +75,7 @@ void onExit(Runnable mocker, MockResult mockResult, Predicate predic static Stream onExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(ArgumentMatchers.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -87,4 +88,4 @@ static Stream onExitCase() { arguments(needRecord, null, predicate1) ); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentation.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentation.java index 15cabdaa2..1c433e1d6 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentation.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentation.java @@ -64,7 +64,7 @@ public static boolean onEnter(@Advice.This Invoker invoker, public static void onExit(@Advice.Return(readOnly = false) Result result, @Advice.Local("extractor") DubboConsumerExtractor extractor, @Advice.Local("mockResult") MockResult mockResult) { - if (extractor == null || !RepeatedCollectManager.exitAndValidate()) { + if (extractor == null || !RepeatedCollectManager.exitAndValidate("dubbo consumer repeat record")) { return; } diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentation.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentation.java index 0d2e82ff2..74b7db31d 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentation.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/main/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentation.java @@ -85,7 +85,7 @@ public static void onExit(@Advice.This TripleClientCall clientCall, @Advice.FieldValue("listener") ClientCall.Listener listener, @Advice.Local("extractor") DubboStreamConsumerExtractor extractor, @Advice.Local("mockResult") List mockResults) { - if (extractor == null || !RepeatedCollectManager.exitAndValidate()) { + if (extractor == null || !RepeatedCollectManager.exitAndValidate("dubbo stream consumer repeat record")) { return; } diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentationTest.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentationTest.java index 852bccc8f..6ce98282b 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentationTest.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/DubboConsumerInstrumentationTest.java @@ -77,7 +77,7 @@ void onExit(Runnable mocker, MockResult mockResult, Predicate predic static Stream onExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -90,4 +90,4 @@ static Stream onExitCase() { arguments(needRecord, null, predicate1) ); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentationTest.java b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentationTest.java index 83428f8b7..c2e274fa0 100644 --- a/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentationTest.java +++ b/arex-instrumentation/dubbo/arex-dubbo-apache-v3/src/test/java/io/arex/inst/dubbo/apache/v3/stream/DubboStreamConsumerInstrumentationTest.java @@ -82,7 +82,7 @@ void sendMessageOnExit(Runnable mocker, List mockResults, Runnable a static Stream sendMessageOnExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -138,4 +138,4 @@ void closeOnEnter() { consumerExtractor.verify(() -> DubboStreamConsumerExtractor.close(any(), any())); } } -} \ No newline at end of file +} diff --git a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/arex/ArexMockInstrumentation.java b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/arex/ArexMockInstrumentation.java index 9279084bb..534124611 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/arex/ArexMockInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/arex/ArexMockInstrumentation.java @@ -85,7 +85,7 @@ public static void onExit(@Advice.Local("extractor") DynamicClassExtractor extra } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && extractor != null) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("dynamic repeat record") && extractor != null) { result = extractor.recordResponse(throwable != null ? throwable : result); } } diff --git a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineAsyncInstrumentation.java b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineAsyncInstrumentation.java index ba6ab8437..6cd4e42d8 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineAsyncInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineAsyncInstrumentation.java @@ -68,7 +68,7 @@ public static void onExit(@Advice.Origin("#m") String methodName, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && CacheLoaderUtil.needRecordOrReplay(cacheLoader)) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("caffeine async repeat record") && CacheLoaderUtil.needRecordOrReplay(cacheLoader)) { String className = CacheLoaderUtil.getLocatedClass(cacheLoader); DynamicClassExtractor extractor = new DynamicClassExtractor(className, methodName, new Object[]{key}, methodReturnType); extractor.recordResponse(throwable != null ? throwable : result); diff --git a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineSyncInstrumentation.java b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineSyncInstrumentation.java index dd59d1024..45a7c8624 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineSyncInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/caffeine/CaffeineSyncInstrumentation.java @@ -67,7 +67,7 @@ public static void onExit(@Advice.Origin("#m") String methodName, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && CacheLoaderUtil.needRecordOrReplay(cacheLoader)) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("caffeine sync repeat record") && CacheLoaderUtil.needRecordOrReplay(cacheLoader)) { String className = CacheLoaderUtil.getLocatedClass(cacheLoader); DynamicClassExtractor extractor = new DynamicClassExtractor(className, methodName, new Object[]{key}, methodReturnType); extractor.recordResponse(throwable != null ? throwable : result); diff --git a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/guava/GuavaCacheInstrumentation.java b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/guava/GuavaCacheInstrumentation.java index 7880d9903..7729904b5 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/guava/GuavaCacheInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/guava/GuavaCacheInstrumentation.java @@ -71,7 +71,7 @@ public static void onExit(@Advice.Origin("#m") String methodName, } } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && CacheLoaderUtil.needRecordOrReplay(loader)) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("guava cache repeat record") && CacheLoaderUtil.needRecordOrReplay(loader)) { String className = CacheLoaderUtil.getLocatedClass(loader); DynamicClassExtractor extractor = new DynamicClassExtractor(className, methodName, new Object[]{key}, methodReturnType); extractor.recordResponse(throwable != null ? throwable : result); diff --git a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/spring/SpringCacheInstrumentation.java b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/spring/SpringCacheInstrumentation.java index 791a056a3..97ff2f5f2 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/spring/SpringCacheInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-cache/src/main/java/io/arex/inst/cache/spring/SpringCacheInstrumentation.java @@ -81,7 +81,7 @@ public static void onExit(@Advice.Argument(2) Method method, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && extractor != null) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("spring cache repeat record") && extractor != null) { extractor.recordResponse(throwable != null ? throwable : result); } } diff --git a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/arex/ArexMockInstrumentationTest.java b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/arex/ArexMockInstrumentationTest.java index e4afe2729..c5aab5bcd 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/arex/ArexMockInstrumentationTest.java +++ b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/arex/ArexMockInstrumentationTest.java @@ -97,11 +97,11 @@ void onExit() throws NoSuchMethodException { Mockito.doReturn(true).when(extractor).recordResponse(throwable); }))) { Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); Method test1 = TestArexMock.class.getDeclaredMethod("testWithCacheableAnnotation", String.class, int.class); DynamicClassExtractor extractor = new DynamicClassExtractor(test1, new Object[]{"mock"}, "#val", null); ArexMockInstrumentation.ArexMockAdvice.onExit(extractor, null, null, throwable); Mockito.verify(extractor, Mockito.times(1)).recordResponse(throwable); } } -} \ No newline at end of file +} diff --git a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/guava/GuavaCacheInstrumentationTest.java b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/guava/GuavaCacheInstrumentationTest.java index 6631f206d..f5ad3887f 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/guava/GuavaCacheInstrumentationTest.java +++ b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/guava/GuavaCacheInstrumentationTest.java @@ -104,7 +104,7 @@ public String load(String key) throws Exception { // record AtomicReference atomicReference = new AtomicReference<>(); Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); // record try(MockedConstruction ignored = Mockito.mockConstruction(DynamicClassExtractor.class, ((extractor, context) -> { atomicReference.set(extractor); diff --git a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/spring/SpringCacheInstrumentationTest.java b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/spring/SpringCacheInstrumentationTest.java index 6c77b139f..181e654ef 100644 --- a/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/spring/SpringCacheInstrumentationTest.java +++ b/arex-instrumentation/dynamic/arex-cache/src/test/java/io/arex/inst/cache/spring/SpringCacheInstrumentationTest.java @@ -101,7 +101,7 @@ void onExit() throws NoSuchMethodException { Mockito.doReturn(true).when(extractor).recordResponse(throwable); }))) { Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); DynamicClassExtractor extractor = new DynamicClassExtractor(test1, new Object[]{"mock"}, "#val", null); SpringCacheInstrumentation.SpringCacheAdvice.onExit(test1, extractor, null, null, throwable); Mockito.verify(extractor, Mockito.times(1)).recordResponse(throwable); diff --git a/arex-instrumentation/dynamic/arex-dynamic/src/main/java/io/arex/inst/dynamic/DynamicClassInstrumentation.java b/arex-instrumentation/dynamic/arex-dynamic/src/main/java/io/arex/inst/dynamic/DynamicClassInstrumentation.java index 0e929fd46..509966925 100644 --- a/arex-instrumentation/dynamic/arex-dynamic/src/main/java/io/arex/inst/dynamic/DynamicClassInstrumentation.java +++ b/arex-instrumentation/dynamic/arex-dynamic/src/main/java/io/arex/inst/dynamic/DynamicClassInstrumentation.java @@ -180,7 +180,7 @@ public static void onExit(@Advice.Local("extractor") DynamicClassExtractor extra } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && extractor != null) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("dynamic repeat record") && extractor != null) { result = extractor.recordResponse(throwable != null ? throwable : result); } } diff --git a/arex-instrumentation/dynamic/arex-dynamic/src/test/java/io/arex/inst/dynamic/DynamicClassInstrumentationTest.java b/arex-instrumentation/dynamic/arex-dynamic/src/test/java/io/arex/inst/dynamic/DynamicClassInstrumentationTest.java index 6ba46ff63..17974d9b2 100644 --- a/arex-instrumentation/dynamic/arex-dynamic/src/test/java/io/arex/inst/dynamic/DynamicClassInstrumentationTest.java +++ b/arex-instrumentation/dynamic/arex-dynamic/src/test/java/io/arex/inst/dynamic/DynamicClassInstrumentationTest.java @@ -204,7 +204,7 @@ void onExit() throws NoSuchMethodException { Mockito.doReturn(true).when(extractor).recordResponse(throwable); }))) { Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); Method test1 = DynamicTestClass.class.getDeclaredMethod("testWithArexMock", String.class); DynamicClassExtractor extractor = new DynamicClassExtractor(test1, new Object[]{"mock"}, "#val", null); DynamicClassInstrumentation.MethodAdvice.onExit(extractor, null, null, throwable); diff --git a/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/main/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/main/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentation.java index 8c832522b..c3e42f040 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/main/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/main/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentation.java @@ -82,7 +82,7 @@ public static void onExit( return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("apache httpclient repeat record")) { if (throwable != null) { extractor.record(throwable); } else { diff --git a/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/test/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentationTest.java b/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/test/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentationTest.java index f554b3582..53aa150b7 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/test/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentationTest.java +++ b/arex-instrumentation/httpclient/arex-httpclient-apache-v4/src/test/java/io/arex/inst/httpclient/apache/sync/InternalHttpClientInstrumentationTest.java @@ -83,7 +83,7 @@ void onExit(HttpClientExtractor extractor, Exception static Stream onExitCase() { Exception throwable2 = new NullPointerException(); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); HttpClientExtractor extractor2 = Mockito.mock(HttpClientExtractor.class); Mockito.when(ContextManager.needRecord()).thenReturn(true); diff --git a/arex-instrumentation/httpclient/arex-httpclient-feign/src/main/java/io/arex/inst/httpclient/feign/FeignClientInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-feign/src/main/java/io/arex/inst/httpclient/feign/FeignClientInstrumentation.java index a73aa2225..7a3ad527c 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-feign/src/main/java/io/arex/inst/httpclient/feign/FeignClientInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-feign/src/main/java/io/arex/inst/httpclient/feign/FeignClientInstrumentation.java @@ -82,7 +82,7 @@ public static void onExit(@Local("adapter") FeignClientAdapter adapter, return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("feign http client repeat record")) { response = adapter.copyResponse(response); if (throwable != null) { extractor.record(throwable); diff --git a/arex-instrumentation/httpclient/arex-httpclient-feign/src/test/java/io/arex/inst/httpclient/feign/FeignClientInstrumentationTest.java b/arex-instrumentation/httpclient/arex-httpclient-feign/src/test/java/io/arex/inst/httpclient/feign/FeignClientInstrumentationTest.java index 275adba80..9d138fac7 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-feign/src/test/java/io/arex/inst/httpclient/feign/FeignClientInstrumentationTest.java +++ b/arex-instrumentation/httpclient/arex-httpclient-feign/src/test/java/io/arex/inst/httpclient/feign/FeignClientInstrumentationTest.java @@ -92,7 +92,7 @@ void onExit() { // record exception Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); final FeignClientAdapter clientAdapter = Mockito.mock(FeignClientAdapter.class); final RuntimeException exception = new RuntimeException(); FeignClientInstrumentation.ExecuteAdvice.onExit(clientAdapter, clientExtractor, null, null, exception); diff --git a/arex-instrumentation/httpclient/arex-httpclient-ning/src/main/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-ning/src/main/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentation.java index ab2b02535..a8c2ff412 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-ning/src/main/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-ning/src/main/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentation.java @@ -69,7 +69,7 @@ public static void onExit(@Advice.Local("mockResult") MockResult mockResult, } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && extractor != null) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("ning http client repeat record") && extractor != null) { if (throwable != null) { extractor.record(throwable); } else { diff --git a/arex-instrumentation/httpclient/arex-httpclient-ning/src/test/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentationTest.java b/arex-instrumentation/httpclient/arex-httpclient-ning/src/test/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentationTest.java index 1a4e25142..727b10503 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-ning/src/test/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentationTest.java +++ b/arex-instrumentation/httpclient/arex-httpclient-ning/src/test/java/io/arex/inst/httpclient/ning/AsyncHttpClientInstrumentationTest.java @@ -78,7 +78,7 @@ void onEnter() { @Test void onExit() { Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); // replay result MockResult mockResult = MockResult.success("testMockResult"); HttpClientExtractor extractorMock = Mockito.mock(HttpClientExtractor.class); diff --git a/arex-instrumentation/httpclient/arex-httpclient-okhttp-v3/src/main/java/io/arex/inst/httpclient/okhttp/v3/OkHttpCallInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-okhttp-v3/src/main/java/io/arex/inst/httpclient/okhttp/v3/OkHttpCallInstrumentation.java index bee2f564d..ba9837977 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-okhttp-v3/src/main/java/io/arex/inst/httpclient/okhttp/v3/OkHttpCallInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-okhttp-v3/src/main/java/io/arex/inst/httpclient/okhttp/v3/OkHttpCallInstrumentation.java @@ -70,7 +70,7 @@ public static void onExit( @Advice.Thrown(readOnly = false) Exception throwable, @Advice.Return(readOnly = false) Response response, @Advice.Local("mockResult") MockResult mockResult) throws IOException { - if (extractor == null || !RepeatedCollectManager.exitAndValidate()) { + if (extractor == null || !RepeatedCollectManager.exitAndValidate("okhttp repeat record")) { return; } diff --git a/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/main/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/main/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentation.java index 05f72f129..f80f34562 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/main/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/main/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentation.java @@ -62,7 +62,7 @@ public static void onExit(@Return(readOnly = false, typing = Typing.DYNAMIC) Obj } return; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate() && extractor != null) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("restTemplate http client repeat record") && extractor != null) { extractor.record(result, throwable); } } diff --git a/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/test/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentationTest.java b/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/test/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentationTest.java index 0493a3532..43e78e83e 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/test/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentationTest.java +++ b/arex-instrumentation/httpclient/arex-httpclient-resttemplate/src/test/java/io/arex/inst/httpclient/resttemplate/RestTemplateInstrumentationTest.java @@ -83,9 +83,9 @@ void onExit() { // record Mockito.when(ContextManager.needRecord()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); RestTemplateInstrumentation.ExecuteAdvice.onExit(result, throwable, extractor, null); Mockito.verify(extractor, Mockito.times(1)).record(result, throwable); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/main/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentation.java b/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/main/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentation.java index e283a6614..2440699a1 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/main/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentation.java +++ b/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/main/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentation.java @@ -64,7 +64,7 @@ public static void onExit( @Advice.Local("wrapper") WebClientWrapper wrapper, @Advice.Local("mockResult") MockResult mockResult, @Advice.Return(readOnly = false) Mono response) { - if (wrapper == null || !RepeatedCollectManager.exitAndValidate()) { + if (wrapper == null || !RepeatedCollectManager.exitAndValidate("webclient repeat record")) { return; } @@ -77,4 +77,4 @@ public static void onExit( } } } -} \ No newline at end of file +} diff --git a/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/test/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentationTest.java b/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/test/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentationTest.java index a914b0db6..38aad8f12 100644 --- a/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/test/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentationTest.java +++ b/arex-instrumentation/httpclient/arex-httpclient-webclient-v5/src/test/java/io/arex/inst/httpclient/webclient/v5/WebClientInstrumentationTest.java @@ -83,7 +83,7 @@ void onExit(Runnable mocker, MockResult mockResult, Predicate predic static Stream onExitCase() { Runnable emptyMocker = () -> {}; Runnable exitAndValidate = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); }; Runnable needRecord = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(true); @@ -96,4 +96,4 @@ static Stream onExitCase() { arguments(needRecord, null, predicate1) ); } -} \ No newline at end of file +} diff --git a/arex-instrumentation/redis/arex-jedis-v2/src/main/java/io/arex/inst/jedis/v2/JedisWrapper.java b/arex-instrumentation/redis/arex-jedis-v2/src/main/java/io/arex/inst/jedis/v2/JedisWrapper.java index 6420841ed..85f7f6719 100644 --- a/arex-instrumentation/redis/arex-jedis-v2/src/main/java/io/arex/inst/jedis/v2/JedisWrapper.java +++ b/arex-instrumentation/redis/arex-jedis-v2/src/main/java/io/arex/inst/jedis/v2/JedisWrapper.java @@ -565,7 +565,7 @@ private U call(String command, Object key, Object field, Callable callabl try { result = callable.call(); } catch (Exception e) { - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("jedis exception repeat record")) { RedisExtractor extractor = new RedisExtractor(this.url, command, key, field); extractor.record(e); } @@ -577,7 +577,7 @@ private U call(String command, Object key, Object field, Callable callabl return defaultValue; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("jedis repeat record")) { RedisExtractor extractor = new RedisExtractor(this.url, command, key, field); extractor.record(result); } diff --git a/arex-instrumentation/redis/arex-jedis-v4/src/main/java/io/arex/inst/jedis/v4/JedisWrapper.java b/arex-instrumentation/redis/arex-jedis-v4/src/main/java/io/arex/inst/jedis/v4/JedisWrapper.java index dea92ea28..a262a1c18 100644 --- a/arex-instrumentation/redis/arex-jedis-v4/src/main/java/io/arex/inst/jedis/v4/JedisWrapper.java +++ b/arex-instrumentation/redis/arex-jedis-v4/src/main/java/io/arex/inst/jedis/v4/JedisWrapper.java @@ -618,7 +618,7 @@ private U call(String command, String key, String field, Callable callabl try { result = callable.call(); } catch (Exception e) { - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("jedis exception repeat record")) { RedisExtractor extractor = new RedisExtractor(this.url, command, key, field); extractor.record(e); } @@ -630,7 +630,7 @@ private U call(String command, String key, String field, Callable callabl return defaultValue; } - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("jedis repeat record")) { RedisExtractor extractor = new RedisExtractor(this.url, command, key, field); extractor.record(result); } diff --git a/arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common/lettuce/wrapper/RedisCommandWrapper.java b/arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common/lettuce/wrapper/RedisCommandWrapper.java index aa84c8277..6e02c7a2a 100644 --- a/arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common/lettuce/wrapper/RedisCommandWrapper.java +++ b/arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common/lettuce/wrapper/RedisCommandWrapper.java @@ -725,7 +725,7 @@ public RedisFuture dispatch(Supplier> supplier, RedisComma RedisFuture resultFuture = supplier.get(); - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("redis repeat record")) { try (TraceTransmitter traceTransmitter = TraceTransmitter.create()) { resultFuture.whenComplete((v, throwable) -> { RedisExtractor extractor = new RedisExtractor(redisUri, cmd.getType().name(), key, field); diff --git a/arex-instrumentation/redis/arex-redission-v3/src/main/java/io/arex/inst/redisson/v3/RedissonWrapperCommon.java b/arex-instrumentation/redis/arex-redission-v3/src/main/java/io/arex/inst/redisson/v3/RedissonWrapperCommon.java index adaae8e69..2699e8b75 100644 --- a/arex-instrumentation/redis/arex-redission-v3/src/main/java/io/arex/inst/redisson/v3/RedissonWrapperCommon.java +++ b/arex-instrumentation/redis/arex-redission-v3/src/main/java/io/arex/inst/redisson/v3/RedissonWrapperCommon.java @@ -36,7 +36,7 @@ public static RFuture delegateCall(String redisUri, String cmd, String ke RFuture resultFuture = futureSupplier.get(); - if (resultFuture != null && ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (resultFuture != null && ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("redis repeat record")) { try (TraceTransmitter traceTransmitter = TraceTransmitter.create()) { resultFuture.whenComplete((v, throwable) -> { traceTransmitter.transmit(); diff --git a/arex-instrumentation/redis/arex-spring-data-redis/src/main/java/io/arex/inst/spring/data/redis/RedisTemplateProvider.java b/arex-instrumentation/redis/arex-spring-data-redis/src/main/java/io/arex/inst/spring/data/redis/RedisTemplateProvider.java index d136cbdd8..513e49ed1 100644 --- a/arex-instrumentation/redis/arex-spring-data-redis/src/main/java/io/arex/inst/spring/data/redis/RedisTemplateProvider.java +++ b/arex-instrumentation/redis/arex-spring-data-redis/src/main/java/io/arex/inst/spring/data/redis/RedisTemplateProvider.java @@ -12,7 +12,7 @@ public class RedisTemplateProvider { public static void methodOnExit(String redisUri, String methodName, Object key, Object result, Throwable throwable) { - if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate()) { + if (ContextManager.needRecord() && RepeatedCollectManager.exitAndValidate("redis repeat record")) { RedisExtractor extractor = new RedisExtractor(redisUri, methodName, key, null); if (throwable != null) { extractor.record(throwable); diff --git a/arex-instrumentation/redis/arex-spring-data-redis/src/test/java/io/arex/inst/spring/data/redis/RedisTemplateProviderTest.java b/arex-instrumentation/redis/arex-spring-data-redis/src/test/java/io/arex/inst/spring/data/redis/RedisTemplateProviderTest.java index b5a634865..eec2b012f 100644 --- a/arex-instrumentation/redis/arex-spring-data-redis/src/test/java/io/arex/inst/spring/data/redis/RedisTemplateProviderTest.java +++ b/arex-instrumentation/redis/arex-spring-data-redis/src/test/java/io/arex/inst/spring/data/redis/RedisTemplateProviderTest.java @@ -66,20 +66,20 @@ private static Stream mockStream() { Runnable mocker1 = () -> { Mockito.when(ContextManager.needRecord()).thenReturn(false); Mockito.when(ContextManager.needReplay()).thenReturn(true); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(false); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(false); }; // needRecord & not repeatEnter Runnable mocker2 = () -> { Mockito.mock(ContextManager.class); - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(true); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(true); Mockito.when(ContextManager.needReplay()).thenReturn(false); Mockito.when(ContextManager.needRecord()).thenReturn(true); }; // needRecord & repeatEnter Runnable mocker3 = () -> { - Mockito.when(RepeatedCollectManager.exitAndValidate()).thenReturn(false); + Mockito.when(RepeatedCollectManager.exitAndValidate(Mockito.anyString())).thenReturn(false); }; return Stream.of(arguments(mocker), arguments(mocker1), arguments(mocker2), arguments(mocker3));