question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TraceID are not presented properly

See original GitHub issue

Bug report

  • Kotlin 1.3
  • Spring Boot v2.1.0.RELEASE
  • WebFlux
  • Spring Cloud Sleuth (Spring Cloud Dependencies Finchley.SR1)

Sample code 1 🙆‍♂️

Send http requests synchronously …

class CartApiController(
    // ...

    @GetMapping("items")
    fun fetchItems(
        userIdentifiers: UserIdentifiers
    ) :String {
        log.info("*********** TEST ***********")
        testHttpRequest("test1")
        testHttpRequest("test2")
        testHttpRequest("test3")
        return "{}"
    }

    // ...
}

Logs

The TraceID ea404a5d1bb61f73 is presented properly.

2018-12-13 18:54:03.993 					TRACE [       reactor-http-nio-2] o.s.w.s.a.HttpWebHandlerAdapter                    :       [8788eec2] HTTP GET "/sf/api/cart/items", headers={masked} 
2018-12-13 18:54:04.007 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.RequestMappingHandlerMapping         :       [8788eec2] Mapped to public java.lang.String jp.lohaco.sf.web.controller.api.CartApiController.fetchItems(jp.lohaco.sf.domain.entity.user.UserIdentifiers) 
2018-12-13 18:54:04.010 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	INFO  [       reactor-http-nio-2] j.l.s.w.c.a.CartApiController                      :       *********** TEST *********** 
2018-12-13 18:54:04.012 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [21cfbae3] HTTP GET http://127.0.0.1:9999/?a=test1, headers={masked} 
2018-12-13 18:54:04.015 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [3598fdaf] HTTP GET http://127.0.0.1:9999/?a=test2, headers={masked} 
2018-12-13 18:54:04.019 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [5cbec266] HTTP GET http://127.0.0.1:9999/?a=test3, headers={masked} 
2018-12-13 18:54:04.020 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler            :       Using 'application/json;charset=UTF-8;q=0.8' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] and supported [application/json;charset=UTF-8] 
2018-12-13 18:54:04.020 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler            :       [8788eec2] 0..1 [java.lang.String] 
2018-12-13 18:54:04.021 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [8788eec2] Writing "{}" 
2018-12-13 18:54:04.024 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.s.a.HttpWebHandlerAdapter                    :       [8788eec2] Completed 200 OK, headers={masked} 
2018-12-13 18:54:04.024 					TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [8788eec2] Handling completed 
2018-12-13 18:54:04.038 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [21cfbae3] Response 200 OK, headers={masked} 
2018-12-13 18:54:04.041 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [21cfbae3] Decoded 
2018-12-13 18:54:04.050 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [3598fdaf] Response 200 OK, headers={masked} 
2018-12-13 18:54:04.053 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [3598fdaf] Decoded "
2018-12-13 18:54:04.071 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [5cbec266] Response 200 OK, headers={masked} 
2018-12-13 18:54:04.074 		ea404a5d1bb61f73	ea404a5d1bb61f73	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [5cbec266] Decoded 

Sample code 2 🙅‍♂️ 🙅‍♂️ 🙅‍♂️

Send http requests with coroutine …

class CartApiController(
    // ...

    @GetMapping("items")
    fun fetchItems(
        userIdentifiers: UserIdentifiers
    ) = runBlocking {
        log.info("*********** TEST ***********")
        GlobalScope.async {
            testHttpRequest("test1")
            testHttpRequest("test2")
            testHttpRequest("test3")
        }.await()
    }

    // ...
}

Logs

The TraceIDs are not presented proprly. The IDs should be single value as well as the sample code 1.

2018-12-13 18:33:20.871 					TRACE [       reactor-http-nio-2] o.s.w.s.a.HttpWebHandlerAdapter                    :       [79598515] HTTP GET "/sf/api/cart/items", headers={masked} 
2018-12-13 18:33:20.886 		2819c16fa83e6725	2819c16fa83e6725	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.RequestMappingHandlerMapping         :       [79598515] Mapped to public reactor.core.Disposable {*masked*}
2018-12-13 18:33:20.889 		2819c16fa83e6725	2819c16fa83e6725	false	INFO  [       reactor-http-nio-2] j.l.s.w.c.a.CartApiController                      :       *********** TEST *********** 
2018-12-13 18:33:20.892 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [efaultDispatcher-worker-1] o.s.w.r.f.c.ExchangeFunctions                      :       [7f9a91cd] HTTP GET http://127.0.0.1:9999/?a=test1, headers={masked} 
2018-12-13 18:33:20.896 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [efaultDispatcher-worker-1] o.s.w.r.f.c.ExchangeFunctions                      :       [28fc35d1] HTTP GET http://127.0.0.1:9999/?a=test2, headers={masked} 
2018-12-13 18:33:20.901 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [efaultDispatcher-worker-1] o.s.w.r.f.c.ExchangeFunctions                      :       [549aedbd] HTTP GET http://127.0.0.1:9999/?a=test3, headers={masked} 
2018-12-13 18:33:20.903 		2819c16fa83e6725	2819c16fa83e6725	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler            :       Using 'application/json;charset=UTF-8;q=0.8' given [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] and supported [application/json;charset=UTF-8] 
2018-12-13 18:33:20.903 		2819c16fa83e6725	2819c16fa83e6725	false	DEBUG [       reactor-http-nio-2] o.s.w.r.r.m.a.ResponseBodyResultHandler            :       [79598515] 0..1 [reactor.core.Disposable] 
2018-12-13 18:33:20.904 		2819c16fa83e6725	2819c16fa83e6725	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [79598515] Encoding [reactor.core.publisher.LambdaMonoSubscriber@4adfa453] 
2018-12-13 18:33:20.908 		2819c16fa83e6725	2819c16fa83e6725	false	TRACE [       reactor-http-nio-2] o.s.w.s.a.HttpWebHandlerAdapter                    :       [79598515] Completed 200 OK, headers={masked} 
2018-12-13 18:33:20.909 					TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [79598515] Handling completed 
2018-12-13 18:33:20.958 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-4] o.s.w.r.f.c.ExchangeFunctions                      :       [28fc35d1] Response 200 OK, headers={masked} 
2018-12-13 18:33:20.963 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-4] o.s.w.HttpLogging                                  :       [28fc35d1] Decoded "{*masked*}*
2018-12-13 18:33:20.973 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [7f9a91cd] Response 200 OK, headers={masked} 
2018-12-13 18:33:20.976 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [7f9a91cd] Decoded "{*masked*}"
2018-12-13 18:33:20.986 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-2] o.s.w.r.f.c.ExchangeFunctions                      :       [549aedbd] Response 200 OK, headers={masked} 
2018-12-13 18:33:20.990 		5787dfcb2b3ca394	5787dfcb2b3ca394	false	TRACE [       reactor-http-nio-2] o.s.w.HttpLogging                                  :       [549aedbd] Decoded "{*masked*}"

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
marcingrzejszczakcommented, Jan 7, 2019

Ok let’s close this one and leave the one in Brave

0reactions
ackintoshcommented, Dec 14, 2018

Thanks. 🙏✨ I’ll check it out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not observe TraceId & SpanId in Spring Cloud Sleuth
I am trying to run Spring Cloud Sleuth and observe traceid, span id oin logs. I have configured as below but when i...
Read more >
Correlated Logs Are Not Showing Up In The Trace ID Panel
If this process is not working as expected, ensure the logs attribute's name containing the trace ID is dd.trace_id and verify that the...
Read more >
Spring Cloud Sleuth
To ensure that your application name is properly displayed in Zipkin, ... Most notably, this means the trace ID and span IDs are...
Read more >
Trace an Application Load Balancer request using X-Amzn ...
Log the identifier and then use it to troubleshoot issues with your load balancer. For example, use the X-Amzn-Trace-Id header to identify ...
Read more >
Instrumenting a library · OpenZipkin
Let's walk through how Spans are identified. When an incoming request has no trace information attached, we generate a random trace ID and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found