From a6e23231e1040681883dddeb660569f00bbca60b Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 7 Mar 2018 20:18:36 -0500 Subject: [PATCH] Brought back the 128 bit property setting --- .../cloud/sleuth/autoconfig/SleuthProperties.java | 11 +++++++++++ .../sleuth/autoconfig/TraceAutoConfiguration.java | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/SleuthProperties.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/SleuthProperties.java index 51a336c1f..78f105b5c 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/SleuthProperties.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/SleuthProperties.java @@ -31,6 +31,9 @@ public class SleuthProperties { private boolean enabled = true; + /** When true, generate 128-bit trace IDs instead of 64-bit ones. */ + private boolean traceId128 = false; + /** * List of baggage key names that should be propagated out of process. * These keys will be prefixed with `baggage` before the actual key. @@ -59,6 +62,14 @@ public class SleuthProperties { this.enabled = enabled; } + public boolean isTraceId128() { + return this.traceId128; + } + + public void setTraceId128(boolean traceId128) { + this.traceId128 = traceId128; + } + public List getBaggageKeys() { return this.baggageKeys; } diff --git a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java index e8172b7b8..a0bcc2a51 100644 --- a/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java +++ b/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceAutoConfiguration.java @@ -66,13 +66,15 @@ public class TraceAutoConfiguration { Propagation.Factory factory, CurrentTraceContext currentTraceContext, Reporter reporter, - Sampler sampler) { + Sampler sampler, SleuthProperties sleuthProperties) { return Tracing.newBuilder() .sampler(sampler) .localServiceName(serviceName) .propagationFactory(factory) .currentTraceContext(currentTraceContext) - .spanReporter(adjustedReporter(reporter)).build(); + .spanReporter(adjustedReporter(reporter)) + .traceId128Bit(sleuthProperties.isTraceId128()) + .build(); } private Reporter adjustedReporter(Reporter delegate) {