Distributed Tracing with Spring Cloud Jaeger


Implementing Jaeger Tracing

public class Controller {

private static final Logger logger = LoggerFactory.getLogger(Controller.class);
private RestTemplate restTemplate;

private String applicationName;

public Controller(RestTemplate restTemplate) {
this.restTemplate = restTemplate;

public ResponseEntity path1() {

logger.info("Incoming request at {} for request /path1 ", applicationName);
String response = restTemplate.getForObject("http://localhost:8090/service/path2", String.class);
return ResponseEntity.ok("response from /path1 + " + response);

public ResponseEntity path2() {
logger.info("Incoming request at {} at /path2", applicationName);
return ResponseEntity.ok("response from /path2 ");
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
version: "3.3"
image: jaegertracing/all-in-one:1.25
- 6831:6831/udp
- 6832:6832/udp
- 16686:16686
- 14268:14268
url: http://localhost:14268/api/traces
java -jar \
target/Distributed-Service-0.0.1-SNAPSHOT.jar \
--spring.application.name=Service-1 \
java -jar \
target/Distributed-Service-0.0.1-SNAPSHOT.jar \
--spring.application.name=Service-2 \
curl -i http://localhost:8080/service/path1
INFO 69938 --- [nio-8080-exec-1] i.j.internal.reporters.LoggingReporter   : Span reported: ed70bbaa2bd5b42f:c7c94163fc95fc1e:ed70bbaa2bd5b42f:1 - GET
INFO 69885 --- [nio-8090-exec-1] i.j.internal.reporters.LoggingReporter   : Span reported: ed70bbaa2bd5b42f:e9060cb1d5336c55:c7c94163fc95fc1e:1 - path2





Software Craftsman, Tech Enthusiast. I run https://refactorfirst.com to post all my articles

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Did GitHub just start the Junior Developer as a Service era?

5 Mistakes You Can Make in Development

Sugui Digest — SE01EP14 — Fear.

Designing the Swiggy app to be truly ‘accessible’ | Episode-2

Open-source Rapid application development platform

Introduction to the Topos Reliable Broadcast

Kubernetes vs Openshift in Container Management World

WordPress Application on AWS with MySQL Database

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Amrut Prabhu

Amrut Prabhu

Software Craftsman, Tech Enthusiast. I run https://refactorfirst.com to post all my articles

More from Medium

Java — Dr. Strange Heap (or How I Learned to Stop Worrying and Love the Metaspace)

Spring Boot Liquibase Integration

Prometheus Monitoring Using Spring Boot

RSocket using Spring Boot