From 869c56595151fd16832bcbb920cd880549afb355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=A7=E6=80=9D?= Date: Wed, 8 May 2024 12:08:58 +0800 Subject: [PATCH] polish code --- .../apache-shenyu-2.4/javaagent/build.gradle.kts | 4 ++-- ...onModule.java => ApacheShenYuInstrumentationModule.java} | 4 ++-- ...cheShenyuSingletons.java => ApacheShenYuSingletons.java} | 4 ++-- .../apacheshenyu/v2_4/ContextBuilderInstrumentation.java | 2 +- .../v2_4/{ShenyuRouteTest.java => ShenYuRouteTest.java} | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) rename instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/{ApacheShenyuInstrumentationModule.java => ApacheShenYuInstrumentationModule.java} (85%) rename instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/{ApacheShenyuSingletons.java => ApacheShenYuSingletons.java} (83%) rename instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/{ShenyuRouteTest.java => ShenYuRouteTest.java} (96%) diff --git a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/build.gradle.kts b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/build.gradle.kts index 254772db18a4..bd8ddb72eeb2 100644 --- a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/build.gradle.kts +++ b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/build.gradle.kts @@ -7,6 +7,7 @@ muzzle { group.set("org.apache.shenyu") module.set("shenyu-web") versions.set("[2.4.0,)") + assertInverse.set(true) } } @@ -15,7 +16,6 @@ dependencies { compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") - testInstrumentation(project(":instrumentation:apache-shenyu:apache-shenyu-2.4:javaagent")) testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-3.1:javaagent")) testInstrumentation(project(":instrumentation:reactor:reactor-netty:reactor-netty-1.0:javaagent")) @@ -25,7 +25,7 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-webflux:2.2.2.RELEASE") { exclude("org.codehaus.groovy", "groovy") } -// based on apache shenyu 2.4.0 official example + // based on apache shenyu 2.4.0 official example testImplementation("org.apache.shenyu:shenyu-spring-boot-starter-gateway:2.4.0") { exclude("org.codehaus.groovy", "groovy") } diff --git a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuInstrumentationModule.java b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuInstrumentationModule.java similarity index 85% rename from instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuInstrumentationModule.java rename to instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuInstrumentationModule.java index 87ceb42913c9..1fafefb8e016 100644 --- a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuInstrumentationModule.java +++ b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuInstrumentationModule.java @@ -13,8 +13,8 @@ import java.util.List; @AutoService(InstrumentationModule.class) -public class ApacheShenyuInstrumentationModule extends InstrumentationModule { - public ApacheShenyuInstrumentationModule() { +public class ApacheShenYuInstrumentationModule extends InstrumentationModule { + public ApacheShenYuInstrumentationModule() { super("apache-shenyu", "apache-shenyu-2.4"); } diff --git a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuSingletons.java b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuSingletons.java similarity index 83% rename from instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuSingletons.java rename to instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuSingletons.java index 4822ddcc94fc..a26a11623f3f 100644 --- a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenyuSingletons.java +++ b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ApacheShenYuSingletons.java @@ -8,9 +8,9 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter; import org.apache.shenyu.common.dto.MetaData; -public class ApacheShenyuSingletons { +public final class ApacheShenYuSingletons { - private ApacheShenyuSingletons() {} + private ApacheShenYuSingletons() {} public static HttpServerRouteGetter httpRouteGetter() { return (context, metaData) -> metaData.getPath(); diff --git a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ContextBuilderInstrumentation.java b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ContextBuilderInstrumentation.java index dab39d418965..c858eb1bad33 100644 --- a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ContextBuilderInstrumentation.java +++ b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ContextBuilderInstrumentation.java @@ -48,7 +48,7 @@ public static void onExit(@Advice.Argument(0) ServerWebExchange exchange) { HttpServerRoute.update( context, HttpServerRouteSource.NESTED_CONTROLLER, - ApacheShenyuSingletons.httpRouteGetter(), + ApacheShenYuSingletons.httpRouteGetter(), metaData); MetaDataHelper.extractAttributes(metaData, context); } diff --git a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenyuRouteTest.java b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java similarity index 96% rename from instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenyuRouteTest.java rename to instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java index 96047ab9e2e0..41cd0fd80cb3 100644 --- a/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenyuRouteTest.java +++ b/instrumentation/apache-shenyu/apache-shenyu-2.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apacheshenyu/v2_4/ShenYuRouteTest.java @@ -30,8 +30,8 @@ @SpringBootTest( properties = {"shenyu.local.enabled=true", "spring.main.allow-bean-definition-overriding=true"}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - classes = {ShenyuBootstrapApplication.class, ShenyuRouteTest.ForceNettyAutoConfiguration.class}) -public class ShenyuRouteTest { + classes = {ShenyuBootstrapApplication.class, ShenYuRouteTest.ForceNettyAutoConfiguration.class}) +class ShenYuRouteTest { private static final AttributeKey META_ID_ATTRIBUTE = AttributeKey.stringKey("apache-shenyu.meta.id"); @@ -75,7 +75,7 @@ NettyReactiveWebServerFactory nettyFactory() { } @RegisterExtension - static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + private static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); final ConfigurableApplicationContext[] context = {null};