From d3c80d135ccde4832cc9a8596f86a284ff13cf28 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 7 Jan 2024 16:15:57 +0800 Subject: [PATCH] deps: bumps to Brave 5.17.1 and moves off internal type This updates to Brave 5.17.1 and dodges an internal type that will not be in Brave 6.0. See https://github.com/openzipkin/brave/pull/1396 about Propagation and Brave 6.0 Signed-off-by: Adrian Cole --- pom.xml | 2 +- .../brave/BraveBaggageConfiguration.java | 16 ++++--- .../brave/BravePropagationTests.java | 15 ++++-- .../CustomPropagationFactoryTests.java | 16 +++++-- .../CompositePropagationFactorySupplier.java | 48 ++++++++++++++----- .../sleuth/brave/bridge/W3CPropagation.java | 28 +++++++++-- .../.flattened-pom.xml | 4 +- spring-cloud-sleuth-dependencies/pom.xml | 4 +- .../instrument/web/client/MergedFactory.java | 15 ++++-- 9 files changed, 112 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index 6abc183065..42cb24e78f 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 3.1.10-SNAPSHOT 2.4.6 2.5.1 - 5.13.9 + 5.17.1 0.32.0 2.3.4.RELEASE diff --git a/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.java b/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.java index 62cf393958..89cdb675aa 100644 --- a/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.java +++ b/spring-cloud-sleuth-autoconfigure/src/main/java/org/springframework/cloud/sleuth/autoconfig/brave/BraveBaggageConfiguration.java @@ -323,6 +323,16 @@ public boolean requires128BitTraceId() { return delegate.requires128BitTraceId(); } + /** + * @deprecated end users and instrumentation should never call this, and instead + * use {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated + @Override + public Propagation create(Propagation.KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + @Override public Propagation get() { Propagation propagation = delegate.get(); @@ -334,12 +344,6 @@ public TraceContext decorate(TraceContext context) { return delegate.decorate(context); } - @Override - public Propagation create(Propagation.KeyFactory keyFactory) { - Propagation propagation = delegate.create(keyFactory); - return delegateWithoutB3Baggage(factoryFromSupplier, propagation); - } - private Propagation delegateWithoutB3Baggage(Propagation.Factory factoryFromSupplier, Propagation propagation) { return new Propagation() { diff --git a/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/BravePropagationTests.java b/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/BravePropagationTests.java index 96a2f0f949..5df1152313 100644 --- a/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/BravePropagationTests.java +++ b/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/BravePropagationTests.java @@ -22,7 +22,6 @@ import java.util.Map; import brave.internal.codec.HexCodec; -import brave.internal.propagation.StringPropagationAdapter; import brave.propagation.Propagation; import brave.propagation.TraceContext; import brave.propagation.TraceContextOrSamplingFlags; @@ -158,9 +157,19 @@ public TraceContext.Extractor extractor(Getter getter) { .spanId(HexCodec.lowerHexToUnsignedLong(getter.get(request, "myCustomSpanId"))).build()); } + /** + * @deprecated end users and instrumentation should never call this, and instead use + * {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return this; } } diff --git a/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/baggage/CustomPropagationFactoryTests.java b/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/baggage/CustomPropagationFactoryTests.java index 5ba137735b..0e8f929b26 100644 --- a/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/baggage/CustomPropagationFactoryTests.java +++ b/spring-cloud-sleuth-autoconfigure/src/test/java/org/springframework/cloud/sleuth/autoconfig/brave/baggage/CustomPropagationFactoryTests.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.List; -import brave.internal.propagation.StringPropagationAdapter; import brave.propagation.Propagation; import brave.propagation.TraceContext; import brave.propagation.TraceContextOrSamplingFlags; @@ -93,9 +92,20 @@ public TraceContext.Extractor extractor(Getter getter) { return request -> TraceContextOrSamplingFlags.EMPTY; } + /** + * @deprecated end users and instrumentation should never call this, and + * instead use {@link #get()}. This only remains to avoid rev-lock upgrading + * to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return this; } } diff --git a/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/CompositePropagationFactorySupplier.java b/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/CompositePropagationFactorySupplier.java index 3afdd8d3b7..7ce8060520 100644 --- a/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/CompositePropagationFactorySupplier.java +++ b/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/CompositePropagationFactorySupplier.java @@ -23,7 +23,6 @@ import java.util.Map; import java.util.stream.Collectors; -import brave.internal.propagation.StringPropagationAdapter; import brave.propagation.B3Propagation; import brave.propagation.Propagation; import brave.propagation.TraceContext; @@ -128,9 +127,19 @@ public TraceContext.Extractor extractor(Getter getter) { }; } + /** + * @deprecated end users and instrumentation should never call this, and instead use + * {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return this; } @Override @@ -176,9 +185,19 @@ private Propagation.Factory propagationFactory() { return this.propagationFactory; } + /** + * @deprecated end users and instrumentation should never call this, and instead + * use {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return propagationFactory().create(keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return new LazyPropagation(this); } @Override @@ -191,11 +210,6 @@ public boolean requires128BitTraceId() { return propagationFactory().requires128BitTraceId(); } - @Override - public Propagation get() { - return new LazyPropagation(this); - } - @Override public TraceContext decorate(TraceContext context) { return propagationFactory().decorate(context); @@ -259,9 +273,19 @@ public TraceContext.Extractor extractor(Getter getter) { return request -> TraceContextOrSamplingFlags.EMPTY; } + /** + * @deprecated end users and instrumentation should never call this, and instead + * use {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return this; } } diff --git a/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/W3CPropagation.java b/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/W3CPropagation.java index 4794f3ff9e..9a0974deb1 100644 --- a/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/W3CPropagation.java +++ b/spring-cloud-sleuth-brave/src/main/java/org/springframework/cloud/sleuth/brave/bridge/W3CPropagation.java @@ -31,7 +31,6 @@ import brave.baggage.BaggagePropagation; import brave.baggage.BaggagePropagationConfig; import brave.internal.baggage.BaggageFields; -import brave.internal.propagation.StringPropagationAdapter; import brave.propagation.Propagation; import brave.propagation.TraceContext; import brave.propagation.TraceContextOrSamplingFlags; @@ -128,9 +127,19 @@ class W3CPropagation extends Propagation.Factory implements Propagation this.braveBaggageManager = braveBaggageManager; } + /** + * @deprecated end users and instrumentation should never call this, and instead use + * {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated + @Override + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation get() { + return this; } @Override @@ -320,8 +329,19 @@ class W3CBaggagePropagator { private BaggagePropagation.FactoryBuilder factory() { return BaggagePropagation.newFactoryBuilder(new Propagation.Factory() { + /** + * @deprecated end users and instrumentation should never call this, and + * instead use {@link #get()}. This only remains to avoid rev-lock upgrading + * to Brave 6. + */ + @Deprecated + @Override + public Propagation create(Propagation.KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + @Override - public Propagation create(Propagation.KeyFactory keyFactory) { + public Propagation get() { return null; } }); diff --git a/spring-cloud-sleuth-dependencies/.flattened-pom.xml b/spring-cloud-sleuth-dependencies/.flattened-pom.xml index 23e93f39cc..c5a380a41c 100644 --- a/spring-cloud-sleuth-dependencies/.flattened-pom.xml +++ b/spring-cloud-sleuth-dependencies/.flattened-pom.xml @@ -100,9 +100,9 @@ https://github.com/spring-cloud - 0.37.4 + 1.0.1 4.2.2 - 5.13.9 + 5.17.1 diff --git a/spring-cloud-sleuth-dependencies/pom.xml b/spring-cloud-sleuth-dependencies/pom.xml index 79dcafc3e8..233704cd16 100644 --- a/spring-cloud-sleuth-dependencies/pom.xml +++ b/spring-cloud-sleuth-dependencies/pom.xml @@ -42,8 +42,8 @@ - 5.13.11 - 0.37.5 + 5.17.1 + 1.0.1 4.2.3 diff --git a/tests/brave/spring-cloud-sleuth-instrumentation-webflux-tests/src/test/java/org/springframework/cloud/sleuth/brave/instrument/web/client/MergedFactory.java b/tests/brave/spring-cloud-sleuth-instrumentation-webflux-tests/src/test/java/org/springframework/cloud/sleuth/brave/instrument/web/client/MergedFactory.java index 6168ebc725..49cd72d638 100644 --- a/tests/brave/spring-cloud-sleuth-instrumentation-webflux-tests/src/test/java/org/springframework/cloud/sleuth/brave/instrument/web/client/MergedFactory.java +++ b/tests/brave/spring-cloud-sleuth-instrumentation-webflux-tests/src/test/java/org/springframework/cloud/sleuth/brave/instrument/web/client/MergedFactory.java @@ -20,7 +20,6 @@ import brave.Span; import brave.internal.collect.Lists; -import brave.internal.propagation.StringPropagationAdapter; import brave.propagation.B3Propagation; import brave.propagation.Propagation; import brave.propagation.TraceContext; @@ -51,9 +50,19 @@ public TraceContext.Extractor extractor(Getter getter) { return multi.extractor(getter); } + /** + * @deprecated end users and instrumentation should never call this, and instead use + * {@link #get()}. This only remains to avoid rev-lock upgrading to Brave 6. + */ + @Deprecated @Override - public Propagation create(KeyFactory keyFactory) { - return StringPropagationAdapter.create(this, keyFactory); + public Propagation create(KeyFactory ignored) { + throw new UnsupportedOperationException("As of Brave 5.12, call PropagationFactory.get()"); + } + + @Override + public Propagation get() { + return this; } }