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 50f73aa48069..72ce1b77a701 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 @@ -7,6 +7,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.context.propagation.TextMapSetter; import io.opentelemetry.instrumentation.api.incubator.config.internal.CommonConfig; import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpClientExperimentalMetrics; @@ -18,6 +19,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter; @@ -39,18 +41,25 @@ */ public final class DefaultHttpClientInstrumenterBuilder { + // copied from PeerIncubatingAttributes + private static final AttributeKey PEER_SERVICE = AttributeKey.stringKey("peer.service"); + private final String instrumentationName; private final OpenTelemetry openTelemetry; private final List> additionalExtractors = new ArrayList<>(); + private Function< + SpanStatusExtractor, + ? extends SpanStatusExtractor> + statusExtractorTransformer = Function.identity(); private final HttpClientAttributesExtractorBuilder httpAttributesExtractorBuilder; private final HttpClientAttributesGetter attributesGetter; private final HttpSpanNameExtractorBuilder httpSpanNameExtractorBuilder; @Nullable private TextMapSetter headerSetter; - private Function, ? extends SpanNameExtractor> + private Function, ? extends SpanNameExtractor> spanNameExtractorTransformer = Function.identity(); private boolean emitExperimentalHttpClientMetrics = false; private Consumer> builderCustomizer = b -> {}; @@ -77,6 +86,16 @@ public DefaultHttpClientInstrumenterBuilder addAttributeExtra return this; } + @CanIgnoreReturnValue + public DefaultHttpClientInstrumenterBuilder setStatusExtractor( + Function< + SpanStatusExtractor, + ? extends SpanStatusExtractor> + statusExtractor) { + this.statusExtractorTransformer = statusExtractor; + return this; + } + /** * Configures the HTTP request headers that will be captured as span attributes. * @@ -145,7 +164,7 @@ public DefaultHttpClientInstrumenterBuilder setHeaderSetter( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public DefaultHttpClientInstrumenterBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { this.spanNameExtractorTransformer = spanNameExtractorTransformer; return this; @@ -159,6 +178,13 @@ public DefaultHttpClientInstrumenterBuilder setPeerServiceRes HttpClientPeerServiceAttributesExtractor.create(attributesGetter, peerServiceResolver)); } + /** Sets the {@code peer.service} attribute for http client spans. */ + @CanIgnoreReturnValue + public DefaultHttpClientInstrumenterBuilder setPeerService( + String peerService) { + return addAttributeExtractor(AttributesExtractor.constant(PEER_SERVICE, peerService)); + } + @CanIgnoreReturnValue public DefaultHttpClientInstrumenterBuilder setBuilderCustomizer( Consumer> builderCustomizer) { @@ -174,7 +200,8 @@ public Instrumenter build() { InstrumenterBuilder builder = Instrumenter.builder( openTelemetry, instrumentationName, spanNameExtractor) - .setSpanStatusExtractor(HttpSpanStatusExtractor.create(attributesGetter)) + .setSpanStatusExtractor( + statusExtractorTransformer.apply(HttpSpanStatusExtractor.create(attributesGetter))) .addAttributesExtractor(httpAttributesExtractorBuilder.build()) .addAttributesExtractors(additionalExtractors) .addOperationMetrics(HttpClientMetrics.get()); 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 b229a7126e48..b3c7976f6c8a 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 @@ -54,7 +54,7 @@ public final class DefaultHttpServerInstrumenterBuilder { private final HttpSpanNameExtractorBuilder httpSpanNameExtractorBuilder; @Nullable private TextMapGetter headerGetter; - private Function, ? extends SpanNameExtractor> + private Function, ? extends SpanNameExtractor> spanNameExtractorTransformer = Function.identity(); private final HttpServerRouteBuilder httpServerRouteBuilder; private final HttpServerAttributesGetter attributesGetter; @@ -162,7 +162,7 @@ public DefaultHttpServerInstrumenterBuilder setHeaderGetter( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public DefaultHttpServerInstrumenterBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { this.spanNameExtractorTransformer = spanNameExtractorTransformer; return this; 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 3526ca01436a..7508931128b1 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 @@ -98,7 +98,7 @@ public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( @CanIgnoreReturnValue public ApacheHttpClientTelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, + SpanNameExtractor, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); 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 e9a5eb273de0..b9b98eb5d4a6 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 @@ -100,7 +100,7 @@ public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics( @CanIgnoreReturnValue public ApacheHttpClient5TelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, + SpanNameExtractor, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); diff --git a/instrumentation/armeria/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java b/instrumentation/armeria/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java index 8f4800ebca34..4845c528e7e1 100644 --- a/instrumentation/armeria/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java +++ b/instrumentation/armeria/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/ArmeriaSingletons.java @@ -8,9 +8,10 @@ import com.linecorp.armeria.client.HttpClient; import com.linecorp.armeria.server.HttpService; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpClientPeerServiceAttributesExtractor; +import io.opentelemetry.instrumentation.api.incubator.config.internal.CommonConfig; import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetry; -import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter; +import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetryBuilder; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import java.util.function.Function; @@ -22,28 +23,15 @@ public final class ArmeriaSingletons { public static final Function SERVER_DECORATOR; static { - ArmeriaTelemetry telemetry = - ArmeriaTelemetry.builder(GlobalOpenTelemetry.get()) - .setCapturedClientRequestHeaders(AgentCommonConfig.get().getClientRequestHeaders()) - .setCapturedClientResponseHeaders(AgentCommonConfig.get().getClientResponseHeaders()) - .setCapturedServerRequestHeaders(AgentCommonConfig.get().getServerRequestHeaders()) - .setCapturedServerResponseHeaders(AgentCommonConfig.get().getServerResponseHeaders()) - .setKnownMethods(AgentCommonConfig.get().getKnownHttpRequestMethods()) - .addClientAttributeExtractor( - HttpClientPeerServiceAttributesExtractor.create( - ArmeriaHttpClientAttributesGetter.INSTANCE, - AgentCommonConfig.get().getPeerServiceResolver())) - .setEmitExperimentalHttpClientMetrics( - AgentCommonConfig.get().shouldEmitExperimentalHttpClientTelemetry()) - .setEmitExperimentalHttpServerMetrics( - AgentCommonConfig.get().shouldEmitExperimentalHttpServerTelemetry()) - .build(); + ArmeriaTelemetryBuilder builder = ArmeriaTelemetry.builder(GlobalOpenTelemetry.get()); + CommonConfig config = AgentCommonConfig.get(); + ArmeriaInstrumenterBuilderUtil.getClientBuilderExtractor().apply(builder).configure(config); + ArmeriaInstrumenterBuilderUtil.getServerBuilderExtractor().apply(builder).configure(config); + ArmeriaTelemetry telemetry = builder.build(); CLIENT_DECORATOR = telemetry.newClientDecorator(); Function libraryDecorator = - telemetry - .newServiceDecorator() - .compose(service -> new ResponseCustomizingDecorator(service)); + telemetry.newServiceDecorator().compose(ResponseCustomizingDecorator::new); SERVER_DECORATOR = service -> new ServerDecorator(service, libraryDecorator.apply(service)); } 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 d39d8dcbb47a..5d6a17eb6586 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 @@ -11,98 +11,92 @@ import com.linecorp.armeria.common.logging.RequestLog; import com.linecorp.armeria.server.ServiceRequestContext; import io.opentelemetry.api.OpenTelemetry; -import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpClientExperimentalMetrics; -import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpExperimentalAttributesExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.http.HttpServerExperimentalMetrics; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor; -import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder; -import io.opentelemetry.instrumentation.api.semconv.http.HttpClientMetrics; -import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractor; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder; -import io.opentelemetry.instrumentation.api.semconv.http.HttpServerMetrics; -import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRoute; -import io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBuilder; -import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractor; -import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder; -import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor; -import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter; -import java.util.ArrayList; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory; +import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil; import java.util.List; import java.util.Set; import java.util.function.Function; -import java.util.stream.Stream; -import javax.annotation.Nullable; public final class ArmeriaTelemetryBuilder { - private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3"; - // copied from PeerIncubatingAttributes - private static final AttributeKey PEER_SERVICE = AttributeKey.stringKey("peer.service"); + private final DefaultHttpClientInstrumenterBuilder + clientBuilder; + private final DefaultHttpServerInstrumenterBuilder + serverBuilder; - private final OpenTelemetry openTelemetry; - @Nullable private String peerService; - private boolean emitExperimentalHttpClientMetrics = false; - private boolean emitExperimentalHttpServerMetrics = false; - - private final List> - additionalExtractors = new ArrayList<>(); - private final List> - additionalClientExtractors = new ArrayList<>(); - - private final HttpClientAttributesExtractorBuilder - httpClientAttributesExtractorBuilder = - HttpClientAttributesExtractor.builder(ArmeriaHttpClientAttributesGetter.INSTANCE); - private final HttpServerAttributesExtractorBuilder - httpServerAttributesExtractorBuilder = - HttpServerAttributesExtractor.builder(ArmeriaHttpServerAttributesGetter.INSTANCE); - - private final HttpSpanNameExtractorBuilder httpClientSpanNameExtractorBuilder = - HttpSpanNameExtractor.builder(ArmeriaHttpClientAttributesGetter.INSTANCE); - private final HttpSpanNameExtractorBuilder httpServerSpanNameExtractorBuilder = - HttpSpanNameExtractor.builder(ArmeriaHttpServerAttributesGetter.INSTANCE); - private Function< - SpanNameExtractor, ? extends SpanNameExtractor> - clientSpanNameExtractorTransformer = Function.identity(); - private Function< - SpanNameExtractor, ? extends SpanNameExtractor> - serverSpanNameExtractorTransformer = Function.identity(); - - private final HttpServerRouteBuilder httpServerRouteBuilder = - HttpServerRoute.builder(ArmeriaHttpServerAttributesGetter.INSTANCE); - - private Function< - SpanStatusExtractor, - ? extends SpanStatusExtractor> - statusExtractorTransformer = Function.identity(); + static { + ArmeriaInstrumenterBuilderUtil.setClientBuilderExtractor( + ArmeriaTelemetryBuilder::getClientBuilder); + ArmeriaInstrumenterBuilderUtil.setServerBuilderExtractor( + ArmeriaTelemetryBuilder::getServerBuilder); + } ArmeriaTelemetryBuilder(OpenTelemetry openTelemetry) { - this.openTelemetry = openTelemetry; + clientBuilder = ArmeriaInstrumenterBuilderFactory.getClientBuilder(openTelemetry); + serverBuilder = ArmeriaInstrumenterBuilderFactory.getServerBuilder(openTelemetry); } + /** + * Sets the status extractor for both client and server spans. + * + * @deprecated Use {@link #setClientStatusExtractor(Function)} or {@link + * #setServerStatusExtractor(Function)} instead. + */ + @Deprecated + @SuppressWarnings({"unchecked", "rawtypes"}) @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setStatusExtractor( Function< SpanStatusExtractor, ? extends SpanStatusExtractor> statusExtractor) { - this.statusExtractorTransformer = statusExtractor; + clientBuilder.setStatusExtractor((Function) statusExtractor); + serverBuilder.setStatusExtractor((Function) statusExtractor); + return this; + } + + /** Sets the status extractor for client spans. */ + @CanIgnoreReturnValue + public ArmeriaTelemetryBuilder setClientStatusExtractor( + Function< + SpanStatusExtractor, + ? extends SpanStatusExtractor> + statusExtractor) { + clientBuilder.setStatusExtractor(statusExtractor); + return this; + } + + /** Sets the status extractor for server spans. */ + @CanIgnoreReturnValue + public ArmeriaTelemetryBuilder setServerStatusExtractor( + Function< + SpanStatusExtractor, + ? extends SpanStatusExtractor> + statusExtractor) { + serverBuilder.setStatusExtractor(statusExtractor); return this; } /** * Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented * items. The {@link AttributesExtractor} will be executed after all default extractors. + * + * @deprecated Use {@link #addClientAttributeExtractor(AttributesExtractor)} or {@link + * #addServerAttributeExtractor(AttributesExtractor)} instead. */ + @Deprecated @CanIgnoreReturnValue public ArmeriaTelemetryBuilder addAttributeExtractor( AttributesExtractor attributesExtractor) { - additionalExtractors.add(attributesExtractor); + clientBuilder.addAttributeExtractor(attributesExtractor); + serverBuilder.addAttributesExtractor(attributesExtractor); return this; } @@ -114,14 +108,26 @@ public ArmeriaTelemetryBuilder addAttributeExtractor( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder addClientAttributeExtractor( AttributesExtractor attributesExtractor) { - additionalClientExtractors.add(attributesExtractor); + clientBuilder.addAttributeExtractor(attributesExtractor); + return this; + } + + /** + * Adds an extra server-only {@link AttributesExtractor} to invoke to set attributes to + * instrumented items. The {@link AttributesExtractor} will be executed after all default + * extractors. + */ + @CanIgnoreReturnValue + public ArmeriaTelemetryBuilder addServerAttributeExtractor( + AttributesExtractor attributesExtractor) { + serverBuilder.addAttributesExtractor(attributesExtractor); return this; } /** Sets the {@code peer.service} attribute for http client spans. */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setPeerService(String peerService) { - this.peerService = peerService; + clientBuilder.setPeerService(peerService); return this; } @@ -132,7 +138,7 @@ public ArmeriaTelemetryBuilder setPeerService(String peerService) { */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setCapturedClientRequestHeaders(List requestHeaders) { - httpClientAttributesExtractorBuilder.setCapturedRequestHeaders(requestHeaders); + clientBuilder.setCapturedRequestHeaders(requestHeaders); return this; } @@ -143,7 +149,7 @@ public ArmeriaTelemetryBuilder setCapturedClientRequestHeaders(List requ */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setCapturedClientResponseHeaders(List responseHeaders) { - httpClientAttributesExtractorBuilder.setCapturedResponseHeaders(responseHeaders); + clientBuilder.setCapturedResponseHeaders(responseHeaders); return this; } @@ -154,7 +160,7 @@ public ArmeriaTelemetryBuilder setCapturedClientResponseHeaders(List res */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setCapturedServerRequestHeaders(List requestHeaders) { - httpServerAttributesExtractorBuilder.setCapturedRequestHeaders(requestHeaders); + serverBuilder.setCapturedRequestHeaders(requestHeaders); return this; } @@ -165,7 +171,7 @@ public ArmeriaTelemetryBuilder setCapturedServerRequestHeaders(List requ */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setCapturedServerResponseHeaders(List responseHeaders) { - httpServerAttributesExtractorBuilder.setCapturedResponseHeaders(responseHeaders); + serverBuilder.setCapturedResponseHeaders(responseHeaders); return this; } @@ -185,11 +191,8 @@ public ArmeriaTelemetryBuilder setCapturedServerResponseHeaders(List res */ @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setKnownMethods(Set knownMethods) { - httpClientAttributesExtractorBuilder.setKnownMethods(knownMethods); - httpServerAttributesExtractorBuilder.setKnownMethods(knownMethods); - httpClientSpanNameExtractorBuilder.setKnownMethods(knownMethods); - httpServerSpanNameExtractorBuilder.setKnownMethods(knownMethods); - httpServerRouteBuilder.setKnownMethods(knownMethods); + clientBuilder.setKnownMethods(knownMethods); + serverBuilder.setKnownMethods(knownMethods); return this; } @@ -202,7 +205,7 @@ public ArmeriaTelemetryBuilder setKnownMethods(Set knownMethods) { @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setEmitExperimentalHttpClientMetrics( boolean emitExperimentalHttpClientMetrics) { - this.emitExperimentalHttpClientMetrics = emitExperimentalHttpClientMetrics; + clientBuilder.setEmitExperimentalHttpClientMetrics(emitExperimentalHttpClientMetrics); return this; } @@ -215,7 +218,7 @@ public ArmeriaTelemetryBuilder setEmitExperimentalHttpClientMetrics( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setEmitExperimentalHttpServerMetrics( boolean emitExperimentalHttpServerMetrics) { - this.emitExperimentalHttpServerMetrics = emitExperimentalHttpServerMetrics; + serverBuilder.setEmitExperimentalHttpServerMetrics(emitExperimentalHttpServerMetrics); return this; } @@ -223,10 +226,10 @@ public ArmeriaTelemetryBuilder setEmitExperimentalHttpServerMetrics( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setClientSpanNameExtractor( Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + SpanNameExtractor, + ? extends SpanNameExtractor> clientSpanNameExtractor) { - this.clientSpanNameExtractorTransformer = clientSpanNameExtractor; + clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; } @@ -234,66 +237,24 @@ public ArmeriaTelemetryBuilder setClientSpanNameExtractor( @CanIgnoreReturnValue public ArmeriaTelemetryBuilder setServerSpanNameExtractor( Function< - SpanNameExtractor, - ? extends SpanNameExtractor> + SpanNameExtractor, + ? extends SpanNameExtractor> serverSpanNameExtractor) { - this.serverSpanNameExtractorTransformer = serverSpanNameExtractor; + serverBuilder.setSpanNameExtractor(serverSpanNameExtractor); return this; } public ArmeriaTelemetry build() { - ArmeriaHttpClientAttributesGetter clientAttributesGetter = - ArmeriaHttpClientAttributesGetter.INSTANCE; - ArmeriaHttpServerAttributesGetter serverAttributesGetter = - ArmeriaHttpServerAttributesGetter.INSTANCE; - - SpanNameExtractor clientSpanNameExtractor = - clientSpanNameExtractorTransformer.apply(httpClientSpanNameExtractorBuilder.build()); - SpanNameExtractor serverSpanNameExtractor = - serverSpanNameExtractorTransformer.apply(httpServerSpanNameExtractorBuilder.build()); - - InstrumenterBuilder clientInstrumenterBuilder = - Instrumenter.builder(openTelemetry, INSTRUMENTATION_NAME, clientSpanNameExtractor); - InstrumenterBuilder serverInstrumenterBuilder = - Instrumenter.builder(openTelemetry, INSTRUMENTATION_NAME, serverSpanNameExtractor); - - Stream.of(clientInstrumenterBuilder, serverInstrumenterBuilder) - .forEach(instrumenter -> instrumenter.addAttributesExtractors(additionalExtractors)); - - clientInstrumenterBuilder - .setSpanStatusExtractor( - statusExtractorTransformer.apply( - HttpSpanStatusExtractor.create(clientAttributesGetter))) - .addAttributesExtractor(httpClientAttributesExtractorBuilder.build()) - .addAttributesExtractors(additionalClientExtractors) - .addOperationMetrics(HttpClientMetrics.get()); - serverInstrumenterBuilder - .setSpanStatusExtractor( - statusExtractorTransformer.apply( - HttpSpanStatusExtractor.create(serverAttributesGetter))) - .addAttributesExtractor(httpServerAttributesExtractorBuilder.build()) - .addOperationMetrics(HttpServerMetrics.get()) - .addContextCustomizer(httpServerRouteBuilder.build()); + return new ArmeriaTelemetry(clientBuilder.build(), serverBuilder.build()); + } - if (peerService != null) { - clientInstrumenterBuilder.addAttributesExtractor( - AttributesExtractor.constant(PEER_SERVICE, peerService)); - } - if (emitExperimentalHttpClientMetrics) { - clientInstrumenterBuilder - .addAttributesExtractor( - HttpExperimentalAttributesExtractor.create(clientAttributesGetter)) - .addOperationMetrics(HttpClientExperimentalMetrics.get()); - } - if (emitExperimentalHttpServerMetrics) { - serverInstrumenterBuilder - .addAttributesExtractor( - HttpExperimentalAttributesExtractor.create(serverAttributesGetter)) - .addOperationMetrics(HttpServerExperimentalMetrics.get()); - } + private DefaultHttpClientInstrumenterBuilder + getClientBuilder() { + return clientBuilder; + } - return new ArmeriaTelemetry( - clientInstrumenterBuilder.buildClientInstrumenter(ClientRequestContextSetter.INSTANCE), - serverInstrumenterBuilder.buildServerInstrumenter(RequestContextGetter.INSTANCE)); + private DefaultHttpServerInstrumenterBuilder + getServerBuilder() { + return serverBuilder; } } diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java index ec6d00b8d6e2..29dfa4aca00b 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpClientAttributesGetter.java @@ -5,9 +5,9 @@ package io.opentelemetry.instrumentation.armeria.v1_3.internal; +import com.linecorp.armeria.client.ClientRequestContext; import com.linecorp.armeria.common.HttpRequest; import com.linecorp.armeria.common.HttpStatus; -import com.linecorp.armeria.common.RequestContext; import com.linecorp.armeria.common.SessionProtocol; import com.linecorp.armeria.common.logging.RequestLog; import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesGetter; @@ -16,12 +16,8 @@ import java.util.List; import javax.annotation.Nullable; -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public enum ArmeriaHttpClientAttributesGetter - implements HttpClientAttributesGetter { +enum ArmeriaHttpClientAttributesGetter + implements HttpClientAttributesGetter { INSTANCE; private static final ClassValue authorityMethodCache = @@ -38,12 +34,12 @@ protected Method computeValue(Class type) { }; @Override - public String getHttpRequestMethod(RequestContext ctx) { + public String getHttpRequestMethod(ClientRequestContext ctx) { return ctx.method().name(); } @Override - public String getUrlFull(RequestContext ctx) { + public String getUrlFull(ClientRequestContext ctx) { HttpRequest request = request(ctx); StringBuilder uri = new StringBuilder(); String scheme = request.scheme(); @@ -65,14 +61,14 @@ public String getUrlFull(RequestContext ctx) { } @Override - public List getHttpRequestHeader(RequestContext ctx, String name) { + public List getHttpRequestHeader(ClientRequestContext ctx, String name) { return request(ctx).headers().getAll(name); } @Override @Nullable public Integer getHttpResponseStatusCode( - RequestContext ctx, RequestLog requestLog, @Nullable Throwable error) { + ClientRequestContext ctx, RequestLog requestLog, @Nullable Throwable error) { HttpStatus status = requestLog.responseHeaders().status(); if (!status.equals(HttpStatus.UNKNOWN)) { return status.code(); @@ -82,17 +78,18 @@ public Integer getHttpResponseStatusCode( @Override public List getHttpResponseHeader( - RequestContext ctx, RequestLog requestLog, String name) { + ClientRequestContext ctx, RequestLog requestLog, String name) { return requestLog.responseHeaders().getAll(name); } @Override - public String getNetworkProtocolName(RequestContext ctx, @Nullable RequestLog requestLog) { + public String getNetworkProtocolName(ClientRequestContext ctx, @Nullable RequestLog requestLog) { return "http"; } @Override - public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog requestLog) { + public String getNetworkProtocolVersion( + ClientRequestContext ctx, @Nullable RequestLog requestLog) { SessionProtocol protocol = requestLog != null ? requestLog.sessionProtocol() : ctx.sessionProtocol(); return protocol.isMultiplex() ? "2" : "1.1"; @@ -100,7 +97,7 @@ public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog @Nullable @Override - public String getServerAddress(RequestContext ctx) { + public String getServerAddress(ClientRequestContext ctx) { String authority = authority(ctx); if (authority == null) { return null; @@ -111,7 +108,7 @@ public String getServerAddress(RequestContext ctx) { @Nullable @Override - public Integer getServerPort(RequestContext ctx) { + public Integer getServerPort(ClientRequestContext ctx) { String authority = authority(ctx); if (authority == null) { return null; @@ -130,12 +127,12 @@ public Integer getServerPort(RequestContext ctx) { @Override @Nullable public InetSocketAddress getNetworkPeerInetSocketAddress( - RequestContext ctx, @Nullable RequestLog requestLog) { + ClientRequestContext ctx, @Nullable RequestLog requestLog) { return RequestContextAccess.remoteAddress(ctx); } @Nullable - private static String authority(RequestContext ctx) { + private static String authority(ClientRequestContext ctx) { // newer armeria versions expose authority through DefaultClientRequestContext#authority // we are using this method as it provides default values based on endpoint // in older versions armeria wraps the request, and we can get the same default values through @@ -153,7 +150,7 @@ private static String authority(RequestContext ctx) { return request.authority(); } - private static HttpRequest request(RequestContext ctx) { + private static HttpRequest request(ClientRequestContext ctx) { HttpRequest request = ctx.request(); if (request == null) { throw new IllegalStateException( diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaHttpServerAttributesGetter.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpServerAttributesGetter.java similarity index 63% rename from instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaHttpServerAttributesGetter.java rename to instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpServerAttributesGetter.java index 1f5891d9c43f..5cef09ca7fd9 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaHttpServerAttributesGetter.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaHttpServerAttributesGetter.java @@ -3,37 +3,35 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.armeria.v1_3; +package io.opentelemetry.instrumentation.armeria.v1_3.internal; import com.linecorp.armeria.common.HttpRequest; import com.linecorp.armeria.common.HttpStatus; -import com.linecorp.armeria.common.RequestContext; import com.linecorp.armeria.common.SessionProtocol; import com.linecorp.armeria.common.logging.RequestLog; import com.linecorp.armeria.server.ServiceRequestContext; import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesGetter; -import io.opentelemetry.instrumentation.armeria.v1_3.internal.RequestContextAccess; import java.net.InetSocketAddress; import java.util.List; import javax.annotation.Nullable; enum ArmeriaHttpServerAttributesGetter - implements HttpServerAttributesGetter { + implements HttpServerAttributesGetter { INSTANCE; @Override - public String getHttpRequestMethod(RequestContext ctx) { + public String getHttpRequestMethod(ServiceRequestContext ctx) { return ctx.method().name(); } @Override @Nullable - public String getUrlScheme(RequestContext ctx) { + public String getUrlScheme(ServiceRequestContext ctx) { return request(ctx).scheme(); } @Override - public String getUrlPath(RequestContext ctx) { + public String getUrlPath(ServiceRequestContext ctx) { String fullPath = request(ctx).path(); int separatorPos = fullPath.indexOf('?'); return separatorPos == -1 ? fullPath : fullPath.substring(0, separatorPos); @@ -41,21 +39,21 @@ public String getUrlPath(RequestContext ctx) { @Nullable @Override - public String getUrlQuery(RequestContext ctx) { + public String getUrlQuery(ServiceRequestContext ctx) { String fullPath = request(ctx).path(); int separatorPos = fullPath.indexOf('?'); return separatorPos == -1 ? null : fullPath.substring(separatorPos + 1); } @Override - public List getHttpRequestHeader(RequestContext ctx, String name) { + public List getHttpRequestHeader(ServiceRequestContext ctx, String name) { return request(ctx).headers().getAll(name); } @Override @Nullable public Integer getHttpResponseStatusCode( - RequestContext ctx, RequestLog requestLog, @Nullable Throwable error) { + ServiceRequestContext ctx, RequestLog requestLog, @Nullable Throwable error) { HttpStatus status = requestLog.responseHeaders().status(); if (!status.equals(HttpStatus.UNKNOWN)) { return status.code(); @@ -65,26 +63,24 @@ public Integer getHttpResponseStatusCode( @Override public List getHttpResponseHeader( - RequestContext ctx, RequestLog requestLog, String name) { + ServiceRequestContext ctx, RequestLog requestLog, String name) { return requestLog.responseHeaders().getAll(name); } @Override @Nullable - public String getHttpRoute(RequestContext ctx) { - if (ctx instanceof ServiceRequestContext) { - return ((ServiceRequestContext) ctx).config().route().patternString(); - } - return null; + public String getHttpRoute(ServiceRequestContext ctx) { + return ctx.config().route().patternString(); } @Override - public String getNetworkProtocolName(RequestContext ctx, @Nullable RequestLog requestLog) { + public String getNetworkProtocolName(ServiceRequestContext ctx, @Nullable RequestLog requestLog) { return "http"; } @Override - public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog requestLog) { + public String getNetworkProtocolVersion( + ServiceRequestContext ctx, @Nullable RequestLog requestLog) { SessionProtocol protocol = ctx.sessionProtocol(); return protocol.isMultiplex() ? "2" : "1.1"; } @@ -92,18 +88,18 @@ public String getNetworkProtocolVersion(RequestContext ctx, @Nullable RequestLog @Override @Nullable public InetSocketAddress getNetworkPeerInetSocketAddress( - RequestContext ctx, @Nullable RequestLog requestLog) { + ServiceRequestContext ctx, @Nullable RequestLog requestLog) { return RequestContextAccess.remoteAddress(ctx); } @Nullable @Override public InetSocketAddress getNetworkLocalInetSocketAddress( - RequestContext ctx, @Nullable RequestLog log) { + ServiceRequestContext ctx, @Nullable RequestLog log) { return RequestContextAccess.localAddress(ctx); } - private static HttpRequest request(RequestContext ctx) { + private static HttpRequest request(ServiceRequestContext ctx) { HttpRequest request = ctx.request(); if (request == null) { throw new IllegalStateException( diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderFactory.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderFactory.java new file mode 100644 index 000000000000..07a28da6da85 --- /dev/null +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderFactory.java @@ -0,0 +1,37 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.armeria.v1_3.internal; + +import com.linecorp.armeria.client.ClientRequestContext; +import com.linecorp.armeria.common.logging.RequestLog; +import com.linecorp.armeria.server.ServiceRequestContext; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; + +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public class ArmeriaInstrumenterBuilderFactory { + private ArmeriaInstrumenterBuilderFactory() {} + + private static final String INSTRUMENTATION_NAME = "io.opentelemetry.armeria-1.3"; + + public static DefaultHttpServerInstrumenterBuilder + getServerBuilder(OpenTelemetry openTelemetry) { + return new DefaultHttpServerInstrumenterBuilder<>( + INSTRUMENTATION_NAME, openTelemetry, ArmeriaHttpServerAttributesGetter.INSTANCE) + .setHeaderGetter(RequestContextGetter.INSTANCE); + } + + public static DefaultHttpClientInstrumenterBuilder + getClientBuilder(OpenTelemetry openTelemetry) { + return new DefaultHttpClientInstrumenterBuilder<>( + INSTRUMENTATION_NAME, openTelemetry, ArmeriaHttpClientAttributesGetter.INSTANCE) + .setHeaderSetter(ClientRequestContextSetter.INSTANCE); + } +} diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderUtil.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderUtil.java new file mode 100644 index 000000000000..a9a7d8b43b09 --- /dev/null +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ArmeriaInstrumenterBuilderUtil.java @@ -0,0 +1,67 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.armeria.v1_3.internal; + +import com.linecorp.armeria.client.ClientRequestContext; +import com.linecorp.armeria.common.logging.RequestLog; +import com.linecorp.armeria.server.ServiceRequestContext; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder; +import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpServerInstrumenterBuilder; +import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetryBuilder; +import java.util.function.Function; +import javax.annotation.Nullable; + +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public class ArmeriaInstrumenterBuilderUtil { + private ArmeriaInstrumenterBuilderUtil() {} + + @Nullable + private static Function< + ArmeriaTelemetryBuilder, + DefaultHttpClientInstrumenterBuilder> + clientBuilderExtractor; + + @Nullable + private static Function< + ArmeriaTelemetryBuilder, + DefaultHttpServerInstrumenterBuilder> + serverBuilderExtractor; + + @Nullable + public static Function< + ArmeriaTelemetryBuilder, + DefaultHttpClientInstrumenterBuilder> + getClientBuilderExtractor() { + return clientBuilderExtractor; + } + + public static void setClientBuilderExtractor( + Function< + ArmeriaTelemetryBuilder, + DefaultHttpClientInstrumenterBuilder> + clientBuilderExtractor) { + ArmeriaInstrumenterBuilderUtil.clientBuilderExtractor = clientBuilderExtractor; + } + + @Nullable + public static Function< + ArmeriaTelemetryBuilder, + DefaultHttpServerInstrumenterBuilder> + getServerBuilderExtractor() { + return serverBuilderExtractor; + } + + public static void setServerBuilderExtractor( + Function< + ArmeriaTelemetryBuilder, + DefaultHttpServerInstrumenterBuilder> + serverBuilderExtractor) { + ArmeriaInstrumenterBuilderUtil.serverBuilderExtractor = serverBuilderExtractor; + } +} diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ClientRequestContextSetter.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ClientRequestContextSetter.java similarity index 89% rename from instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ClientRequestContextSetter.java rename to instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ClientRequestContextSetter.java index 91ce53e54805..1a225fd7108b 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ClientRequestContextSetter.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/ClientRequestContextSetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.armeria.v1_3; +package io.opentelemetry.instrumentation.armeria.v1_3.internal; import com.linecorp.armeria.client.ClientRequestContext; import io.opentelemetry.context.propagation.TextMapSetter; diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextAccess.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextAccess.java index acaf7fd9cfa0..1a7830758fd6 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextAccess.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextAccess.java @@ -13,11 +13,7 @@ import java.net.SocketAddress; import javax.annotation.Nullable; -/** - * This class is internal and is hence not for public use. Its APIs are unstable and can change at - * any time. - */ -public final class RequestContextAccess { +final class RequestContextAccess { @Nullable private static final MethodHandle remoteAddress = findAccessorOrNull("remoteAddress"); @Nullable private static final MethodHandle localAddress = findAccessorOrNull("localAddress"); diff --git a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/RequestContextGetter.java b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextGetter.java similarity index 93% rename from instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/RequestContextGetter.java rename to instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextGetter.java index 5163333591a0..5cae10de6578 100644 --- a/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/RequestContextGetter.java +++ b/instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/internal/RequestContextGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.armeria.v1_3; +package io.opentelemetry.instrumentation.armeria.v1_3.internal; import com.linecorp.armeria.server.ServiceRequestContext; import io.netty.util.AsciiString; 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 1e5cbd0c1490..66d8f753c300 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 @@ -95,7 +95,9 @@ public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public JavaHttpClientTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function< + SpanNameExtractor, + ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; 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 a914f73d266f..ec5c8b379d50 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 @@ -112,7 +112,7 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public JettyClientTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; 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 427980f0d244..a976fe7a2f30 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 @@ -112,7 +112,7 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public JettyClientTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; 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 552db08382e0..6dafba2c124d 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 @@ -95,7 +95,7 @@ public OkHttpTelemetryBuilder setEmitExperimentalHttpClientMetrics( /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public OkHttpTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function, ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; 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 3eab8e96bf61..36fde223c3ec 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 @@ -74,7 +74,9 @@ public SpringWebTelemetryBuilder setCapturedResponseHeaders(List respons /** Sets custom {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public SpringWebTelemetryBuilder setSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function< + SpanNameExtractor, + ? extends SpanNameExtractor> spanNameExtractorTransformer) { builder.setSpanNameExtractor(spanNameExtractorTransformer); return this; 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 e8387880cd32..e004ee7e9a70 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 @@ -169,7 +169,9 @@ public SpringWebfluxTelemetryBuilder setEmitExperimentalHttpServerTelemetry( /** Sets custom client {@link SpanNameExtractor} via transform function. */ @CanIgnoreReturnValue public SpringWebfluxTelemetryBuilder setClientSpanNameExtractor( - Function, ? extends SpanNameExtractor> + Function< + SpanNameExtractor, + ? extends SpanNameExtractor> clientSpanNameExtractor) { clientBuilder.setSpanNameExtractor(clientSpanNameExtractor); return this; @@ -179,7 +181,7 @@ public SpringWebfluxTelemetryBuilder setClientSpanNameExtractor( @CanIgnoreReturnValue public SpringWebfluxTelemetryBuilder setServerSpanNameExtractor( Function< - SpanNameExtractor, + SpanNameExtractor, ? extends SpanNameExtractor> serverSpanNameExtractor) { serverBuilder.setSpanNameExtractor(serverSpanNameExtractor); 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 588263aff6e6..4acb087b72b5 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 @@ -74,7 +74,7 @@ public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List resp @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, + SpanNameExtractor, ? extends SpanNameExtractor> spanNameExtractor) { builder.setSpanNameExtractor(spanNameExtractor); 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 7978664dd053..abf49f90fd25 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 @@ -73,7 +73,7 @@ public SpringWebMvcTelemetryBuilder setCapturedResponseHeaders(List resp @CanIgnoreReturnValue public SpringWebMvcTelemetryBuilder setSpanNameExtractor( Function< - SpanNameExtractor, + SpanNameExtractor, ? extends SpanNameExtractor> spanNameExtractor) { builder.setSpanNameExtractor(spanNameExtractor);