diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java index 6124bf249380..0ca29c76aefe 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java @@ -172,7 +172,7 @@ public DefaultHttpServerInstrumenterBuilder setBuilderCustomi } public Instrumenter build() { - InstrumenterBuilder builder = builder(); + InstrumenterBuilder builder = instrumenterBuilder(); if (headerGetter != null) { return builder.buildServerInstrumenter(headerGetter); @@ -180,7 +180,7 @@ public Instrumenter build() { return builder.buildInstrumenter(SpanKindExtractor.alwaysServer()); } - public InstrumenterBuilder builder() { + public InstrumenterBuilder instrumenterBuilder() { SpanNameExtractor spanNameExtractor = spanNameExtractorTransformer.apply(httpSpanNameExtractorBuilder.build()); @@ -199,11 +199,7 @@ public InstrumenterBuilder builder() { .addOperationMetrics(HttpServerExperimentalMetrics.get()); } builderCustomizer.accept(builder); - - if (headerGetter != null) { - return builder.buildServerInstrumenter(headerGetter); - } - return builder.buildInstrumenter(SpanKindExtractor.alwaysServer()); + return builder; } @CanIgnoreReturnValue diff --git a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerTracing.kt b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerTracing.kt index 99e364af89b5..661cb48dbead 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerTracing.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorServerTracing.kt @@ -40,7 +40,8 @@ class KtorServerTracing private constructor( DefaultHttpServerInstrumenterBuilder( INSTRUMENTATION_NAME, openTelemetry, - KtorHttpServerAttributesGetter.INSTANCE + KtorHttpServerAttributesGetter.INSTANCE, + null ) } @@ -111,7 +112,7 @@ class KtorServerTracing private constructor( } val instrumenter = InstrumenterUtil.buildUpstreamInstrumenter( - configuration.builder.builder(), + configuration.builder.instrumenterBuilder(), ApplicationRequestGetter, configuration.spanKindExtractor(SpanKindExtractor.alwaysServer()) ) diff --git a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/server/KtorServerTracing.kt b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/server/KtorServerTracing.kt index b6990763e34f..3992acb3b09f 100644 --- a/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/server/KtorServerTracing.kt +++ b/instrumentation/ktor/ktor-2.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v2_0/server/KtorServerTracing.kt @@ -234,7 +234,7 @@ class KtorServerTracing private constructor( require(configuration.isOpenTelemetryInitialized()) { "OpenTelemetry must be set" } val instrumenter = InstrumenterUtil.buildUpstreamInstrumenter( - configuration.serverBuilder.builder(), + configuration.serverBuilder.instrumenterBuilder(), ApplicationRequestGetter, configuration.spanKindExtractor(SpanKindExtractor.alwaysServer()) ) diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackTelemetryBuilder.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackTelemetryBuilder.java index 4139aa1dccca..5f0191ecaa10 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackTelemetryBuilder.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackTelemetryBuilder.java @@ -36,7 +36,10 @@ public final class RatpackTelemetryBuilder { .setHeaderSetter(RequestHeaderSetter.INSTANCE); serverBuilder = new DefaultHttpServerInstrumenterBuilder<>( - INSTRUMENTATION_NAME, openTelemetry, RatpackHttpAttributesGetter.INSTANCE, RatpackGetter.INSTANCE); + INSTRUMENTATION_NAME, + openTelemetry, + RatpackHttpAttributesGetter.INSTANCE, + RatpackGetter.INSTANCE); } /** @@ -151,7 +154,9 @@ public RatpackTelemetryBuilder setEmitExperimentalHttpServerMetrics( /** Sets custom client {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public RatpackTelemetryBuilder setClientSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function< + SpanNameExtractor, + ? extends SpanNameExtractor> clientSpanNameExtractor) { clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; diff --git a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java index 0f7630e5a9c4..3ff61af4a73f 100644 --- a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java +++ b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/RestletTelemetryBuilder.java @@ -95,7 +95,7 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public RestletTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; diff --git a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/RestletTelemetryBuilderFactory.java b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/RestletTelemetryBuilderFactory.java index a4a1f1cc2890..7ffac6aa5084 100644 --- a/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/RestletTelemetryBuilderFactory.java +++ b/instrumentation/restlet/restlet-1.1/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_1/internal/RestletTelemetryBuilderFactory.java @@ -22,7 +22,9 @@ private RestletTelemetryBuilderFactory() {} public static DefaultHttpServerInstrumenterBuilder create( OpenTelemetry openTelemetry) { return new DefaultHttpServerInstrumenterBuilder<>( - INSTRUMENTATION_NAME, openTelemetry, RestletHttpAttributesGetter.INSTANCE) - .setHeaderGetter(RestletHeadersGetter.INSTANCE); + INSTRUMENTATION_NAME, + openTelemetry, + RestletHttpAttributesGetter.INSTANCE, + RestletHeadersGetter.INSTANCE); } } diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java index 6c49897500ed..a933f52cdea4 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/RestletTelemetryBuilder.java @@ -95,7 +95,7 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public RestletTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java index 309149fe2845..9d2aa96f6915 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletTelemetryBuilderFactory.java @@ -20,7 +20,9 @@ private RestletTelemetryBuilderFactory() {} public static DefaultHttpServerInstrumenterBuilder create( OpenTelemetry openTelemetry) { return new DefaultHttpServerInstrumenterBuilder<>( - "io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE) - .setHeaderGetter(new RestletHeadersGetter()); + "io.opentelemetry.restlet-2.0", + openTelemetry, + RestletHttpAttributesGetter.INSTANCE, + new RestletHeadersGetter()); } } 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 224fb1687d6f..75875ecadde6 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 @@ -57,8 +57,10 @@ public Instrumenter, ServletResponseContext, ServletResponseContext> serverBuilder = new DefaultHttpServerInstrumenterBuilder<>( - instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter) - .setHeaderGetter(new ServletRequestGetter<>(accessor)); + instrumentationName, + GlobalOpenTelemetry.get(), + httpAttributesGetter, + new ServletRequestGetter<>(accessor)); serverBuilder.setSpanNameExtractor(e -> spanNameExtractor); return JavaagentHttpServerInstrumenters.create( diff --git a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java index 2b83cfcf261e..7b46b82c420b 100644 --- a/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java +++ b/javaagent-extension-api/src/main/java/io/opentelemetry/javaagent/bootstrap/internal/JavaagentHttpServerInstrumenters.java @@ -44,7 +44,7 @@ public static Instrumenter create( instrumenterBuilderConsumer); } - private static Instrumenter create( + public static Instrumenter create( DefaultHttpServerInstrumenterBuilder builder, Consumer> builderCustomizer) { return builder