Skip to content

πŸš€ This project demonstrates distributed tracing in Spring Boot microservices using OpenTelemetry & Jaeger. 🧩 It includes services like order, inventory, and cart, connected via API gateway. πŸ“Š Trace requests, monitor performance, and visualize spans in Jaeger UI effortlessly with Docker Compose. 🐳✨

License

Notifications You must be signed in to change notification settings

moshclouds/OpenTelemetry-And-Jaeger-With-Springboot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ OpenTelemetry & Jaeger with Spring Boot

This is a sample microservices setup demonstrating observability using OpenTelemetry and Jaeger with a Spring Boot architecture.

The goal is to show how to enable tracing across multiple services, visualize those traces via Jaeger, and use Docker Compose for a quick local environment.

Image

🧩 Architecture & Components

This repo contains several microservices + support infrastructure:

  • service-registry β€” Eureka / Consul or similar for service discovery
  • configserver β€” Central configuration server for all services
  • api-gateway β€” Entry point (REST API) routing to downstream services
  • inventory-service β€” Handles inventory related operations
  • order-service β€” Manages orders
  • cart-service β€” Shopping cart logic

Plus:

  • docker-compose.yaml to bring up Jaeger.
  • Distributed tracing setup using OpenTelemetry to send trace data to Jaeger

βš™οΈ Prerequisites

Make sure you have the following installed:

  • Java 17 (or whichever version the services are using)
  • Maven / Gradle (depending on how the projects are built)
  • Docker & Docker Compose
  • Git

πŸš€ Getting Started

These steps will get the project up and running locally.

  1. Clone the repo

    git clone https://github.com/moshclouds/OpenTelemetry-And-Jaeger-With-Springboot.git
    cd OpenTelemetry-And-Jaeger-With-Springboot
    
  2. Build the services

    For each microservice, you might run something like:

    cd <service-folder>
    mvn clean package   # or ./gradlew build
  3. Start everything with Docker Compose

    docker-compose up --build

    This will bring up:

    • Jaeger (UI + collector)
    • All microservices
    • Service registry
    • Config server
    • Gateway
  4. Verify

    • Go to Jaeger UI, usually at: http://localhost:16686
    • Make some requests to the API Gateway or services via e.g. curl or Postman
    • Observe traces appearing in Jaeger UI

πŸ”§ Configuration

Some key configuration items:

  • application.properties / application.yml in each service must have:

    • Service name (e.g. spring.application.name)
    • OpenTelemetry exporter endpoint (e.g. OTLP or Jaeger collector)
    • Sampling probability (e.g. send all vs some traces)
  • Docker Compose:

    • Ports for Jaeger UI (e.g. 16686)
    • Ports for OTLP / gRPC if needed

πŸ“‚ File Structure

Here’s roughly how the repo is organized:

/
β”œβ”€β”€ api-gateway/
β”œβ”€β”€ cart-service/
β”œβ”€β”€ inventory-service/
β”œβ”€β”€ order-service/
β”œβ”€β”€ configserver/
β”œβ”€β”€ service-registry/
β”œβ”€β”€ docker-compose.yaml
β”œβ”€β”€ README.md
└── LICENSE

Each folder represents a Spring Boot service with its source, configs, etc.


πŸ§ͺ Usage & Examples

After everything is up:

  • Hit endpoints through the api-gateway (for example: GET /orders/{id}, or whatever the exposed endpoints are)
  • Watch how the trace spans propagate through api-gateway β†’ order-service β†’ inventory-service (or similar flow)
  • In Jaeger, you should see a trace UI showing each span, timings, response times, etc.

Image

Image

Image

Image

πŸ’‘ Tips & Best Practices

  • Use high sampling probability during development; lower it in production to reduce overhead
  • Tag spans with useful metadata (HTTP method, status code, service names)
  • Use correlation IDs in your logs so that logs + traces together help diagnose issues
  • Secure your Jaeger / OTLP endpoints if used in non-local environments

πŸ› οΈ Troubleshooting

Problem Possible Causes Solutions
No traces showing in Jaeger Exporter misconfigured or wrong endpoint Check application.yml / OTLP / jaeger config
Services not registering with registry Registry address wrong or service not started after registry Ensure service-registry is up and reachable
Docker ports conflict Another service using same port Modify ports in docker-compose.yaml

πŸ“œ License

This project is licensed under the MIT License. See LICENSE for details.


πŸ™Œ Acknowledgements

  • OpenTelemetry community
  • Jaeger project
  • Spring Boot / Spring Cloud

If you have suggestions or improvements, pull requests are very welcome! πŸ’¬

About

πŸš€ This project demonstrates distributed tracing in Spring Boot microservices using OpenTelemetry & Jaeger. 🧩 It includes services like order, inventory, and cart, connected via API gateway. πŸ“Š Trace requests, monitor performance, and visualize spans in Jaeger UI effortlessly with Docker Compose. 🐳✨

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages