spring.application.name=My Server
Maven
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
The trace and span ids will now be created and can be seen in the headers.
To log this and make it useful though is one thing but there is a graphical tool which makes this very easy.
Zipkin
Zipkin can be configured so that all Sleuth output is sent there and it allows a view of the interactions so that the times and services called can be seen. To configure and use zipkin just add another dependency,
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
</dependency>
By default everything is logged to localhost:9411 but this can be changed by adding a property
spring.zipkin.baseurl=http://zipkin:9411/
Docker
If you are running with docker you'll need to add a zipkin image into the compose file,
zipkin:
image: openzipkin/zipkin
networks:
- my-network
hostname: zipkin
ports:
- "9411:9411"
- "9411:9411"