[2] Create instrumentation-core:spring:spring-webflux-5.0-core
ADD
instrumentation-core/spring/spring-webflux-5.0/spring-webflux-5.0.gradle
+plugins {
+ id "com.github.johnrengelman.shadow"
+}
+
+ext {
+ minJavaVersionForTests = JavaVersion.VERSION_1_8
+ noShadowPublish = true
+}
+
+apply from: "$rootDir/gradle/java.gradle"
+
+group = 'io.opentelemetry.instrumentation.spring.webflux'
+
+dependencies {
+ compileOnly project(':auto-bootstrap')
+
+ api group: 'org.springframework', name: 'spring-webflux', version: '5.0.0.RELEASE'
+ api group: 'io.projectreactor.ipc', name: 'reactor-netty', version: '0.7.0.RELEASE'
+ api deps.opentelemetryApi
+}
+
+shadowJar {
+ archiveClassifier = 'agent'
+ configurations = []
+ relocate 'io.opentelemetry.instrumentation.springwebflux.client', 'io.opentelemetry.auto.instrumentation.springwebflux.client.shaded'
+}
+
+
+testSets {
+ latestDepTest {
+ dirName = 'test'
+ }
+}
\ No newline at end of file

RENAME
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/HttpHeadersInjectAdapter.java
instrumentation-core/spring/spring-webflux-5.0/src/main/java/io/opentelemetry/instrumentation/springwebflux/client/HttpHeadersInjectAdapter.java
* limitations under the License.
*/
-package io.opentelemetry.auto.instrumentation.springwebflux.client;
+package io.opentelemetry.instrumentation.springwebflux.client;
import io.opentelemetry.context.propagation.HttpTextFormat;
import org.springframework.http.HttpHeaders;
-public class HttpHeadersInjectAdapter implements HttpTextFormat.Setter<HttpHeaders> {
+class HttpHeadersInjectAdapter implements HttpTextFormat.Setter<HttpHeaders> {
public static final HttpHeadersInjectAdapter SETTER = new HttpHeadersInjectAdapter();

RENAME
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/SpringWebfluxHttpClientDecorator.java
instrumentation-core/spring/spring-webflux-5.0/src/main/java/io/opentelemetry/instrumentation/springwebflux/client/SpringWebfluxHttpClientDecorator.java
* limitations under the License.
*/
-package io.opentelemetry.auto.instrumentation.springwebflux.client;
+package io.opentelemetry.instrumentation.springwebflux.client;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.auto.bootstrap.instrumentation.decorator.HttpClientDecorator;
@@ -22,13 +22,10 @@ import io.opentelemetry.trace.Span;
import io.opentelemetry.trace.Tracer;
import java.net.URI;
import java.util.List;
-import lombok.extern.slf4j.Slf4j;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
-@Slf4j
-public class SpringWebfluxHttpClientDecorator
- extends HttpClientDecorator<ClientRequest, ClientResponse> {
+class SpringWebfluxHttpClientDecorator extends HttpClientDecorator<ClientRequest, ClientResponse> {
public static final Tracer TRACER =
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.spring-webflux-5.0");

RENAME
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/WebClientTracingFilter.java
instrumentation-core/spring/spring-webflux-5.0/src/main/java/io/opentelemetry/instrumentation/springwebflux/client/WebClientTracingFilter.java
* limitations under the License.
*/
-package io.opentelemetry.auto.instrumentation.springwebflux.client;
+package io.opentelemetry.instrumentation.springwebflux.client;
-import static io.opentelemetry.auto.instrumentation.springwebflux.client.HttpHeadersInjectAdapter.SETTER;
-import static io.opentelemetry.auto.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator.DECORATE;
-import static io.opentelemetry.auto.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator.TRACER;
+import static io.opentelemetry.instrumentation.springwebflux.client.HttpHeadersInjectAdapter.SETTER;
+import static io.opentelemetry.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator.DECORATE;
+import static io.opentelemetry.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator.TRACER;
import static io.opentelemetry.trace.Span.Kind.CLIENT;
import io.grpc.Context;
import io.opentelemetry.OpenTelemetry;
import io.opentelemetry.context.Scope;
import io.opentelemetry.trace.Span;
+import io.opentelemetry.trace.Tracer;
import java.util.List;
import org.springframework.web.reactive.function.client.ClientRequest;
import org.springframework.web.reactive.function.client.ClientResponse;
@@ -34,14 +35,25 @@ import reactor.core.publisher.Mono;
public class WebClientTracingFilter implements ExchangeFilterFunction {
+ private final Tracer tracer;
+
+ public WebClientTracingFilter(Tracer tracer) {
+ this.tracer = tracer;
+ }
+
public static void addFilter(final List<ExchangeFilterFunction> exchangeFilterFunctions) {
- exchangeFilterFunctions.add(0, new WebClientTracingFilter());
+ addFilter(exchangeFilterFunctions, TRACER);
+ }
+
+ public static void addFilter(
+ final List<ExchangeFilterFunction> exchangeFilterFunctions, Tracer tracer) {
+ exchangeFilterFunctions.add(0, new WebClientTracingFilter(tracer));
}
@Override
public Mono<ClientResponse> filter(final ClientRequest request, final ExchangeFunction next) {
final Span span =
- TRACER.spanBuilder(DECORATE.spanNameForRequest(request)).setSpanKind(CLIENT).startSpan();
+ tracer.spanBuilder(DECORATE.spanNameForRequest(request)).setSpanKind(CLIENT).startSpan();
DECORATE.afterStart(span);
try (final Scope scope = TRACER.withSpan(span)) {

MODIFY
instrumentation/spring-webflux-5.0/spring-webflux-5.0.gradle
instrumentation/spring-webflux-5.0/spring-webflux-5.0.gradle
@@ -30,6 +30,7 @@ testSets {
}
dependencies {
+ implementation project(path: ':instrumentation-core:spring:spring-webflux-5.0', configuration: 'shadow')
compileOnly group: 'org.springframework', name: 'spring-webflux', version: '5.0.0.RELEASE'
compileOnly group: 'io.projectreactor.ipc', name: 'reactor-netty', version: '0.7.0.RELEASE'

MODIFY
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/WebClientFilterAdvice.java
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/WebClientFilterAdvice.java
package io.opentelemetry.auto.instrumentation.springwebflux.client;
+import io.opentelemetry.auto.instrumentation.springwebflux.client.shaded.WebClientTracingFilter;
import net.bytebuddy.asm.Advice;
import org.springframework.web.reactive.function.client.WebClient;

MODIFY
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/WebClientFilterInstrumentation.java
instrumentation/spring-webflux-5.0/src/main/java/io/opentelemetry/auto/instrumentation/springwebflux/client/WebClientFilterInstrumentation.java
@@ -46,9 +46,9 @@ public class WebClientFilterInstrumentation extends Instrumenter.Default {
@Override
public String[] helperClassNames() {
return new String[] {
- packageName + ".SpringWebfluxHttpClientDecorator",
- packageName + ".HttpHeadersInjectAdapter",
- packageName + ".WebClientTracingFilter",
+ packageName + ".shaded.SpringWebfluxHttpClientDecorator",
+ packageName + ".shaded.HttpHeadersInjectAdapter",
+ packageName + ".shaded.WebClientTracingFilter"
};
}

MODIFY
settings.gradle
settings.gradle
@@ -154,6 +154,7 @@ include ':instrumentation-core:aws-sdk:aws-sdk-2.2'
include ':instrumentation-core:reactor-3.1'
include ':instrumentation-core:servlet'
include ':instrumentation-core:spring:spring-web-3.1'
+include ':instrumentation-core:spring:spring-webflux-5.0'
include ':instrumentation-core:spring:spring-webmvc-3.1'
// exporter adapters

[2] Create instrumentation-core:spring:spring-webflux-5.0-core  (#639)