ONYX
ONYX

Reputation: 1

spring cloud sleuth cannot geerate spanID

it is necessary to generate a span-id for all that gets into the console log, but unfortunately the span-id is not generated:

2019-03-13 12:35:27.116  INFO [core.data,,,] 13304 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@1fd386c3: startup date [Wed Mar 13 12:35:27 MSK 2019]; root of context hierarchy
2019-03-13 12:35:27.268  INFO [core.data,,,] 13304 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-03-13 12:35:27.298  INFO [core.data,,,] 13304 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$66207a2f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2019-03-13 14:58:43,737+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-13 14:58:43,737+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'webMvcMetricsFilter' to: [/*]
2019-03-13 14:58:43,738+0300 p=INFO l=org.springframework.boot.web.servlet.FilterRegistrationBean trace-id= span-id= Mapping filter: 'unauthorizedLogbookFilter' to: [/*]

application.yml

    logging:
      config: classpath:config/logging/logback.xml
    pattern:
      console: '%d{"yyyy-MM-dd HH:mm:ss,SSSZ"} %clr(p=%level) %clr(t=%t){yellow} %clr(l=%logger){magenta} %clr(trace-id=%X{X-B3-TraceId:-}){blue} %clr(span-id=%X{X-B3-SpanId:-}){cyan} %msg%n'

      level:
        org.hibernate: info
        org.springframework: info

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <!--spring defaults-->
  <include 
    resource="org/springframework/boot/logging/logback/defaults.xml"/>
  <include resource="org/springframework/boot/logging/logback/console- 
appender.xml"/>
<!--custom configurations-->
<include resource="config/logging/file-appender.xml"/>

<!-- level configurations-->
<root level="INFO">
    <appender-ref ref="CONSOLE"/>
    <appender-ref ref="FILE"/>
</root>

span-id generation occurs for an explicitly called logging method:

Logger log = loggerFactory().getLogger(this.class);
public void method(){ log.info("test"); }

Upvotes: 0

Views: 1451

Answers (2)

Rahul
Rahul

Reputation: 138

First create an Rest Api and make an api request to it, if not already done. If you are using Restemplate try creating a RestTemplate bean.

Also set the logging level to debug

logging.level.org.springframework.web.servlet.DispatcherServlet=DEBUG

Upvotes: 1

jramapurath
jramapurath

Reputation: 271

It's not necessary to generate a span-id for all that gets into the console log. Hit your API's then you can see the span-id and trace-id in your logs in console.

Upvotes: 0

Related Questions