0

I am trying to add span context like below, with spring boot 2.0 and sleuth version 2.0.RC1/2.0.RC2

Span initialSpan = _tracer.nextSpan().name("span").start();
try( Tracer.SpanInScope ws = _tracer.withSpanInScope(initialSpan) ) {
    ExtraFieldPropagation.set("foo", "bar");
    ExtraFieldPropagation.set("UPPER_CASE", "someValue");
}

after setting the data when trying to retrieve getting null value

ExtraFieldPropagation.get("foo")
Chandra
  • 1
  • 2
  • That might be related to https://github.com/openzipkin/brave/issues/682 – Marcin Grzejszczak May 30 '18 at 14:38
  • Do you retrieve the key in the same method or in another service? – Marcin Grzejszczak May 30 '18 at 14:41
  • 1
    I have to retrieve in different service, but for testing purpose doing in same method and still getting null. – Chandra May 30 '18 at 14:59
  • 1
    The same method won't work IMO - check this out https://github.com/spring-cloud-samples/sleuth-documentation-apps here we set the baggage https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service1/src/main/java/io/spring/cloud/sleuth/docs/service1/Service2Client.java#L50 and here we retrieve it https://github.com/spring-cloud-samples/sleuth-documentation-apps/blob/master/service2/src/main/java/io/spring/cloud/sleuth/docs/service2/Application.java#L87 and it works fine `Service2Controller : Service2: Baggage for [key] is [foo]` – Marcin Grzejszczak May 30 '18 at 15:03
  • when i observed the code, find(context.extra()) is always returning empty even after set. please find the below class and method. public abstract class PropagationFields {} public static void put(TraceContext context, String name, String value) { if (context == null) throw new NullPointerException("context == null"); if (name == null) throw new NullPointerException("name == null"); if (value == null) throw new NullPointerException("value == null"); PropagationFields fields = find(context.extra()); if (fields == null) return; fields.put(name, value); } – Chandra May 30 '18 at 17:01
  • I have no idea what this comment means. Maybe let's move it to gitter? https://gitter.im/spring-cloud/spring-cloud-contract – Marcin Grzejszczak May 30 '18 at 17:02

0 Answers0