From 5a9814de4793761edca70ac5fd40b915ff9b0aaa Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Sat, 22 Jun 2024 11:38:03 +0200 Subject: [PATCH] fix rebase --- .../server/AkkaHttpServerSingletons.java | 7 +++--- .../grizzly/GrizzlySingletons.java | 7 +++--- .../jetty/v12_0/Jetty12Singletons.java | 7 +++--- .../LibertyDispatcherSingletons.java | 7 +++--- .../v3_8/server/NettyServerSingletons.java | 7 +++--- .../NettyClientInstrumenterBuilder.java | 8 ++----- .../v4_0/server/NettyServerSingletons.java | 7 +++--- .../server/PekkoHttpServerSingletons.java | 7 +++--- .../restlet/v1_1/RestletSingletons.java | 4 ++-- .../restlet/v2_0/RestletSingletons.java | 5 ++-- .../servlet/ServletInstrumenterBuilder.java | 4 ++-- ...bMvc5InstrumentationAutoConfiguration.java | 12 ++++------ ...bMvc6InstrumentationAutoConfiguration.java | 12 ++++------ .../common/TomcatInstrumenterFactory.java | 7 +++--- .../undertow/UndertowSingletons.java | 7 +++--- .../JavaagentHttpClientInstrumenters.java | 6 ++--- ... => JavaagentHttpServerInstrumenters.java} | 23 +++++++++---------- 17 files changed, 59 insertions(+), 78 deletions(-) rename javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/{JavaagentHttpServerInstrumenterBuilder.java => JavaagentHttpServerInstrumenters.java} (74%) diff --git a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/server/AkkaHttpServerSingletons.java b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/server/AkkaHttpServerSingletons.java index 4feb440c32e3..a52da0636ffc 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/server/AkkaHttpServerSingletons.java +++ b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/server/AkkaHttpServerSingletons.java @@ -8,9 +8,8 @@ import akka.http.scaladsl.model.HttpRequest; import akka.http.scaladsl.model.HttpResponse; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.instrumentation.akkahttp.AkkaHttpUtil; -import java.util.Optional; public final class AkkaHttpServerSingletons { @@ -18,10 +17,10 @@ public final class AkkaHttpServerSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.create( + JavaagentHttpServerInstrumenters.create( AkkaHttpUtil.instrumentationName(), new AkkaHttpServerAttributesGetter(), - Optional.of(AkkaHttpServerHeaders.INSTANCE)); + AkkaHttpServerHeaders.INSTANCE); } public static Instrumenter instrumenter() { diff --git a/instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlySingletons.java b/instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlySingletons.java index 315d55482122..f19965d65ad4 100644 --- a/instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlySingletons.java +++ b/instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlySingletons.java @@ -6,9 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.grizzly; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge; -import java.util.Optional; import org.glassfish.grizzly.http.HttpRequestPacket; import org.glassfish.grizzly.http.HttpResponsePacket; @@ -18,10 +17,10 @@ public final class GrizzlySingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + JavaagentHttpServerInstrumenters.create( "io.opentelemetry.grizzly-2.3", new GrizzlyHttpAttributesGetter(), - Optional.of(HttpRequestHeadersGetter.INSTANCE), + HttpRequestHeadersGetter.INSTANCE, builder -> builder .addContextCustomizer( diff --git a/instrumentation/jetty/jetty-12.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/v12_0/Jetty12Singletons.java b/instrumentation/jetty/jetty-12.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/v12_0/Jetty12Singletons.java index 8dd17eaec62f..4017379dc172 100644 --- a/instrumentation/jetty/jetty-12.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/v12_0/Jetty12Singletons.java +++ b/instrumentation/jetty/jetty-12.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jetty/v12_0/Jetty12Singletons.java @@ -6,9 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.jetty.v12_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge; -import java.util.Optional; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Response; @@ -19,10 +18,10 @@ public final class Jetty12Singletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + JavaagentHttpServerInstrumenters.create( INSTRUMENTATION_NAME, new Jetty12HttpAttributesGetter(), - Optional.of(Jetty12TextMapGetter.INSTANCE), + Jetty12TextMapGetter.INSTANCE, builder -> builder.addContextCustomizer( (context, request, attributes) -> diff --git a/instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java b/instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java index 4dd2630f7fcc..609a6824b9e2 100644 --- a/instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java +++ b/instrumentation/liberty/liberty-dispatcher-20.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherSingletons.java @@ -6,8 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.liberty.dispatcher; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; -import java.util.Optional; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; public final class LibertyDispatcherSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.liberty-dispatcher-20.0"; @@ -16,10 +15,10 @@ public final class LibertyDispatcherSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.create( + JavaagentHttpServerInstrumenters.create( INSTRUMENTATION_NAME, new LibertyDispatcherHttpAttributesGetter(), - Optional.of(LibertyDispatcherRequestGetter.INSTANCE)); + LibertyDispatcherRequestGetter.INSTANCE); } public static Instrumenter instrumenter() { diff --git a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyServerSingletons.java b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyServerSingletons.java index ea0b36964b34..ba1f1e5e4e99 100644 --- a/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyServerSingletons.java +++ b/instrumentation/netty/netty-3.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v3_8/server/NettyServerSingletons.java @@ -7,9 +7,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.netty.common.internal.NettyErrorHolder; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.instrumentation.netty.v3_8.HttpRequestAndChannel; -import java.util.Optional; import org.jboss.netty.handler.codec.http.HttpResponse; final class NettyServerSingletons { @@ -18,10 +17,10 @@ final class NettyServerSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + JavaagentHttpServerInstrumenters.create( "io.opentelemetry.netty-3.8", new NettyHttpServerAttributesGetter(), - Optional.of(NettyHeadersGetter.INSTANCE), + NettyHeadersGetter.INSTANCE, builder -> builder.addContextCustomizer( (context, requestAndChannel, startAttributes) -> diff --git a/instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterBuilder.java b/instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterBuilder.java index a868619b043d..3ffe71f3227a 100644 --- a/instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterBuilder.java +++ b/instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterBuilder.java @@ -11,7 +11,6 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver; import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel; -import java.util.Optional; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at @@ -22,11 +21,8 @@ public class NettyClientInstrumenterBuilder private PeerServiceResolver peerServiceResolver; public NettyClientInstrumenterBuilder(String instrumentationName, OpenTelemetry openTelemetry) { - super( - instrumentationName, - openTelemetry, - new NettyHttpClientAttributesGetter(), - Optional.of(HttpRequestHeadersSetter.INSTANCE)); + super(instrumentationName, openTelemetry, new NettyHttpClientAttributesGetter()); + setHeaderSetter(HttpRequestHeadersSetter.INSTANCE); } @CanIgnoreReturnValue diff --git a/instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/NettyServerSingletons.java b/instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/NettyServerSingletons.java index 46a460744b74..66ecf192f0ae 100644 --- a/instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/NettyServerSingletons.java +++ b/instrumentation/netty/netty-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_0/server/NettyServerSingletons.java @@ -11,16 +11,15 @@ import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel; import io.opentelemetry.instrumentation.netty.v4.common.internal.server.HttpRequestHeadersGetter; import io.opentelemetry.instrumentation.netty.v4.common.internal.server.NettyHttpServerAttributesGetter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; -import java.util.Optional; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; public final class NettyServerSingletons { private static final Instrumenter INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + JavaagentHttpServerInstrumenters.create( "io.opentelemetry.netty-4.0", new NettyHttpServerAttributesGetter(), - Optional.of(HttpRequestHeadersGetter.INSTANCE), + HttpRequestHeadersGetter.INSTANCE, builder -> builder.addContextCustomizer( (context, requestAndChannel, startAttributes) -> NettyErrorHolder.init(context))); diff --git a/instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/PekkoHttpServerSingletons.java b/instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/PekkoHttpServerSingletons.java index 0b9fc624c3a0..3c865385e14d 100644 --- a/instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/PekkoHttpServerSingletons.java +++ b/instrumentation/pekko/pekko-http-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/pekkohttp/v1_0/server/PekkoHttpServerSingletons.java @@ -6,9 +6,8 @@ package io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.server; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.instrumentation.pekkohttp.v1_0.PekkoHttpUtil; -import java.util.Optional; import org.apache.pekko.http.scaladsl.model.HttpRequest; import org.apache.pekko.http.scaladsl.model.HttpResponse; @@ -18,10 +17,10 @@ public final class PekkoHttpServerSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.create( + JavaagentHttpServerInstrumenters.create( PekkoHttpUtil.instrumentationName(), new PekkoHttpServerAttributesGetter(), - Optional.of(PekkoHttpServerHeaders.INSTANCE)); + PekkoHttpServerHeaders.INSTANCE); } public static Instrumenter instrumenter() { diff --git a/instrumentation/restlet/restlet-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v1_1/RestletSingletons.java b/instrumentation/restlet/restlet-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v1_1/RestletSingletons.java index bc9aec17919d..153bdae98191 100644 --- a/instrumentation/restlet/restlet-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v1_1/RestletSingletons.java +++ b/instrumentation/restlet/restlet-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v1_1/RestletSingletons.java @@ -9,7 +9,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter; import io.opentelemetry.instrumentation.restlet.v1_1.RestletTelemetry; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath; import org.restlet.data.Request; import org.restlet.data.Response; @@ -20,7 +20,7 @@ public final class RestletSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.create( + JavaagentHttpServerInstrumenters.create( RestletTelemetry.builder(GlobalOpenTelemetry.get())); } diff --git a/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java b/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java index 260dd40a2ccf..ff57cf52a2e6 100644 --- a/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java +++ b/instrumentation/restlet/restlet-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/restlet/v2_0/RestletSingletons.java @@ -9,7 +9,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteGetter; import io.opentelemetry.instrumentation.restlet.v2_0.RestletTelemetry; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.ServletContextPath; import org.restlet.Request; import org.restlet.Response; @@ -17,8 +17,7 @@ public final class RestletSingletons { private static final Instrumenter INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.create( - RestletTelemetry.create(GlobalOpenTelemetry.get())); + JavaagentHttpServerInstrumenters.create(RestletTelemetry.create(GlobalOpenTelemetry.get())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java index a95faa4ad506..6bd6b26e7918 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletInstrumenterBuilder.java @@ -15,7 +15,7 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter; import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor; import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import java.util.ArrayList; import java.util.List; @@ -51,7 +51,7 @@ public Instrumenter, ServletResponseContext(accessor)); serverBuilder.setSpanNameExtractor(e -> spanNameExtractor); - return JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + return JavaagentHttpServerInstrumenters.create( serverBuilder, builder -> { if (ServletRequestParametersExtractor.enabled()) { diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc5InstrumentationAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc5InstrumentationAutoConfiguration.java index 513a085265d9..c4dad1e5ba22 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc5InstrumentationAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc5InstrumentationAutoConfiguration.java @@ -6,11 +6,9 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.webmvc; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation; -import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.CommonConfigUtil; +import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil; import io.opentelemetry.instrumentation.spring.webmvc.v5_3.SpringWebMvcTelemetry; -import io.opentelemetry.instrumentation.spring.webmvc.v5_3.SpringWebMvcTelemetryBuilder; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import javax.servlet.Filter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -27,9 +25,9 @@ public class SpringWebMvc5InstrumentationAutoConfiguration { @Bean Filter otelWebMvcFilter(OpenTelemetry openTelemetry, ConfigProperties config) { - SpringWebMvcTelemetryBuilder builder = SpringWebMvcTelemetry.builder(openTelemetry); - DefaultHttpServerInstrumenterBuilder.unwrapAndConfigure( - CommonConfigUtil.getCommonConfig(config), builder); - return builder.build().createServletFilter(); + return InstrumentationConfigUtil.configureBuilder( + config, SpringWebMvcTelemetry.builder(openTelemetry)) + .build() + .createServletFilter(); } } diff --git a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc6InstrumentationAutoConfiguration.java b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc6InstrumentationAutoConfiguration.java index 2289eeedb828..4749cb6ed142 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc6InstrumentationAutoConfiguration.java +++ b/instrumentation/spring/spring-boot-autoconfigure/src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/instrumentation/webmvc/SpringWebMvc6InstrumentationAutoConfiguration.java @@ -6,11 +6,9 @@ package io.opentelemetry.instrumentation.spring.autoconfigure.instrumentation.webmvc; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.spring.autoconfigure.internal.ConditionalOnEnabledInstrumentation; -import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.CommonConfigUtil; +import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.InstrumentationConfigUtil; import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetry; -import io.opentelemetry.instrumentation.spring.webmvc.v6_0.SpringWebMvcTelemetryBuilder; import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties; import jakarta.servlet.Filter; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -27,9 +25,9 @@ public class SpringWebMvc6InstrumentationAutoConfiguration { @Bean Filter otelWebMvcFilter(OpenTelemetry openTelemetry, ConfigProperties config) { - SpringWebMvcTelemetryBuilder builder = SpringWebMvcTelemetry.builder(openTelemetry); - DefaultHttpServerInstrumenterBuilder.unwrapAndConfigure( - CommonConfigUtil.getCommonConfig(config), builder); - return builder.build().createServletFilter(); + return InstrumentationConfigUtil.configureBuilder( + config, SpringWebMvcTelemetry.builder(openTelemetry)) + .build() + .createServletFilter(); } } diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterFactory.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterFactory.java index 4c1a80f49439..2d0dab360594 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterFactory.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatInstrumenterFactory.java @@ -6,11 +6,10 @@ package io.opentelemetry.javaagent.instrumentation.tomcat.common; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge; import io.opentelemetry.javaagent.instrumentation.servlet.ServletAccessor; import io.opentelemetry.javaagent.instrumentation.servlet.ServletErrorCauseExtractor; -import java.util.Optional; import org.apache.coyote.Request; import org.apache.coyote.Response; @@ -20,10 +19,10 @@ private TomcatInstrumenterFactory() {} public static Instrumenter create( String instrumentationName, ServletAccessor accessor) { - return JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + return JavaagentHttpServerInstrumenters.create( instrumentationName, new TomcatHttpAttributesGetter(), - Optional.of(TomcatRequestGetter.INSTANCE), + TomcatRequestGetter.INSTANCE, builder -> builder .setErrorCauseExtractor(new ServletErrorCauseExtractor<>(accessor)) diff --git a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java index 85f3e4e726b1..14c21b0aab58 100644 --- a/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java +++ b/instrumentation/undertow-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/undertow/UndertowSingletons.java @@ -6,11 +6,10 @@ package io.opentelemetry.javaagent.instrumentation.undertow; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenterBuilder; +import io.opentelemetry.javaagent.bootstrap.internal.JavaagentHttpServerInstrumenters; import io.opentelemetry.javaagent.bootstrap.servlet.AppServerBridge; import io.opentelemetry.javaagent.bootstrap.undertow.UndertowActiveHandlers; import io.undertow.server.HttpServerExchange; -import java.util.Optional; public final class UndertowSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.undertow-1.4"; @@ -19,10 +18,10 @@ public final class UndertowSingletons { static { INSTRUMENTER = - JavaagentHttpServerInstrumenterBuilder.createWithCustomizer( + JavaagentHttpServerInstrumenters.create( INSTRUMENTATION_NAME, new UndertowHttpAttributesGetter(), - Optional.of(UndertowExchangeGetter.INSTANCE), + UndertowExchangeGetter.INSTANCE, builder -> builder.addContextCustomizer( (context, request, attributes) -> { diff --git a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpClientInstrumenters.java b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpClientInstrumenters.java index 89091da03b48..9828968fc048 100644 --- a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpClientInstrumenters.java +++ b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpClientInstrumenters.java @@ -45,13 +45,13 @@ public static Instrumenter create( HttpClientAttributesGetter httpAttributesGetter, TextMapSetter headerSetter, Consumer> instrumenterBuilderConsumer) { - DefaultHttpClientInstrumenterBuilder DefaultHttpClientInstrumenterBuilder = + DefaultHttpClientInstrumenterBuilder defaultHttpClientTelemetryBuilder = new DefaultHttpClientInstrumenterBuilder<>( instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter); if (headerSetter != null) { - DefaultHttpClientInstrumenterBuilder.setHeaderSetter(headerSetter); + defaultHttpClientTelemetryBuilder.setHeaderSetter(headerSetter); } - return create(DefaultHttpClientInstrumenterBuilder, instrumenterBuilderConsumer); + return create(defaultHttpClientTelemetryBuilder, instrumenterBuilderConsumer); } private static Instrumenter create( diff --git a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenterBuilder.java b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java similarity index 74% rename from javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenterBuilder.java rename to javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java index ed6f5dd6d216..0e85630ed3c8 100644 --- a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenterBuilder.java +++ b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java @@ -11,41 +11,40 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter; -import java.util.Optional; import java.util.function.Consumer; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ -public final class JavaagentHttpServerInstrumenterBuilder { +public final class JavaagentHttpServerInstrumenters { - private JavaagentHttpServerInstrumenterBuilder() {} + private JavaagentHttpServerInstrumenters() {} public static Instrumenter create( String instrumentationName, HttpServerAttributesGetter httpAttributesGetter, - Optional> headerGetter) { - return createWithCustomizer( - instrumentationName, httpAttributesGetter, headerGetter, customizer -> {}); + TextMapGetter headerGetter) { + return create(instrumentationName, httpAttributesGetter, headerGetter, customizer -> {}); } public static Instrumenter create(Object builder) { - return createWithCustomizer(builder, customizer -> {}); + return create(builder, customizer -> {}); } - public static Instrumenter createWithCustomizer( + public static Instrumenter create( String instrumentationName, HttpServerAttributesGetter httpAttributesGetter, - Optional> headerGetter, + TextMapGetter headerGetter, Consumer> instrumenterBuilderConsumer) { - return createWithCustomizer( + return create( new DefaultHttpServerInstrumenterBuilder<>( - instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter), + instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter) + .setHeaderGetter(headerGetter), instrumenterBuilderConsumer); } - public static Instrumenter createWithCustomizer( + public static Instrumenter create( Object builder, Consumer> instrumenterBuilderConsumer) { return DefaultHttpServerInstrumenterBuilder.unwrapAndConfigure(