diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 5d651642e6..a4cfe3cb54 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -90,6 +90,7 @@ jobs: - dbcp-2.x-scenario - jsonrpc4j-1.x-scenario - gateway-3.x-scenario + - gateway-3.x-filter-context-scenario - neo4j-4.x-scenario - oracle-scenario - druid-1.x-scenario diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingSegmentIDInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingSegmentIDInterceptor.java index 4d00a090f7..a8dc12a80c 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingSegmentIDInterceptor.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingSegmentIDInterceptor.java @@ -48,6 +48,6 @@ public Object afterMethod(Class clazz, Method method, Object[] allArguments, Cla @Override public void handleMethodException(Class clazz, Method method, Object[] allArguments, Class[] parameterTypes, Throwable t) { - LOGGER.error("Failed to getDefault segment Id.", t); + LOGGER.error("Failed to get segment Id.", t); } } diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java index f783a47002..138d9440eb 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingStaticMethodsAroundInterceptor.java @@ -29,7 +29,7 @@ public abstract class WebFluxSkyWalkingStaticMethodsAroundInterceptor implements StaticMethodsAroundInterceptor { - protected static EnhancedInstance getInstance(Object o) { + protected EnhancedInstance getInstance(Object o) { EnhancedInstance instance = null; if (o instanceof DefaultServerWebExchange && o instanceof EnhancedInstance) { instance = (EnhancedInstance) o; @@ -40,7 +40,7 @@ protected static EnhancedInstance getInstance(Object o) { return instance; } - protected static ContextSnapshot getContextSnapshot(Object o) { + protected ContextSnapshot getContextSnapshot(Object o) { return Optional.ofNullable(getInstance(o)) .map(EnhancedInstance::getSkyWalkingDynamicField) .filter(ContextSnapshot.class::isInstance) diff --git a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java index 5d9b31313a..77d522f740 100644 --- a/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java +++ b/apm-sniffer/apm-toolkit-activation/apm-toolkit-webflux-activation/src/main/java/org/apache/skywalking/apm/toolkit/activation/webflux/WebFluxSkyWalkingTraceContextActivation.java @@ -27,8 +27,6 @@ import static net.bytebuddy.matcher.ElementMatchers.named; -/** - */ public class WebFluxSkyWalkingTraceContextActivation extends ClassStaticMethodsEnhancePluginDefine { public static final String TRACE_ID_INTERCEPT_CLASS = "org.apache.skywalking.apm.toolkit.activation.webflux.WebFluxSkyWalkingTraceIDInterceptor"; diff --git a/docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md b/docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md index 8003df0b5f..0fa738c54c 100644 --- a/docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md +++ b/docs/en/setup/service-agent/java-agent/Application-toolkit-webflux.md @@ -59,6 +59,12 @@ The `WebFluxSkyWalkingOperators#continueTracing` provides manual tracing continu // fetch trace ID String traceId = WebFluxSkyWalkingTraceContext.traceId(exchange); + // fetch segment ID + String segmentId = WebFluxSkyWalkingTraceContext.segmentId(exchange); + + // fetch span ID + int spanId = WebFluxSkyWalkingTraceContext.spanId(exchange); + return chain.filter(exchange); } ``` @@ -69,7 +75,13 @@ The `WebFluxSkyWalkingOperators#continueTracing` provides manual tracing continu @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain){ // Set correlation data can be retrieved by upstream nodes. - WebFluxSkyWalkingTraceContext.putCorrelation(exchange, "key", "value"); + WebFluxSkyWalkingTraceContext.putCorrelation(exchange, "key1", "value"); + + // Get correlation data + Optional value2 = WebFluxSkyWalkingTraceContext.getCorrelation(exchange, "key2"); + + // dosomething... + return chain.filter(exchange); } ```