Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Question 7 of 10 · Microservices with Spring Cloud
Interview question

How does distributed tracing work in Spring Cloud microservices (Sleuth, Micrometer Tracing, Zipkin)? स्प्रिंग क्लाउड माइक्रोसर्विसेज़ में डिस्ट्रिब्यूटेड ट्रेसिंग कैसे काम करती है (Sleuth, Micrometer Tracing, Zipkin)?

Answer

A single user request in a microservices system often flows through multiple services, making it hard to debug latency or failures using each service's isolated logs alone. Distributed tracing solves this by tagging a request with a unique trace ID when it enters the system, propagating that ID across every downstream service call, and recording a span (with timing) for each hop.

Micrometer Tracing (the modern replacement for Spring Cloud Sleuth) instruments requests automatically, injecting trace and span IDs into logs and outgoing headers so they carry through Feign calls, RestTemplate, and messaging. The collected spans are typically exported to Zipkin or Jaeger, which visualize the full request path across services as a single timeline, making it possible to pinpoint exactly which service introduced latency or an error.

management:
  tracing:
    sampling:
      probability: 1.0
  zipkin:
    tracing:
      endpoint: http://localhost:9411/api/v2/spans

माइक्रोसर्विसेज़ सिस्टम में एक ही यूज़र रिक्वेस्ट अक्सर कई सर्विसेज़ से होकर गुज़रती है, जिससे केवल हर सर्विस के अलग-अलग लॉग्स से लेटेंसी या विफलताओं को डीबग करना मुश्किल हो जाता है। डिस्ट्रिब्यूटेड ट्रेसिंग रिक्वेस्ट को सिस्टम में प्रवेश करते समय एक अद्वितीय ट्रेस ID से टैग करके, और इसे हर डाउनस्ट्रीम सर्विस कॉल में प्रोपेगेट करके इसे हल करती है।

Micrometer Tracing (Spring Cloud Sleuth का आधुनिक विकल्प) रिक्वेस्ट्स को स्वचालित रूप से इंस्ट्रूमेंट करता है। एकत्रित स्पैन आमतौर पर Zipkin या Jaeger को एक्सपोर्ट किए जाते हैं, जो सर्विसेज़ में पूरे रिक्वेस्ट पथ को एक ही टाइमलाइन के रूप में विज़ुअलाइज़ करते हैं।

management:
  tracing:
    sampling:
      probability: 1.0

Was this answer clear?