Skip to content

Basic example of how tracing could be implemented in microservices. Ideally you would want to hide some of the boilerplating in middlewares.

Notifications You must be signed in to change notification settings

happsie/jaeger-example

Repository files navigation

Simple jaeger and golang example

This example contains two services (flights and passengers) with two different mysql instances (flights and passengers). Making any interactions with the API of any service will report it to jaeger.

Learn more about OpenTelemetry here

Setup

Use host port for curl requests from host machine

Name Type Host Port Container port
jaeger Jaeger:all-in-one 6831/udp, 14269, 16686 6831/udp, 14269, 16686
flight-db MySQL 3306 3306
passenger-db MySQL 3307 3306
flight-service Go service 8080 8080
passenger-service Go service 8090 8080

Running

Running this project requires docker and docker-compose version 1.29.2.

  1. git clone https://github.com/Jepzter/jaeger-example.git
  2. Optional Choose in docker-compose if you want passenger-service to be unstable and simulate errors. Set environment UNSTABLE=true. Default is false
  3. Run docker-compose up in jaeger-example directory
  4. Make a request defined in any of the apis below
  5. Navigate to to jaeger ui
  6. Select flight-service or passenger-service in the services dropdown menu
  7. Click Find traces
  8. Select a trace to view it's timeline

Flight service API

Get flight

GET http://localhost:8080/api/flight-service/flight-v1/1
Parameter Type Description
Flight ID integer Required. The ID of the flight. Example contains only ID 1 and 2

Response

{
    "FlightID": 1,
    "Name": "FLIGHT 33",
    "Destination": "VXO",
    "Passengers": [
        {
            "PassengerID": 1,
            "FlightID": 1,
            "Firstname": "Jesper",
            "Surname": "Placeholdersson"
        }
    ]
}

Passenger service API

Get passengers

GET http://localhost:8090/api/passenger-service/passenger-v1?flightId=1
Parameter Type Description
FlightId integer Optional. The ID of the flight. Example contains only ID 1 and 2

Response

[
    {
        "PassengerID": 1,
        "FlightID": 1,
        "Firstname": "Jesper",
        "Surname": "Placeholdersson"
    }
]

About

Basic example of how tracing could be implemented in microservices. Ideally you would want to hide some of the boilerplating in middlewares.

Topics

Resources

Stars

Watchers

Forks