diff --git a/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java b/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java index 64adfd3..9632c42 100644 --- a/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java +++ b/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/JaegerAutoConfiguration.java @@ -32,7 +32,6 @@ import io.opentracing.contrib.java.spring.jaeger.starter.customizers.ExpandExceptionLogsTracerBuilderCustomizer; import io.opentracing.contrib.java.spring.jaeger.starter.customizers.HigherBitTracerBuilderCustomizer; -import io.opentracing.contrib.java.spring.jaeger.starter.customizers.TraceContextCodecTracerBuilderCustomizer; import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -215,16 +214,6 @@ public TracerBuilderCustomizer b3CodecJaegerTracerCustomizer() { } } - @Configuration - @ConditionalOnProperty(value = "opentracing.jaeger.enable-w3c-propagation") - public static class TraceContextCodecConfiguration { - - @Bean - public TracerBuilderCustomizer traceContextCodecJaegerTracerCustomizer() { - return new TraceContextCodecTracerBuilderCustomizer(); - } - } - @Configuration @ConditionalOnProperty(value = "opentracing.jaeger.enable-128-bit-traces") public static class HigherBitTraceConfiguration { diff --git a/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/TraceContextCodecTracerBuilderCustomizer.java b/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/TraceContextCodecTracerBuilderCustomizer.java deleted file mode 100644 index 01ac5ac..0000000 --- a/opentracing-spring-jaeger-starter/src/main/java/io/opentracing/contrib/java/spring/jaeger/starter/customizers/TraceContextCodecTracerBuilderCustomizer.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2018-2020 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package io.opentracing.contrib.java.spring.jaeger.starter.customizers; - -import io.jaegertracing.internal.JaegerTracer.Builder; -import io.jaegertracing.internal.propagation.TraceContextCodec; -import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer; -import io.opentracing.propagation.Format; - -public class TraceContextCodecTracerBuilderCustomizer implements TracerBuilderCustomizer { - - @Override - public void customize(Builder builder) { - TraceContextCodec injector = new TraceContextCodec.Builder().build(); - - builder.registerInjector(Format.Builtin.HTTP_HEADERS, injector) - .registerExtractor(Format.Builtin.HTTP_HEADERS, injector); - - builder.registerInjector(Format.Builtin.TEXT_MAP, injector) - .registerExtractor(Format.Builtin.TEXT_MAP, injector); - } -} diff --git a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/AbstractSenderSpringTest.java b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/AbstractSenderSpringTest.java index 0e2d778..cd85849 100644 --- a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/AbstractSenderSpringTest.java +++ b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/AbstractSenderSpringTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2018 The OpenTracing Authors + * Copyright 2018-2020 The OpenTracing Authors * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at @@ -13,31 +13,39 @@ */ package io.opentracing.contrib.java.spring.jaeger.starter; +import static org.assertj.core.api.Assertions.as; import static org.assertj.core.api.Assertions.assertThat; import io.jaegertracing.internal.reporters.CompositeReporter; import io.jaegertracing.internal.reporters.RemoteReporter; +import io.jaegertracing.spi.Reporter; import org.assertj.core.api.Condition; +import org.assertj.core.api.InstanceOfAssertFactories; +import org.assertj.core.api.InstanceOfAssertFactory; public abstract class AbstractSenderSpringTest extends AbstractTracerSpringTest { protected void assertSenderClass(Class senderClass) { assertThat(getTracer()) .extracting("reporter") - .extracting("class") - .containsExactly(CompositeReporter.class); + .extracting("class", as(InstanceOfAssertFactories.CLASS)) + .isEqualTo(CompositeReporter.class); assertThat(getTracer()) - .extracting("reporter") - .flatExtracting("reporters") - .filteredOn(new Condition() { - @Override - public boolean matches(Object value) { - return value.getClass().equals(RemoteReporter.class); - } - }) - .extracting("sender") - .extracting("class") - .containsExactly(senderClass); + .extracting("reporter").isInstanceOfSatisfying(CompositeReporter.class, c -> { + assertThat(c) + .extracting("reporters", as(InstanceOfAssertFactories.list(Reporter.class))) + .filteredOn(new Condition() { + @Override + public boolean matches(Object value) { + return value.getClass().equals(RemoteReporter.class); + } + }).allSatisfy(rr -> { + assertThat(rr) + .extracting("sender") + .extracting("class", as(InstanceOfAssertFactories.CLASS)) + .isEqualTo(senderClass); + }); + }); } } diff --git a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerDisabledSpringTest.java b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerDisabledSpringTest.java deleted file mode 100644 index fadea69..0000000 --- a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerDisabledSpringTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2018-2020 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package io.opentracing.contrib.java.spring.jaeger.starter.customizer; - -import static org.assertj.core.api.Assertions.assertThat; - -import io.opentracing.contrib.java.spring.jaeger.starter.AbstractTracerSpringTest; -import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer; -import io.opentracing.contrib.java.spring.jaeger.starter.customizers.TraceContextCodecTracerBuilderCustomizer; -import java.util.List; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource( - properties = { - "spring.main.banner-mode=off", - "opentracing.jaeger.enable-w3c-propagation=false" - } -) -public class JaegerTracerTraceContextCustomerizerDisabledSpringTest extends AbstractTracerSpringTest { - - @Autowired(required = false) - private List customizers; - - @Test - public void testCustomizersShouldContainTraceContextCustomizer() { - if (customizers == null) { - return; - } - - assertThat(customizers) - .extracting("class").doesNotContain(TraceContextCodecTracerBuilderCustomizer.class); - } -} diff --git a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerEnabledSpringTest.java b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerEnabledSpringTest.java deleted file mode 100644 index 5b992e3..0000000 --- a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomerizerEnabledSpringTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2018-2020 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package io.opentracing.contrib.java.spring.jaeger.starter.customizer; - -import static org.assertj.core.api.Assertions.assertThat; - -import io.opentracing.contrib.java.spring.jaeger.starter.AbstractTracerSpringTest; -import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer; -import io.opentracing.contrib.java.spring.jaeger.starter.customizers.TraceContextCodecTracerBuilderCustomizer; -import java.util.List; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource( - properties = { - "spring.main.banner-mode=off", - "opentracing.jaeger.enable-w3c-propagation=true" - } -) -public class JaegerTracerTraceContextCustomerizerEnabledSpringTest extends AbstractTracerSpringTest { - - @Autowired - private List customizers; - - @Test - public void testCustomizersShouldContainTraceContextCustomizer() { - assertThat(customizers) - .isNotEmpty() - .extracting("class").contains(TraceContextCodecTracerBuilderCustomizer.class); - } -} diff --git a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomizerCustomSpringTest.java b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomizerCustomSpringTest.java deleted file mode 100644 index 5413838..0000000 --- a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/JaegerTracerTraceContextCustomizerCustomSpringTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright 2018-2020 The OpenTracing Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ - -package io.opentracing.contrib.java.spring.jaeger.starter.customizer; - -import static org.assertj.core.api.Assertions.assertThat; - -import io.jaegertracing.internal.JaegerSpanContext; -import io.opentracing.Tracer; -import io.opentracing.contrib.java.spring.jaeger.starter.AbstractTracerSpringTest; -import io.opentracing.contrib.java.spring.jaeger.starter.TracerBuilderCustomizer; -import io.opentracing.propagation.Format; -import io.opentracing.propagation.TextMap; -import io.opentracing.propagation.TextMapAdapter; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.TestPropertySource; - - -@TestPropertySource( - properties = { - "spring.main.banner-mode=off", - "opentracing.jaeger.enable-w3c-propagation=true" - } -) -@Import(JaegerTracerTraceContextCustomizerCustomSpringTest.TestConfiguration.class) -public class JaegerTracerTraceContextCustomizerCustomSpringTest extends AbstractTracerSpringTest { - - @Autowired - private Tracer tracer; - - public static class TestConfiguration { - @Bean - public TracerBuilderCustomizer myCustomizer() { - // Noop - return builder -> { - }; - } - } - - @Test - public void testCustomizersHttpHeadersShouldContainTraceContext() { - TextMap textMap = createTextMap(); - - JaegerSpanContext context = (JaegerSpanContext) tracer.extract(Format.Builtin.HTTP_HEADERS, textMap); - - assertOnTraceContextHeaders(context); - } - - @Test - public void testCustomizersTextMapShouldContainTraceContext() { - TextMap textMap = createTextMap(); - - JaegerSpanContext context = (JaegerSpanContext) tracer.extract(Format.Builtin.TEXT_MAP, textMap); - - assertOnTraceContextHeaders(context); - } - - private TextMapAdapter createTextMap() { - Map carrier = new HashMap<>(); - carrier.put("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"); - carrier.put("tracestate", "congo=t61rcWkgMzE"); - - return new TextMapAdapter(carrier); - } - - private void assertOnTraceContextHeaders(JaegerSpanContext context) { - // Note: This test ensures that W3C Trace Context codec actually works - // If it would not, values would never be extracted from B3 headers and context will be null - assertThat(context).isNotNull(); - assertThat(context.getTraceId()).isEqualTo("4bf92f3577b34da6a3ce929d0e0e4736"); - assertThat(context.getSpanId()).isEqualTo(67667974448284343L); - } -} diff --git a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/MultipleCustomizersEnabledSpringTest.java b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/MultipleCustomizersEnabledSpringTest.java index 39e0017..ba29074 100644 --- a/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/MultipleCustomizersEnabledSpringTest.java +++ b/opentracing-spring-jaeger-starter/src/test/java/io/opentracing/contrib/java/spring/jaeger/starter/customizer/MultipleCustomizersEnabledSpringTest.java @@ -23,7 +23,6 @@ import io.opentracing.contrib.java.spring.jaeger.starter.customizers.ExpandExceptionLogsTracerBuilderCustomizer; import io.opentracing.contrib.java.spring.jaeger.starter.customizers.HigherBitTracerBuilderCustomizer; -import io.opentracing.contrib.java.spring.jaeger.starter.customizers.TraceContextCodecTracerBuilderCustomizer; import java.util.List; import org.junit.Test; @@ -42,7 +41,6 @@ "spring.main.banner-mode=off", "opentracing.jaeger.expand-exception-logs=true", "opentracing.jaeger.enable-b3-propagation=true", - "opentracing.jaeger.enable-w3c-propagation=true", "opentracing.jaeger.enable-128-bit-traces=true" } ) @@ -59,7 +57,6 @@ public void testCustomizersShouldContainB3Customizer() { .containsExactlyInAnyOrder( ExpandExceptionLogsTracerBuilderCustomizer.class, B3CodecTracerBuilderCustomizer.class, - TraceContextCodecTracerBuilderCustomizer.class, HigherBitTracerBuilderCustomizer.class, MockTracerBuilderCustomizer.class); } diff --git a/pom.xml b/pom.xml index 5498b38..0f96d69 100644 --- a/pom.xml +++ b/pom.xml @@ -65,8 +65,8 @@ 0.33.0 0.3.1 - 2.1.4.RELEASE - 1.3.2 + 2.3.4.RELEASE + 1.1.0 3.0.0 1.7.3