Skip to content

A Spring Boot REST client that passes the player name to a remote service to fetch the ATP ranking of that player.

Notifications You must be signed in to change notification settings

murcoder14/sportsclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Tracing using Spring Boot 3, OpenTelemetry and Zipkin.

This code base is an attempt to learn how Distributed tracing works with Spring Boot and the open telemetry backend, Zipkin. We use 2 unsophisticated microservices, both built using Java 21 and Spring Boot 3.3.5 - SportsClient and PlayerRanker. The SportsClient calls the PlayerRanker via HTTP passing the player's name to fetch the ATP ranking. The PlayerRanker returns the ranking of the player.

Steps

Prerequisites

We need JDK 21, Spring Boot 3.3.5, Maven and the Docker Desktop to build and run the services.

Installation

Unzip the files to a folder and build them using Maven.

tmurali@fedora:~/javaprojects/sportsclient$ mvn clean package
tmurali@fedora:~/javaprojects/player-ranker-app$ mvn clean package

Execution

Start the 2 microservices in 2 separate shells

tmurali@fedora:~/javaprojects/sportsclient$ java -jar target/sportsclient.jar
tmurali@fedora:~/javaprojects/player-ranker-app$ java -jar target/player-ranker-app.jar

Launch the Zipkin agent in the 3rd shell.

tmurali@fedora:~/tools$ docker run -d -p 9411:9411 openzipkin/zipkin

Invoke the SportsClient endpoint in the 4th shell using cURL. The output of cURL is piped to jq which a JSON formatter. jq is optional.

tmurali@fedora:~/temp$ curl http://localhost:8090/players | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   198    0   198    0     0    357      0 --:--:-- --:--:-- --:--:--   357
[
  {
    "player": "Jannik Sinner",
    "ranking": 1
  },
  {
    "player": "Alex Zverev",
    "ranking": 2
  },
  {
    "player": "Carlos Alcaraz",
    "ranking": 3
  },
  {
    "player": "Daniil Medvedev",
    "ranking": 4
  },
  {
    "player": "Novak Djikovic",
    "ranking": 5
  }
]
tmurali@fedora:~/temp$ 

TRACES VIEW

Access the Zipkin Viewer at http://localhost:9411/zipkin/

The 2 services illustrated here obviously don't have any performance issues. But in the real world, when there are issues, one can dig deeper into the invocation stack by reviewing the traces and spans.

TODO

Need to make this work with Jaegar.

About

A Spring Boot REST client that passes the player name to a remote service to fetch the ATP ranking of that player.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages