0

I am using spring-cloud-starter-sleuth 2.0.0 M6 and due to breaking changes I cannot use my previous configuration which allows me to see the (human readable) span names in console logs instead of spanIds.

I want to see [app,98ec5c2ab34ea626,span-name,false] instead of [app,98ec5c2ab34ea626,f56b4623ee2e9a3f,false]

I used to configure it in 2.0.0M1 as follows:

class CustomSlf4jSpanLogger implements SpanLogger {


    @Override
    public void logStartedSpan(Span parent, Span span) {
        MDC.put(Span.SPAN_ID_NAME, span.getName());
        MDC.put(Span.SPAN_NAME_NAME, span.getName());
        MDC.put(Span.SPAN_EXPORT_NAME, String.valueOf(span.isExportable()));
        MDC.put(Span.TRACE_ID_NAME, span.traceIdString());
        log("Starting span: {}", span);
        if (parent != null) {
            log("With parent: {}", parent);
            MDC.put(Span.PARENT_ID_NAME, Span.idToHex(parent.getSpanId()));
        }
    }

   // the rest is omitted for brevity

}

Now SpanLogger is gone. Closest thing I could find is Slf4jCurrentTraceContext however currentSpan which is of type TraceContext has no span name in it.

How can I configure this in 2.0.0 M6?

destan
  • 4,301
  • 3
  • 35
  • 62

1 Answers1

0

That's the problem... The name is not available in a Brave's span at that point. I guess you'd have to maybe add some tag or sth and try to retrieve it in Slf4jCurrentTraceContext. I think I wrote about this here - https://github.com/spring-cloud/spring-cloud-sleuth/wiki/Spring-Cloud-Sleuth-2.0-Migration-Guide#removed-features

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32