From d8019d474431b66dad9552713313cb357e9f7566 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 8 Dec 2024 19:50:34 -0800 Subject: [PATCH] Simplify signatures --- .../opentelemetry-instrumentation-api.txt | 23 +++++++++- .../DefaultHttpClientInstrumenterBuilder.java | 12 ++--- .../DefaultHttpServerInstrumenterBuilder.java | 12 ++--- .../http/HttpClientTelemetryBuilder.java | 44 +++++++++++++++++++ .../http/HttpServerTelemetryBuilder.java | 44 +++++++++++++++++++ .../ApacheHttpClientTelemetryBuilder.java | 27 +++++++++--- .../ApacheHttpClient5TelemetryBuilder.java | 4 +- .../ApacheHttpClientTelemetryBuilder.java | 29 +++++++++--- .../v1_3/ArmeriaClientTelemetryBuilder.java | 20 ++++++--- .../v1_3/ArmeriaServerTelemetryBuilder.java | 20 ++++++--- .../armeria/v1_3/ArmeriaTelemetryBuilder.java | 16 +++---- .../JavaHttpClientTelemetryBuilder.java | 26 ++++++++--- .../v12_0/JettyClientTelemetryBuilder.java | 22 ++++++++-- .../v9_2/JettyClientTelemetryBuilder.java | 21 +++++++-- .../AbstractKtorClientTelemetryBuilder.kt | 2 +- .../v4_1/NettyClientTelemetryBuilder.java | 24 ++++++++-- .../v4_1/NettyServerTelemetryBuilder.java | 36 ++++++++++++++- .../okhttp/v3_0/OkHttpTelemetryBuilder.java | 26 ++++++++--- .../r2dbc/v1_0/R2dbcSingletons.java | 2 +- .../v1_7/RatpackClientTelemetryBuilder.java | 26 ++++++++--- .../v1_7/RatpackServerTelemetryBuilder.java | 23 ++++++++-- .../ratpack/v1_7/RatpackTelemetryBuilder.java | 7 +-- .../restlet/v1_1/RestletTelemetryBuilder.java | 19 +++++++- .../restlet/v2_0/RestletTelemetryBuilder.java | 20 ++++++++- .../web/v3_1/SpringWebTelemetryBuilder.java | 27 +++++++++--- .../SpringWebfluxClientTelemetryBuilder.java | 25 +++++++++-- .../SpringWebfluxServerTelemetryBuilder.java | 25 +++++++++-- .../v5_3/SpringWebfluxTelemetryBuilder.java | 8 +--- .../v5_3/SpringWebMvcTelemetryBuilder.java | 24 ++++++++-- .../v6_0/SpringWebMvcTelemetryBuilder.java | 24 ++++++++-- 30 files changed, 516 insertions(+), 122 deletions(-) create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientTelemetryBuilder.java create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerTelemetryBuilder.java diff --git a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt index c09bab2b8f36..6133992666dd 100644 --- a/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt +++ b/docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt @@ -1,2 +1,23 @@ Comparing source compatibility of opentelemetry-instrumentation-api-2.11.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.10.0.jar -No changes. \ No newline at end of file ++++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder (not serializable) + +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. + GENERIC TEMPLATES: +++ REQUEST:java.lang.Object, +++ RESPONSE:java.lang.Object + +++ NEW SUPERCLASS: java.lang.Object + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Object build() + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder setCapturedRequestHeaders(java.util.List) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder setCapturedResponseHeaders(java.util.List) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder setKnownMethods(java.util.Set) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder setSpanNameExtractor(java.util.function.Function,io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor>) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder setStatusExtractor(java.util.function.Function,io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor>) ++++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder (not serializable) + +++ CLASS FILE FORMAT VERSION: 52.0 <- n.a. + GENERIC TEMPLATES: +++ REQUEST:java.lang.Object, +++ RESPONSE:java.lang.Object + +++ NEW SUPERCLASS: java.lang.Object + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Object build() + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder setCapturedRequestHeaders(java.util.List) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder setCapturedResponseHeaders(java.util.List) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder setKnownMethods(java.util.Set) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder setSpanNameExtractor(java.util.function.Function,io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor>) + +++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder setStatusExtractor(java.util.function.Function,io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor>) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java index e74dd2e9f48c..28015cc841a2 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java @@ -50,9 +50,7 @@ public final class DefaultHttpClientInstrumenterBuilder { private final List> additionalExtractors = new ArrayList<>(); - private Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + private Function, SpanStatusExtractor> statusExtractorTransformer = Function.identity(); private final HttpClientAttributesExtractorBuilder httpAttributesExtractorBuilder; @@ -60,7 +58,7 @@ public final class DefaultHttpClientInstrumenterBuilder { private final HttpSpanNameExtractorBuilder httpSpanNameExtractorBuilder; @Nullable private final TextMapSetter headerSetter; - private Function, ? extends SpanNameExtractor> + private Function, ? extends SpanNameExtractor> spanNameExtractorTransformer = Function.identity(); private boolean emitExperimentalHttpClientMetrics = false; private Consumer> builderCustomizer = b -> {}; @@ -111,9 +109,7 @@ public DefaultHttpClientInstrumenterBuilder addAttributesExtr @CanIgnoreReturnValue public DefaultHttpClientInstrumenterBuilder setStatusExtractor( - Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + Function, SpanStatusExtractor> statusExtractor) { this.statusExtractorTransformer = statusExtractor; return this; @@ -180,7 +176,7 @@ public DefaultHttpClientInstrumenterBuilder setKnownMethods( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public DefaultHttpClientInstrumenterBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { this.spanNameExtractorTransformer = spanNameExtractorTransformer; return this; 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 caee6c007da7..0353041dac2e 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 @@ -46,16 +46,14 @@ public final class DefaultHttpServerInstrumenterBuilder { private final List> additionalExtractors = new ArrayList<>(); - private Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + private Function, SpanStatusExtractor> statusExtractorTransformer = Function.identity(); private final HttpServerAttributesExtractorBuilder httpAttributesExtractorBuilder; private final HttpSpanNameExtractorBuilder httpSpanNameExtractorBuilder; @Nullable private final TextMapGetter headerGetter; - private Function, ? extends SpanNameExtractor> + private Function, SpanNameExtractor> spanNameExtractorTransformer = Function.identity(); private final HttpServerRouteBuilder httpServerRouteBuilder; private final HttpServerAttributesGetter attributesGetter; @@ -109,9 +107,7 @@ public DefaultHttpServerInstrumenterBuilder addAttributesExtr @CanIgnoreReturnValue public DefaultHttpServerInstrumenterBuilder setStatusExtractor( - Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + Function, SpanStatusExtractor> statusExtractor) { this.statusExtractorTransformer = statusExtractor; return this; @@ -179,7 +175,7 @@ public DefaultHttpServerInstrumenterBuilder setKnownMethods( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public DefaultHttpServerInstrumenterBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { this.spanNameExtractorTransformer = spanNameExtractorTransformer; return this; diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientTelemetryBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientTelemetryBuilder.java new file mode 100644 index 000000000000..991e1ebe2656 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientTelemetryBuilder.java @@ -0,0 +1,44 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.semconv.http; + +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; +import java.util.List; +import java.util.Set; +import java.util.function.Function; + +public interface HttpClientTelemetryBuilder { + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder addAttributesExtractor( + AttributesExtractor attributesExtractor); + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder setCapturedRequestHeaders( + List requestHeaders); + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder setCapturedResponseHeaders( + List responseHeaders); + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder setKnownMethods(Set knownMethods); + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder setSpanNameExtractor( + Function, SpanNameExtractor> + spanNameExtractorTransformer); + + @CanIgnoreReturnValue + HttpClientTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer); + + Object build(); +} diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerTelemetryBuilder.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerTelemetryBuilder.java new file mode 100644 index 000000000000..23cc2a8ac9c6 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerTelemetryBuilder.java @@ -0,0 +1,44 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.semconv.http; + +import com.google.errorprone.annotations.CanIgnoreReturnValue; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; +import java.util.List; +import java.util.Set; +import java.util.function.Function; + +public interface HttpServerTelemetryBuilder { + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder addAttributesExtractor( + AttributesExtractor attributesExtractor); + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder setCapturedRequestHeaders( + List requestHeaders); + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder setCapturedResponseHeaders( + List responseHeaders); + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder setKnownMethods(Set knownMethods); + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder setSpanNameExtractor( + Function, SpanNameExtractor> + spanNameExtractorTransformer); + + @CanIgnoreReturnValue + HttpServerTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer); + + Object build(); +} diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java index e1e37727a90a..66701f56565c 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java @@ -11,14 +11,17 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import java.util.List; import java.util.Set; import java.util.function.Function; import org.apache.http.HttpResponse; /** A builder for {@link ApacheHttpClientTelemetry}. */ -public final class ApacheHttpClientTelemetryBuilder { +public final class ApacheHttpClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-httpclient-4.3"; private final DefaultHttpClientInstrumenterBuilder builder; @@ -50,10 +53,10 @@ public ApacheHttpClientTelemetryBuilder addAttributeExtractor( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor - attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -63,6 +66,7 @@ public ApacheHttpClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -74,6 +78,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List r * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -93,6 +98,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -117,16 +123,27 @@ public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + SpanNameExtractor, + SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link ApacheHttpClientTelemetry} configured with this {@link * ApacheHttpClientTelemetryBuilder}. diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.java b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.java index 889f24600b91..d340d7a60ae6 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.java @@ -112,8 +112,8 @@ public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics( @CanIgnoreReturnValue public ApacheHttpClient5TelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + SpanNameExtractor, + SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClientTelemetryBuilder.java b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClientTelemetryBuilder.java index b2c5bb7131db..3b9c9ebb8b8b 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClientTelemetryBuilder.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClientTelemetryBuilder.java @@ -11,14 +11,17 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import java.util.List; import java.util.Set; import java.util.function.Function; import org.apache.hc.core5.http.HttpResponse; /** A builder for {@link ApacheHttpClientTelemetry}. */ -public final class ApacheHttpClientTelemetryBuilder { +public final class ApacheHttpClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-httpclient-5.2"; private final DefaultHttpClientInstrumenterBuilder builder; @@ -35,10 +38,10 @@ public final class ApacheHttpClientTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue - public ApacheHttpClientTelemetryBuilder addAttributeExtractor( - AttributesExtractor - attributesExtractor) { + public ApacheHttpClientTelemetryBuilder addAttributesExtractor( + AttributesExtractor attributesExtractor) { builder.addAttributeExtractor(attributesExtractor); return this; } @@ -48,6 +51,7 @@ public ApacheHttpClientTelemetryBuilder addAttributeExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -59,6 +63,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List r * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -78,6 +83,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -85,16 +91,27 @@ public ApacheHttpClientTelemetryBuilder setKnownMethods(Set knownMethods } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + SpanNameExtractor, + SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + spanNameExtractorTransformer) { + builder.setStatusExtractor(spanNameExtractorTransformer); + return this; + } + /** * Can be used via the unstable method {@link * Experimental#setEmitExperimentalTelemetry(ApacheHttpClientTelemetryBuilder, boolean)}. diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaClientTelemetryBuilder.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaClientTelemetryBuilder.java index 57d6f5ce5d64..a1e218d2a953 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaClientTelemetryBuilder.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaClientTelemetryBuilder.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil; import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental; @@ -21,7 +22,8 @@ import java.util.Set; import java.util.function.Function; -public final class ArmeriaClientTelemetryBuilder { +public final class ArmeriaClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; @@ -34,11 +36,12 @@ public final class ArmeriaClientTelemetryBuilder { } /** Sets the status extractor for client spans. */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder setStatusExtractor( Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + SpanStatusExtractor, + SpanStatusExtractor> statusExtractor) { builder.setStatusExtractor(statusExtractor); return this; @@ -48,9 +51,10 @@ public ArmeriaClientTelemetryBuilder setStatusExtractor( * Adds an extra {@link AttributesExtractor} to invoke to set attributes to instrumented items. * The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributeExtractor(attributesExtractor); return this; } @@ -60,6 +64,7 @@ public ArmeriaClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -71,6 +76,7 @@ public ArmeriaClientTelemetryBuilder setCapturedRequestHeaders(List requ * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -90,6 +96,7 @@ public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(List res * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -97,11 +104,10 @@ public ArmeriaClientTelemetryBuilder setKnownMethods(Set knownMethods) { } /** Sets custom client {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public ArmeriaClientTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { builder.setSpanNameExtractor(clientSpanNameExtractor); return this; diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaServerTelemetryBuilder.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaServerTelemetryBuilder.java index 11fca59e7dcd..8704e0e7546b 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaServerTelemetryBuilder.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaServerTelemetryBuilder.java @@ -14,6 +14,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory; import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil; import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental; @@ -21,7 +22,8 @@ import java.util.Set; import java.util.function.Function; -public final class ArmeriaServerTelemetryBuilder { +public final class ArmeriaServerTelemetryBuilder + implements HttpServerTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; @@ -34,11 +36,12 @@ public final class ArmeriaServerTelemetryBuilder { } /** Sets the status extractor for server spans. */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder setStatusExtractor( Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + SpanStatusExtractor, + SpanStatusExtractor> statusExtractor) { builder.setStatusExtractor(statusExtractor); return this; @@ -48,9 +51,10 @@ public ArmeriaServerTelemetryBuilder setStatusExtractor( * Adds an extra {@link AttributesExtractor} to invoke to set attributes to instrumented items. * The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -60,6 +64,7 @@ public ArmeriaServerTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -71,6 +76,7 @@ public ArmeriaServerTelemetryBuilder setCapturedRequestHeaders(List requ * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -90,6 +96,7 @@ public ArmeriaServerTelemetryBuilder setCapturedResponseHeaders(List res * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -97,11 +104,10 @@ public ArmeriaServerTelemetryBuilder setKnownMethods(Set knownMethods) { } /** Sets custom server {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public ArmeriaServerTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> serverSpanNameExtractor) { builder.setSpanNameExtractor(serverSpanNameExtractor); return this; diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java index 5a900eb95c8c..1f424edbe7cf 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaTelemetryBuilder.java @@ -69,8 +69,8 @@ public ArmeriaTelemetryBuilder setStatusExtractor( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setClientStatusExtractor( Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + SpanStatusExtractor, + SpanStatusExtractor> statusExtractor) { clientBuilder.setStatusExtractor(statusExtractor); return this; @@ -85,8 +85,8 @@ public ArmeriaTelemetryBuilder setClientStatusExtractor( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setServerStatusExtractor( Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> + SpanStatusExtractor, + SpanStatusExtractor> statusExtractor) { serverBuilder.setStatusExtractor(statusExtractor); return this; @@ -270,9 +270,7 @@ public ArmeriaTelemetryBuilder setEmitExperimentalHttpServerMetrics( @Deprecated @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setClientSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; @@ -286,9 +284,7 @@ public ArmeriaTelemetryBuilder setClientSpanNameExtractor( @Deprecated @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setServerSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> serverSpanNameExtractor) { serverBuilder.setSpanNameExtractor(serverSpanNameExtractor); return this; diff --git a/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java index 72f93a20fdc2..d25d7f4bd819 100644 --- a/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java +++ b/instrumentation/java-http-client/library/src/main/java/io/opentelemetry/instrumentation/httpclient/JavaHttpClientTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.httpclient.internal.Experimental; import io.opentelemetry.instrumentation.httpclient.internal.HttpHeadersSetter; import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientInstrumenterBuilderFactory; @@ -20,7 +22,8 @@ import java.util.Set; import java.util.function.Function; -public final class JavaHttpClientTelemetryBuilder { +public final class JavaHttpClientTelemetryBuilder + implements HttpClientTelemetryBuilder> { private final DefaultHttpClientInstrumenterBuilder> builder; private final OpenTelemetry openTelemetry; @@ -48,9 +51,10 @@ public JavaHttpClientTelemetryBuilder addAttributeExtractor( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor> attributesExtractor) { + AttributesExtractor> attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -60,6 +64,7 @@ public JavaHttpClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -71,6 +76,7 @@ public JavaHttpClientTelemetryBuilder setCapturedRequestHeaders(List req * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -90,6 +96,7 @@ public JavaHttpClientTelemetryBuilder setCapturedResponseHeaders(List re * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -114,16 +121,25 @@ public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder> setStatusExtractor( + Function< + SpanStatusExtractor>, + SpanStatusExtractor>> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + public JavaHttpClientTelemetry build() { return new JavaHttpClientTelemetry( builder.build(), new HttpHeadersSetter(openTelemetry.getPropagators())); diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java index 92225b6a7b06..a1651e3b437b 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-12.0/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v12_0/JettyClientTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.Experimental; import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.JettyHttpClientInstrumenterBuilderFactory; import java.util.List; @@ -21,7 +23,8 @@ import org.eclipse.jetty.client.Response; import org.eclipse.jetty.util.ssl.SslContextFactory; -public final class JettyClientTelemetryBuilder { +public final class JettyClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private HttpClientTransport httpClientTransport; @@ -63,9 +66,10 @@ public JettyClientTelemetryBuilder addAttributeExtractor( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -75,6 +79,7 @@ public JettyClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -86,6 +91,7 @@ public JettyClientTelemetryBuilder setCapturedRequestHeaders(List reques * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -105,6 +111,7 @@ public JettyClientTelemetryBuilder setCapturedResponseHeaders(List respo * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -128,14 +135,23 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link JettyClientTelemetry} with the settings of this {@link * JettyClientTelemetryBuilder}. diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java index 7b30e832faf3..7ef1ee78d81a 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/JettyClientTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.Experimental; import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyHttpClientInstrumenterBuilderFactory; import java.util.List; @@ -22,7 +24,8 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; /** A builder of {@link JettyClientTelemetry}. */ -public final class JettyClientTelemetryBuilder { +public final class JettyClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private HttpClientTransport httpClientTransport; @@ -65,7 +68,7 @@ public JettyClientTelemetryBuilder addAttributeExtractor( */ @CanIgnoreReturnValue public JettyClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -75,6 +78,7 @@ public JettyClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -86,6 +90,7 @@ public JettyClientTelemetryBuilder setCapturedRequestHeaders(List reques * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -105,6 +110,7 @@ public JettyClientTelemetryBuilder setCapturedResponseHeaders(List respo * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -128,14 +134,23 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public JettyClientTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link JettyClientTelemetry} with the settings of this {@link * JettyClientTelemetryBuilder}. diff --git a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/client/AbstractKtorClientTelemetryBuilder.kt b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/client/AbstractKtorClientTelemetryBuilder.kt index eddeec494faa..cf75f76287c5 100644 --- a/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/client/AbstractKtorClientTelemetryBuilder.kt +++ b/instrumentation/ktor/ktor-2-common/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/client/AbstractKtorClientTelemetryBuilder.kt @@ -63,7 +63,7 @@ abstract class AbstractKtorClientTelemetryBuilder( clientBuilder.setKnownMethods(methods.toSet()) } - fun attributeExtractor(extractorBuilder: ExtractorBuilder.() -> Unit = {}) { + fun attributesExtractor(extractorBuilder: ExtractorBuilder.() -> Unit = {}) { val builder = ExtractorBuilder().apply(extractorBuilder).build() this.clientBuilder.addAttributeExtractor( object : AttributesExtractor { diff --git a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java index 961db9b3ba8e..d50baa935d21 100644 --- a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java +++ b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyClientTelemetryBuilder.java @@ -11,7 +11,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel; import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterBuilderFactory; import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory; @@ -22,7 +24,8 @@ import java.util.function.Function; /** A builder of {@link NettyClientTelemetry}. */ -public final class NettyClientTelemetryBuilder { +public final class NettyClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private boolean emitExperimentalTelemetry = false; @@ -49,6 +52,7 @@ public NettyClientTelemetryBuilder setEmitExperimentalHttpClientEvents( * * @param capturedRequestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public NettyClientTelemetryBuilder setCapturedRequestHeaders( List capturedRequestHeaders) { @@ -61,6 +65,7 @@ public NettyClientTelemetryBuilder setCapturedRequestHeaders( * * @param capturedResponseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public NettyClientTelemetryBuilder setCapturedResponseHeaders( List capturedResponseHeaders) { @@ -72,6 +77,7 @@ public NettyClientTelemetryBuilder setCapturedResponseHeaders( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public NettyClientTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -92,6 +98,7 @@ public NettyClientTelemetryBuilder addAttributesExtractor( * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public NettyClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -116,16 +123,25 @@ public NettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public NettyClientTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** Returns a new {@link NettyClientTelemetry} with the given configuration. */ public NettyClientTelemetry build() { return new NettyClientTelemetry( diff --git a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java index 6437a540b106..26d97f0bf896 100644 --- a/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java +++ b/instrumentation/netty/netty-4.1/library/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/NettyServerTelemetryBuilder.java @@ -9,7 +9,11 @@ import io.netty.handler.codec.http.HttpResponse; import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; 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; @@ -18,9 +22,11 @@ import io.opentelemetry.instrumentation.netty.v4_1.internal.server.NettyServerInstrumenterBuilderUtil; import java.util.List; import java.util.Set; +import java.util.function.Function; /** A builder of {@link NettyServerTelemetry}. */ -public final class NettyServerTelemetryBuilder { +public final class NettyServerTelemetryBuilder + implements HttpServerTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; @@ -40,6 +46,31 @@ public final class NettyServerTelemetryBuilder { HttpRequestHeadersGetter.INSTANCE); } + @Override + public HttpServerTelemetryBuilder addAttributesExtractor( + AttributesExtractor attributesExtractor) { + builder.addAttributesExtractor(attributesExtractor); + return this; + } + + @Override + public HttpServerTelemetryBuilder setSpanNameExtractor( + Function, SpanNameExtractor> + spanNameExtractorTransformer) { + builder.setSpanNameExtractor(spanNameExtractorTransformer); + return this; + } + + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Configures emission of experimental events. * @@ -57,6 +88,7 @@ public NettyServerTelemetryBuilder setEmitExperimentalHttpServerEvents( * * @param capturedRequestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public NettyServerTelemetryBuilder setCapturedRequestHeaders( List capturedRequestHeaders) { @@ -69,6 +101,7 @@ public NettyServerTelemetryBuilder setCapturedRequestHeaders( * * @param capturedResponseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public NettyServerTelemetryBuilder setCapturedResponseHeaders( List capturedResponseHeaders) { @@ -89,6 +122,7 @@ public NettyServerTelemetryBuilder setCapturedResponseHeaders( * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public NettyServerTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java index 4e71d07eab18..8c1299bd041f 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/OkHttpTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.Experimental; import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpClientInstrumenterBuilderFactory; import java.util.List; @@ -20,7 +22,8 @@ import okhttp3.Response; /** A builder of {@link OkHttpTelemetry}. */ -public final class OkHttpTelemetryBuilder { +public final class OkHttpTelemetryBuilder + implements HttpClientTelemetryBuilder { private final DefaultHttpClientInstrumenterBuilder builder; private final OpenTelemetry openTelemetry; @@ -48,9 +51,10 @@ public OkHttpTelemetryBuilder addAttributeExtractor( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public OkHttpTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -60,6 +64,7 @@ public OkHttpTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public OkHttpTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -71,6 +76,7 @@ public OkHttpTelemetryBuilder setCapturedRequestHeaders(List requestHead * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public OkHttpTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -90,6 +96,7 @@ public OkHttpTelemetryBuilder setCapturedResponseHeaders(List responseHe * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public OkHttpTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -113,16 +120,25 @@ public OkHttpTelemetryBuilder setEmitExperimentalHttpClientMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public OkHttpTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link OkHttpTelemetry} with the settings of this {@link OkHttpTelemetryBuilder}. */ diff --git a/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java b/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java index 36ebe81accbf..e733a77f8a0e 100644 --- a/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java +++ b/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java @@ -21,7 +21,7 @@ public final class R2dbcSingletons { .getBoolean( "otel.instrumentation.r2dbc.statement-sanitizer.enabled", AgentCommonConfig.get().isStatementSanitizationEnabled())) - .addAttributeExtractor( + .addAttributesExtractor( PeerServiceAttributesExtractor.create( R2dbcNetAttributesGetter.INSTANCE, AgentCommonConfig.get().getPeerServiceResolver())) diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackClientTelemetryBuilder.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackClientTelemetryBuilder.java index 95975fd4d01e..46760f700782 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackClientTelemetryBuilder.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackClientTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.Experimental; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.RatpackClientInstrumenterBuilderFactory; import java.util.List; @@ -20,7 +22,8 @@ import ratpack.http.client.RequestSpec; /** A builder for {@link RatpackClientTelemetry}. */ -public final class RatpackClientTelemetryBuilder { +public final class RatpackClientTelemetryBuilder + implements HttpClientTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.ratpack-1.7"; @@ -30,9 +33,10 @@ public final class RatpackClientTelemetryBuilder { builder = RatpackClientInstrumenterBuilderFactory.create(INSTRUMENTATION_NAME, openTelemetry); } + @Override @CanIgnoreReturnValue public RatpackClientTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributeExtractor(attributesExtractor); return this; } @@ -42,6 +46,7 @@ public RatpackClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RatpackClientTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -53,6 +58,7 @@ public RatpackClientTelemetryBuilder setCapturedRequestHeaders(List requ * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RatpackClientTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -72,6 +78,7 @@ public RatpackClientTelemetryBuilder setCapturedResponseHeaders(List res * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public RatpackClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -79,16 +86,25 @@ public RatpackClientTelemetryBuilder setKnownMethods(Set knownMethods) { } /** Sets custom client {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public RatpackClientTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { builder.setSpanNameExtractor(clientSpanNameExtractor); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Can be used via the unstable method {@link * Experimental#setEmitExperimentalTelemetry(RatpackClientTelemetryBuilder, boolean)}. diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackServerTelemetryBuilder.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackServerTelemetryBuilder.java index f40300fde907..6e6a405d5370 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackServerTelemetryBuilder.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/v1_7/RatpackServerTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.Experimental; import io.opentelemetry.instrumentation.ratpack.v1_7.internal.RatpackServerInstrumenterBuilderFactory; import java.util.List; @@ -20,7 +22,8 @@ import ratpack.http.Response; /** A builder for {@link RatpackServerTelemetry}. */ -public final class RatpackServerTelemetryBuilder { +public final class RatpackServerTelemetryBuilder + implements HttpServerTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.ratpack-1.7"; @@ -34,9 +37,10 @@ public final class RatpackServerTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. The {@link AttributesExtractor} will be executed after all default extractors. */ + @Override @CanIgnoreReturnValue public RatpackServerTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -46,6 +50,7 @@ public RatpackServerTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RatpackServerTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -57,6 +62,7 @@ public RatpackServerTelemetryBuilder setCapturedRequestHeaders(List requ * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RatpackServerTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -76,6 +82,7 @@ public RatpackServerTelemetryBuilder setCapturedResponseHeaders(List res * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public RatpackServerTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -83,14 +90,22 @@ public RatpackServerTelemetryBuilder setKnownMethods(Set knownMethods) { } /** Sets custom server {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public RatpackServerTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> - serverSpanNameExtractor) { + Function, SpanNameExtractor> serverSpanNameExtractor) { builder.setSpanNameExtractor(serverSpanNameExtractor); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Can be used via the unstable method {@link * Experimental#setEmitExperimentalTelemetry(RatpackServerTelemetryBuilder, boolean)}. 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 47f8aa063643..643b386b3846 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 @@ -188,9 +188,7 @@ public RatpackTelemetryBuilder setEmitExperimentalHttpServerMetrics( @Deprecated @CanIgnoreReturnValue public RatpackTelemetryBuilder setClientSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; @@ -204,8 +202,7 @@ public RatpackTelemetryBuilder setClientSpanNameExtractor( @Deprecated @CanIgnoreReturnValue public RatpackTelemetryBuilder setServerSpanNameExtractor( - Function, ? extends SpanNameExtractor> - serverSpanNameExtractor) { + Function, SpanNameExtractor> serverSpanNameExtractor) { serverBuilder.setSpanNameExtractor(serverSpanNameExtractor); 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 b7e40595ea9e..410fada89b67 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 @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.restlet.v1_1.internal.Experimental; import io.opentelemetry.instrumentation.restlet.v1_1.internal.RestletTelemetryBuilderFactory; import java.util.List; @@ -20,7 +22,8 @@ import org.restlet.data.Response; /** A builder of {@link RestletTelemetry}. */ -public final class RestletTelemetryBuilder { +public final class RestletTelemetryBuilder + implements HttpServerTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; @@ -32,6 +35,7 @@ public final class RestletTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -44,6 +48,7 @@ public RestletTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -55,6 +60,7 @@ public RestletTelemetryBuilder setCapturedRequestHeaders(List requestHea * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -74,6 +80,7 @@ public RestletTelemetryBuilder setCapturedResponseHeaders(List responseH * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -99,12 +106,20 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public RestletTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link RestletTelemetry} with the settings of this {@link * RestletTelemetryBuilder}. 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 e705e875b4fc..491caf1a275d 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 @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.restlet.v2_0.internal.Experimental; import io.opentelemetry.instrumentation.restlet.v2_0.internal.RestletTelemetryBuilderFactory; import java.util.List; @@ -20,7 +22,8 @@ import org.restlet.Response; /** A builder of {@link RestletTelemetry}. */ -public final class RestletTelemetryBuilder { +public final class RestletTelemetryBuilder + implements HttpServerTelemetryBuilder { private final DefaultHttpServerInstrumenterBuilder builder; @@ -32,6 +35,7 @@ public final class RestletTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -44,6 +48,7 @@ public RestletTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -55,6 +60,7 @@ public RestletTelemetryBuilder setCapturedRequestHeaders(List requestHea * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -74,6 +80,7 @@ public RestletTelemetryBuilder setCapturedResponseHeaders(List responseH * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -97,14 +104,23 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics( } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public RestletTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function, SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Returns a new {@link RestletTelemetry} with the settings of this {@link * RestletTelemetryBuilder}. diff --git a/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java index e8a7a2e7fd36..b8c7c90b53d4 100644 --- a/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java +++ b/instrumentation/spring/spring-web/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/v3_1/SpringWebTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.spring.web.v3_1.internal.Experimental; import io.opentelemetry.instrumentation.spring.web.v3_1.internal.WebTelemetryUtil; import java.util.List; @@ -20,7 +22,9 @@ import org.springframework.http.client.ClientHttpResponse; /** A builder of {@link SpringWebTelemetry}. */ -public final class SpringWebTelemetryBuilder { +public final class SpringWebTelemetryBuilder + implements HttpClientTelemetryBuilder { + private static final String INSTRUMENTATION_NAME = "io.opentelemetry.spring-web-3.1"; private final DefaultHttpClientInstrumenterBuilder builder; @@ -59,9 +63,10 @@ public SpringWebTelemetryBuilder addAttributeExtractor( * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public SpringWebTelemetryBuilder addAttributesExtractor( - AttributesExtractor attributesExtractor) { + AttributesExtractor attributesExtractor) { builder.addAttributesExtractor(attributesExtractor); return this; } @@ -71,6 +76,7 @@ public SpringWebTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -82,6 +88,7 @@ public SpringWebTelemetryBuilder setCapturedRequestHeaders(List requestH * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -89,16 +96,25 @@ public SpringWebTelemetryBuilder setCapturedResponseHeaders(List respons } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public SpringWebTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Configures the instrumentation to recognize an alternative set of HTTP request methods. * @@ -112,6 +128,7 @@ public SpringWebTelemetryBuilder setSpanNameExtractor( * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public SpringWebTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxClientTelemetryBuilder.java b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxClientTelemetryBuilder.java index 1255d3e729f0..4002e659620f 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxClientTelemetryBuilder.java +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxClientTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder; import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.Experimental; import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.SpringWebfluxBuilderUtil; import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.WebClientHttpAttributesGetter; @@ -21,7 +23,9 @@ import org.springframework.web.reactive.function.client.ClientResponse; /** A builder of {@link SpringWebfluxClientTelemetry}. */ -public final class SpringWebfluxClientTelemetryBuilder { +public final class SpringWebfluxClientTelemetryBuilder + implements HttpClientTelemetryBuilder { + private static final String INSTRUMENTATION_NAME = "io.opentelemetry.spring-webflux-5.3"; private final DefaultHttpClientInstrumenterBuilder builder; @@ -42,6 +46,7 @@ public final class SpringWebfluxClientTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items for WebClient. */ + @Override @CanIgnoreReturnValue public SpringWebfluxClientTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -54,6 +59,7 @@ public SpringWebfluxClientTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebfluxClientTelemetryBuilder setCapturedRequestHeaders( List requestHeaders) { @@ -66,6 +72,7 @@ public SpringWebfluxClientTelemetryBuilder setCapturedRequestHeaders( * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebfluxClientTelemetryBuilder setCapturedResponseHeaders( List responseHeaders) { @@ -86,6 +93,7 @@ public SpringWebfluxClientTelemetryBuilder setCapturedResponseHeaders( * @param knownMethods A set of recognized HTTP request methods. * @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public SpringWebfluxClientTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -93,16 +101,25 @@ public SpringWebfluxClientTelemetryBuilder setKnownMethods(Set knownMeth } /** Sets custom client {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public SpringWebfluxClientTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { builder.setSpanNameExtractor(clientSpanNameExtractor); return this; } + @Override + public HttpClientTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Can be used via the unstable method {@link * Experimental#setEmitExperimentalTelemetry(SpringWebfluxClientTelemetryBuilder, boolean)}. diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxServerTelemetryBuilder.java b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxServerTelemetryBuilder.java index 7624b2c314db..605b65adda8b 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxServerTelemetryBuilder.java +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxServerTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.Experimental; import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.SpringWebfluxBuilderUtil; import java.util.List; @@ -19,7 +21,9 @@ import org.springframework.web.server.ServerWebExchange; /** A builder of {@link SpringWebfluxServerTelemetry}. */ -public final class SpringWebfluxServerTelemetryBuilder { +public final class SpringWebfluxServerTelemetryBuilder + implements HttpServerTelemetryBuilder { + private static final String INSTRUMENTATION_NAME = "io.opentelemetry.spring-webflux-5.3"; private final DefaultHttpServerInstrumenterBuilder builder; @@ -41,6 +45,7 @@ public final class SpringWebfluxServerTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public SpringWebfluxServerTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -54,6 +59,7 @@ public SpringWebfluxServerTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebfluxServerTelemetryBuilder setCapturedRequestHeaders( List requestHeaders) { @@ -67,6 +73,7 @@ public SpringWebfluxServerTelemetryBuilder setCapturedRequestHeaders( * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebfluxServerTelemetryBuilder setCapturedResponseHeaders( List responseHeaders) { @@ -87,6 +94,7 @@ public SpringWebfluxServerTelemetryBuilder setCapturedResponseHeaders( * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public SpringWebfluxServerTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); @@ -94,16 +102,25 @@ public SpringWebfluxServerTelemetryBuilder setKnownMethods(Set knownMeth } /** Sets custom server {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public SpringWebfluxServerTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> serverSpanNameExtractor) { builder.setSpanNameExtractor(serverSpanNameExtractor); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Can be used via the unstable method {@link * Experimental#setEmitExperimentalTelemetry(SpringWebfluxServerTelemetryBuilder, boolean)}. diff --git a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxTelemetryBuilder.java b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxTelemetryBuilder.java index 678f83608a22..713f5b6cac36 100644 --- a/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxTelemetryBuilder.java +++ b/instrumentation/spring/spring-webflux/spring-webflux-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/v5_3/SpringWebfluxTelemetryBuilder.java @@ -209,9 +209,7 @@ public SpringWebfluxTelemetryBuilder setEmitExperimentalHttpServerTelemetry( @Deprecated @CanIgnoreReturnValue public SpringWebfluxTelemetryBuilder setClientSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> clientSpanNameExtractor) { clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; @@ -226,9 +224,7 @@ public SpringWebfluxTelemetryBuilder setClientSpanNameExtractor( @Deprecated @CanIgnoreReturnValue public SpringWebfluxTelemetryBuilder setServerSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> serverSpanNameExtractor) { serverBuilder.setSpanNameExtractor(serverSpanNameExtractor); return this; diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java index cef84ec085e0..6c8bd22b4a06 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.spring.webmvc.v5_3.internal.Experimental; import io.opentelemetry.instrumentation.spring.webmvc.v5_3.internal.SpringMvcBuilderUtil; import java.util.List; @@ -20,7 +22,8 @@ import javax.servlet.http.HttpServletResponse; /** A builder of {@link SpringWebMvcTelemetry}. */ -public final class SpringWebMvcTelemetryBuilder { +public final class SpringWebMvcTelemetryBuilder + implements HttpServerTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.spring-webmvc-5.3"; @@ -44,6 +47,7 @@ public final class SpringWebMvcTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -56,6 +60,7 @@ public SpringWebMvcTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -67,6 +72,7 @@ public SpringWebMvcTelemetryBuilder setCapturedRequestHeaders(List reque * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -74,16 +80,25 @@ public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List resp } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractor) { builder.setSpanNameExtractor(spanNameExtractor); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Configures the instrumentation to recognize an alternative set of HTTP request methods. * @@ -97,6 +112,7 @@ public SpringWebMvcTelemetryBuilder setSpanNameExtractor( * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods); diff --git a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java index 0f4b82cd64c6..51b325e9adb5 100644 --- a/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java +++ b/instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v6_0/SpringWebMvcTelemetryBuilder.java @@ -10,7 +10,9 @@ import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; +import io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder; import io.opentelemetry.instrumentation.spring.webmvc.v6_0.internal.Experimental; import io.opentelemetry.instrumentation.spring.webmvc.v6_0.internal.SpringMvcBuilderUtil; import jakarta.servlet.http.HttpServletRequest; @@ -20,7 +22,8 @@ import java.util.function.Function; /** A builder of {@link SpringWebMvcTelemetry}. */ -public final class SpringWebMvcTelemetryBuilder { +public final class SpringWebMvcTelemetryBuilder + implements HttpServerTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.spring-webmvc-6.0"; private final DefaultHttpServerInstrumenterBuilder @@ -43,6 +46,7 @@ public final class SpringWebMvcTelemetryBuilder { * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder addAttributesExtractor( AttributesExtractor attributesExtractor) { @@ -55,6 +59,7 @@ public SpringWebMvcTelemetryBuilder addAttributesExtractor( * * @param requestHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setCapturedRequestHeaders(List requestHeaders) { builder.setCapturedRequestHeaders(requestHeaders); @@ -66,6 +71,7 @@ public SpringWebMvcTelemetryBuilder setCapturedRequestHeaders(List reque * * @param responseHeaders A list of HTTP header names. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List responseHeaders) { builder.setCapturedResponseHeaders(responseHeaders); @@ -73,16 +79,25 @@ public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List resp } /** Sets custom {@link SpanNameExtractor} via transform function. */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setSpanNameExtractor( - Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + Function, SpanNameExtractor> spanNameExtractor) { builder.setSpanNameExtractor(spanNameExtractor); return this; } + @Override + public HttpServerTelemetryBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + SpanStatusExtractor> + statusExtractorTransformer) { + builder.setStatusExtractor(statusExtractorTransformer); + return this; + } + /** * Configures the instrumentation to recognize an alternative set of HTTP request methods. * @@ -96,6 +111,7 @@ public SpringWebMvcTelemetryBuilder setSpanNameExtractor( * @param knownMethods A set of recognized HTTP request methods. * @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set) */ + @Override @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setKnownMethods(Set knownMethods) { builder.setKnownMethods(knownMethods);