From 1fb9db53cbaf171f18e0f9574b9b980359164bb6 Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 00:11:39 +0800 Subject: [PATCH 1/7] stabilise spanNames --- .../instrumentation/api}/semconv/util/SpanNames.java | 2 +- .../javaagent/instrumentation/grails/HandlerData.java | 2 +- .../instrumentationannotations/AnnotationSingletons.java | 2 +- .../extensionannotations/WithSpanSingletons.java | 2 +- .../instrumentationannotations/AnnotationSingletons.java | 2 +- .../internal/instrumentation/annotations/JoinPointRequest.java | 2 +- .../spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java | 2 +- .../instrumentation/spring/webmvc/HandlerSpanNameExtractor.java | 2 +- .../javaagent/instrumentation/twilio/TwilioSingletons.java | 2 +- .../javaagent/instrumentation/vaadin/VaadinHandlerRequest.java | 2 +- .../javaagent/instrumentation/vaadin/VaadinServiceRequest.java | 2 +- .../javaagent/instrumentation/vaadin/VaadinSingletons.java | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) rename {instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator => instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api}/semconv/util/SpanNames.java (95%) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java similarity index 95% rename from instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java rename to instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java index 7962b0474333..4f1c948373d9 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.api.incubator.semconv.util; +package io.opentelemetry.instrumentation.api.semconv.util; import io.opentelemetry.instrumentation.api.internal.ClassNames; import io.opentelemetry.instrumentation.api.internal.cache.Cache; diff --git a/instrumentation/grails-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grails/HandlerData.java b/instrumentation/grails-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grails/HandlerData.java index cc09d92aa9cd..6427f466d13f 100644 --- a/instrumentation/grails-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grails/HandlerData.java +++ b/instrumentation/grails-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grails/HandlerData.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.grails; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; public class HandlerData { diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java index 134b1a3ac309..c547ffb3184b 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java @@ -7,7 +7,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; public final class AnnotationSingletons { diff --git a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java index ea29e091a461..963a6d5aaa5b 100644 --- a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java +++ b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java @@ -11,7 +11,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.api.annotation.support.MethodSpanAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import java.lang.reflect.Method; import java.util.logging.Logger; diff --git a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java index ff1d75aec95e..b7c07c867562 100644 --- a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java +++ b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java @@ -13,7 +13,7 @@ import io.opentelemetry.instrumentation.api.annotation.support.MethodSpanAttributesExtractor; import io.opentelemetry.instrumentation.api.annotation.support.SpanAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import java.lang.reflect.Method; import java.util.logging.Logger; diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/JoinPointRequest.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/JoinPointRequest.java index 01a6a62d9894..4189c6cb3060 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/JoinPointRequest.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/internal/instrumentation/annotations/JoinPointRequest.java @@ -7,7 +7,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.annotations.WithSpan; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import java.lang.reflect.Method; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.reflect.MethodSignature; diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java index 9ab4ae97d3f5..4b956c7015f6 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import org.springframework.web.method.HandlerMethod; diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java b/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java index a37ebf617784..cbbbb41771dd 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java @@ -5,7 +5,7 @@ package io.opentelemetry.javaagent.instrumentation.spring.webmvc; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import java.lang.reflect.Method; import javax.annotation.Nullable; diff --git a/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java b/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java index 3c6b3296e125..25513804fdb6 100644 --- a/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java +++ b/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java @@ -8,7 +8,7 @@ import static io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor.alwaysClient; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig; diff --git a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinHandlerRequest.java b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinHandlerRequest.java index 0a820e9aa988..15025350dd57 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinHandlerRequest.java +++ b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinHandlerRequest.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; import com.google.auto.value.AutoValue; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; @AutoValue public abstract class VaadinHandlerRequest { diff --git a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinServiceRequest.java b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinServiceRequest.java index 02bfcf2b1a69..9bca796e79d9 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinServiceRequest.java +++ b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinServiceRequest.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.vaadin; import com.google.auto.value.AutoValue; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; @AutoValue public abstract class VaadinServiceRequest { diff --git a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java index 2422b9a1d82a..b81f22b4eff6 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java +++ b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java @@ -10,7 +10,7 @@ import io.opentelemetry.context.ContextKey; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.util.SpanNames; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig; From 5faaf8c64a81b6cc2c4a68612c68096b292a22e6 Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 01:18:22 +0800 Subject: [PATCH 2/7] spotlessApply --- .../instrumentationannotations/AnnotationSingletons.java | 2 +- .../extensionannotations/WithSpanSingletons.java | 2 +- .../instrumentationannotations/AnnotationSingletons.java | 2 +- .../spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java | 2 +- .../instrumentation/spring/webmvc/HandlerSpanNameExtractor.java | 2 +- .../javaagent/instrumentation/twilio/TwilioSingletons.java | 2 +- .../javaagent/instrumentation/vaadin/VaadinSingletons.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java index c547ffb3184b..88d6af48f2f0 100644 --- a/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java +++ b/instrumentation/kotlinx-coroutines/kotlinx-coroutines-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/kotlinxcoroutines/instrumentationannotations/AnnotationSingletons.java @@ -7,8 +7,8 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; public final class AnnotationSingletons { diff --git a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java index 963a6d5aaa5b..cebd4bd009c3 100644 --- a/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java +++ b/instrumentation/opentelemetry-extension-annotations-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/extensionannotations/WithSpanSingletons.java @@ -11,8 +11,8 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.api.annotation.support.MethodSpanAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import java.lang.reflect.Method; import java.util.logging.Logger; diff --git a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java index b7c07c867562..4e268ebf496b 100644 --- a/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java +++ b/instrumentation/opentelemetry-instrumentation-annotations-1.16/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/instrumentationannotations/AnnotationSingletons.java @@ -13,8 +13,8 @@ import io.opentelemetry.instrumentation.api.annotation.support.MethodSpanAttributesExtractor; import io.opentelemetry.instrumentation.api.annotation.support.SpanAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import java.lang.reflect.Method; import java.util.logging.Logger; diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java index 4b956c7015f6..03189d3f0c71 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/WebfluxSpanNameExtractor.java @@ -6,8 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.spring.webflux.v5_0.server; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import org.springframework.web.method.HandlerMethod; public class WebfluxSpanNameExtractor implements SpanNameExtractor { diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java b/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java index cbbbb41771dd..1c332828ba6d 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webmvc/HandlerSpanNameExtractor.java @@ -5,8 +5,8 @@ package io.opentelemetry.javaagent.instrumentation.spring.webmvc; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import java.lang.reflect.Method; import javax.annotation.Nullable; import org.springframework.web.HttpRequestHandler; diff --git a/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java b/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java index 25513804fdb6..106ad4873ce3 100644 --- a/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java +++ b/instrumentation/twilio-6.6/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/twilio/TwilioSingletons.java @@ -8,9 +8,9 @@ import static io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor.alwaysClient; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig; public final class TwilioSingletons { diff --git a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java index b81f22b4eff6..c3ff8e879282 100644 --- a/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java +++ b/instrumentation/vaadin-14.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vaadin/VaadinSingletons.java @@ -10,8 +10,8 @@ import io.opentelemetry.context.ContextKey; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.code.CodeSpanNameExtractor; -import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.semconv.util.SpanNames; import io.opentelemetry.javaagent.bootstrap.internal.ExperimentalConfig; public class VaadinSingletons { From 1adb303fb6312b4622642c02a1252bec56ac6c29 Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 01:22:05 +0800 Subject: [PATCH 3/7] fix --- .../current_vs_latest/opentelemetry-instrumentation-api.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt index a7162c2594c7..8288f76f10ac 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt @@ -1,2 +1,6 @@ Comparing source compatibility of opentelemetry-instrumentation-api-2.10.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.9.0.jar -No changes. \ No newline at end of file ++++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.instrumentation.api.semconv.util.SpanNames (not serializable) + +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. + +++ NEW SUPERCLASS: java.lang.Object + +++ NEW METHOD: PUBLIC(+) STATIC(+) java.lang.String fromMethod(java.lang.reflect.Method) + +++ NEW METHOD: PUBLIC(+) STATIC(+) java.lang.String fromMethod(java.lang.Class, java.lang.String) From 8fd0e5565bef1a2b5944e7915c4f427d6aa1a2cc Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 11:53:19 +0800 Subject: [PATCH 4/7] keep the old class and mark it as 'deprecated' --- .../api/incubator/semconv/util/SpanNames.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java new file mode 100644 index 000000000000..d21b35d00884 --- /dev/null +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java @@ -0,0 +1,48 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.incubator.semconv.util; + +import io.opentelemetry.instrumentation.api.internal.ClassNames; +import io.opentelemetry.instrumentation.api.internal.cache.Cache; + +import java.lang.reflect.Method; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Deprecated +public final class SpanNames { + + private static final Cache, Map> spanNameCaches = Cache.weak(); + + /** + * This method is used to generate a span name based on a method. Anonymous classes are named + * based on their parent. + */ + public static String fromMethod(Method method) { + return fromMethod(method.getDeclaringClass(), method.getName()); + } + + /** + * This method is used to generate a span name based on a method. Anonymous classes are named + * based on their parent. + */ + public static String fromMethod(Class clazz, String methodName) { + // the cache (ConcurrentHashMap) is naturally bounded by the number of methods in a class + Map spanNameCache = + spanNameCaches.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); + + // not using computeIfAbsent, because it would require a capturing (allocating) lambda + String spanName = spanNameCache.get(methodName); + if (spanName != null) { + return spanName; + } + spanName = ClassNames.simpleName(clazz) + "." + methodName; + spanNameCache.put(methodName, spanName); + return spanName; + } + + private SpanNames() {} +} From 26cfbf0a8bf187cfc3feb58bce661b531509b03c Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 11:54:47 +0800 Subject: [PATCH 5/7] spotlessApply --- .../instrumentation/api/incubator/semconv/util/SpanNames.java | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java index d21b35d00884..e23d75f835f2 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java @@ -7,7 +7,6 @@ import io.opentelemetry.instrumentation.api.internal.ClassNames; import io.opentelemetry.instrumentation.api.internal.cache.Cache; - import java.lang.reflect.Method; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; From f7c177a68f9d0be2da4c8c7ab3bd5cd014c853e5 Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Tue, 22 Oct 2024 12:01:18 +0800 Subject: [PATCH 6/7] add javadoc --- .../instrumentation/api/incubator/semconv/util/SpanNames.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java index e23d75f835f2..73a565c97660 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java @@ -11,6 +11,10 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +/** + * This class has been stabilized and moved to {@link + * io.opentelemetry.instrumentation.api.semconv.util.SpanNames} + */ @Deprecated public final class SpanNames { From e014cbf1f6a9827eedfb1f442d807da672317b58 Mon Sep 17 00:00:00 2001 From: dingjiefei <1264677051@qq.com> Date: Thu, 21 Nov 2024 14:40:32 +0800 Subject: [PATCH 7/7] add javadoc,unit test --- .../opentelemetry-instrumentation-api.txt | 6 ++++- .../api/incubator/semconv/util/SpanNames.java | 22 +++------------- .../api/semconv/util/SpanNames.java | 1 + .../api/semconv/util/SpanNamesTest.java | 25 +++++++++++++++++++ 4 files changed, 34 insertions(+), 20 deletions(-) create mode 100644 instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNamesTest.java diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt index 89b50f435fc5..767e445ba09b 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt @@ -1,2 +1,6 @@ Comparing source compatibility of opentelemetry-instrumentation-api-2.11.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.10.0.jar -No changes. ++++ NEW CLASS: PUBLIC(+) FINAL(+) io.opentelemetry.instrumentation.api.semconv.util.SpanNames (not serializable) + +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. + +++ NEW SUPERCLASS: java.lang.Object + +++ NEW METHOD: PUBLIC(+) STATIC(+) java.lang.String fromMethod(java.lang.reflect.Method) + +++ NEW METHOD: PUBLIC(+) STATIC(+) java.lang.String fromMethod(java.lang.Class, java.lang.String) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java index 73a565c97660..6d9f799436a3 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/util/SpanNames.java @@ -5,11 +5,7 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.util; -import io.opentelemetry.instrumentation.api.internal.ClassNames; -import io.opentelemetry.instrumentation.api.internal.cache.Cache; import java.lang.reflect.Method; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** * This class has been stabilized and moved to {@link @@ -18,14 +14,12 @@ @Deprecated public final class SpanNames { - private static final Cache, Map> spanNameCaches = Cache.weak(); - /** * This method is used to generate a span name based on a method. Anonymous classes are named * based on their parent. */ public static String fromMethod(Method method) { - return fromMethod(method.getDeclaringClass(), method.getName()); + return io.opentelemetry.instrumentation.api.semconv.util.SpanNames.fromMethod(method); } /** @@ -33,18 +27,8 @@ public static String fromMethod(Method method) { * based on their parent. */ public static String fromMethod(Class clazz, String methodName) { - // the cache (ConcurrentHashMap) is naturally bounded by the number of methods in a class - Map spanNameCache = - spanNameCaches.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); - - // not using computeIfAbsent, because it would require a capturing (allocating) lambda - String spanName = spanNameCache.get(methodName); - if (spanName != null) { - return spanName; - } - spanName = ClassNames.simpleName(clazz) + "." + methodName; - spanNameCache.put(methodName, spanName); - return spanName; + return io.opentelemetry.instrumentation.api.semconv.util.SpanNames.fromMethod( + clazz, methodName); } private SpanNames() {} diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java index 4f1c948373d9..4dfffeaa8e0c 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNames.java @@ -11,6 +11,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +/** A utility class used to generate span names. */ public final class SpanNames { private static final Cache, Map> spanNameCaches = Cache.weak(); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNamesTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNamesTest.java new file mode 100644 index 000000000000..dde0647db52d --- /dev/null +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/util/SpanNamesTest.java @@ -0,0 +1,25 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.semconv.util; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.lang.reflect.Method; +import org.junit.jupiter.api.Test; + +class SpanNamesTest { + @Test + void testFromMethod() throws NoSuchMethodException { + Method method = TestClass.class.getMethod("test"); + assertThat(SpanNames.fromMethod(method)).isEqualTo("TestClass.test"); + } + + static class TestClass { + private TestClass() {} + + public void test() {} + } +}