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.

Spring Cloud Gateway and Sleuth / Zipkin integration

See original GitHub issue

Bug report spring-cloud-version: Greenwich.M3

We used Spring Cloud Gateway and we starting to integrate Sleuth / Zipkin.

We make this workflow :

client ----> SpringCloudGateway ------> PatientService ------> EpisodeOfCareService

and we have activate DEBUG logs for Sleuth in SC, PS and EOCS apps logging.level.org.springframework.cloud.sleuth: DEBUG In Postman or Chrome, we call http://localhost/patient/97005400/with-eds this is pass througth Gateway, PatientService and EpisodeOfCareService

logs are : Gateway :

2018-11-22 15:11:49.412 DEBUG [gateway-service,,,] 18792 --- [ctor-http-nio-4] o.s.c.s.instrument.web.TraceWebFilter    : Received a request to uri [/patient/97005400/with-eds]
2018-11-22 15:11:49.412 DEBUG [gateway-service,,,] 18792 --- [ctor-http-nio-4] o.s.c.s.instrument.web.TraceWebFilter    : Handled receive of span RealSpan(da30b8233cab261f/da30b8233cab261f)
2018-11-22 15:11:49.471 DEBUG [gateway-service,da30b8233cab261f,da30b8233cab261f,true] 18792 --- [ctor-http-nio-4] o.s.c.s.instrument.web.TraceWebFilter    : Handled send of RealSpan(da30b8233cab261f/da30b8233cab261f)
2018-11-22 15:11:49.818 DEBUG [gateway-service,,,] 18792 --- [ender@1cba0321}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : HTTP POST http://vmlt-00008.hcuge.ch:9411/api/v2/spans
2018-11-22 15:11:49.818 DEBUG [gateway-service,,,] 18792 --- [ender@1cba0321}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Accept=[text/plain, application/json, application/*+json, */*]
2018-11-22 15:11:49.818 DEBUG [gateway-service,,,] 18792 --- [ender@1cba0321}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Writing [[B@5c213931] as "application/json"
2018-11-22 15:11:49.823 DEBUG [gateway-service,,,] 18792 --- [ender@1cba0321}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Response 202 ACCEPTED

PatientService :

2018-11-22 15:11:49.451  INFO [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] c.h.p.controller.PatientController       : Patient find: id=97005400
2018-11-22 15:11:49.451 DEBUG [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] c.s.i.w.c.f.TraceLoadBalancerFeignClient : Before send
2018-11-22 15:11:49.452 DEBUG [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] o.s.c.s.i.w.c.f.LazyTracingFeignClient   : Sending a request via tracing feign client [org.springframework.cloud.sleuth.instrument.web.client.feign.TracingFeignClient@489534aa] and the delegate [feign.Client$Default@50872e76]
2018-11-22 15:11:49.452 DEBUG [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] o.s.c.s.i.w.c.feign.TracingFeignClient   : Handled send of RealSpan(6b568740db93adf6/4077b43e2a74a1ed)
2018-11-22 15:11:49.465 DEBUG [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] o.s.c.s.i.w.c.feign.TracingFeignClient   : Handled receive of RealSpan(6b568740db93adf6/4077b43e2a74a1ed)
2018-11-22 15:11:49.466 DEBUG [patient-service,6b568740db93adf6,6b568740db93adf6,true] 20456 --- [nio-8001-exec-3] c.s.i.w.c.f.TraceLoadBalancerFeignClient : After receive

EpisodeOfCareService :

2018-11-22 15:11:49.461  INFO [episodeofcare-service,6b568740db93adf6,4077b43e2a74a1ed,true] 14664 --- [nio-8101-exec-2] c.h.e.c.EpisodeOfCareController          : Eds find: id=11111111
2018-11-22 15:11:50.127 DEBUG [episodeofcare-service,,,] 14664 --- [ender@4bbf20d1}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : HTTP POST http://vmlt-00008.hcuge.ch:9411/api/v2/spans
2018-11-22 15:11:50.128 DEBUG [episodeofcare-service,,,] 14664 --- [ender@4bbf20d1}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Accept=[text/plain, application/json, application/*+json, */*]
2018-11-22 15:11:50.128 DEBUG [episodeofcare-service,,,] 14664 --- [ender@4bbf20d1}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Writing [[B@823c21e] as "application/json"
2018-11-22 15:11:50.134 DEBUG [episodeofcare-service,,,] 14664 --- [ender@4bbf20d1}] o.s.c.s.z.s.ZipkinRestTemplateWrapper    : Response 202 ACCEPTED

As you can see, traceId are différents between Gateway and PatientService/EpisodeOfCareService. So in Zipkin, there is no correlation : image

gateway config : gateway-build.gradle.txt application.yml

---
# This default profile is used when running a single instance completely standalone:
spring:
  profiles: default
  application:
    name: gateway-service
  cloud:
    gateway:
      discovery:
        locator:
          enabled: true
      routes:
      - id: patient-service
        uri: lb://patient-service
        predicates:
        - Path=/patient/**
        filters:
        - RewritePath=/patient/(?<segment>.*), /$\{segment}
  zipkin:
    base-url: http://xxxxx:9411
    sender:
      type: web
    service:
      name: ${spring.application.name}  
  sleuth:
    sampler:
      probability: 1     
management:
  endpoints:
    web:
      exposure:
        include: "*"  
  endpoint:
    health:
      show-details: ALWAYS
eureka:
  instance:
    lease-expiration-duration-in-seconds: 10
    lease-renewal-interval-in-seconds: 10    
    instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
  client:
    registerWithEureka: true
    fetchRegistry: true
    prefer-same-zone-eureka: true
    serviceUrl:
      defaultZone: ${EUREKA_CLIENT_SERVICE_URL_DEFAULT_ZONE:http://localhost:8761/eureka}
    registry-fetch-interval-seconds: 10
    region: ${ZONE:us-east-1}
logging:
  level:
    org.springframework.cloud.sleuth: DEBUG

Patient : patient-build.gradle.txt application.yml

---
# This default profile is used when running a single instance completely standalone:
spring:
  profiles: default
  zipkin:
    base-url: http://xxxxx:9411
    sender:
      type: web
    service:
      name: ${spring.application.name}  
  sleuth:
    sampler:
      probability: 1 
eureka:  
  instance:
    lease-renewal-interval-in-seconds: 30
    health-check-url-path: /actuator/health
    prefer-ip-address: ${EUREKA_INSTANCE_PREFER_IP_ADDRESS:false}   # forcer l'enregistrement par adresse IP
  client:
    registry-fetch-interval-seconds: 30
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: ${EUREKA_CLIENT_SERVICE_URL_DEFAULT_ZONE:http://localhost:8761/eureka}
    region: ${ZONE:us-east-1} 
management:
  endpoints:
    web:
      exposure:
        include: "*"  
  endpoint:
    health:
      show-details: ALWAYS
logging:
  level:
    org.springframework.cloud.sleuth: DEBUG

EOCS : eds-build.gradle.txt application.yml (same as patient-service)

What are we doing wrong ? Thanks for your help

Issue Analytics

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

github_iconTop GitHub Comments

4reactions
alex0ptrcommented, Dec 10, 2018

We ran into the same issue with Greenwich.M2. Can also confirm on Greenwich.M3. We used httpbin.org/headers as upstream. The headers are definitely missing.

application.yml:

spring:
  sleuth:
    enabled: true
    sampler.probability: 1
  zipkin:
    enabled: true
    base-url: replace_me
1reaction
thekalingacommented, Mar 7, 2019

I was using Greenwich.RELEASE before. I now switched to Greenwich.SR1 based on @marcingrzejszczak 's advice. The header propagation now works

@marcingrzejszczak @guerricm Thanks!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Cloud Sleuth
If spring-cloud-sleuth-zipkin is on the classpath, the app generates and collects Zipkin-compatible traces. By default, it sends them over HTTP to a Zipkin...
Read more >
Spring Cloud Tutorial - Distributed Log Tracing using Sleuth ...
Spring Cloud Sleuth is used to generate and attach the trace id, span id to the logs so that these can then be...
Read more >
Distributed Tracing with Spring Cloud Sleuth And Zipkin
We would learn how we can implement distributed tracing in a Spring Boot Application and understand the key concepts of distributed tracing.
Read more >
Spring Cloud: Distributed Tracing with Sleuth - Stack Abuse
The spring.zipkin.baseUrl property tells Spring and Sleuth where to push data to. Also, by default, Spring Cloud Sleuth sets all spans to non- ......
Read more >
Spring Cloud - Zipkin and Sleuth - HowToDoInJava
Spring Cloud – Zipkin and Sleuth ... Zipkin is a very efficient tool for distributed tracing in the microservices ecosystem. Distributed tracing, ...
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