https://github.com/moshclouds/opentelemetry-and-jaeger-with-springboot
π 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. π³β¨
https://github.com/moshclouds/opentelemetry-and-jaeger-with-springboot
jaeger microservice observability opentelemetry spring-boot traces
Last synced: 4 days ago
JSON representation
π 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. π³β¨
- Host: GitHub
- URL: https://github.com/moshclouds/opentelemetry-and-jaeger-with-springboot
- Owner: moshclouds
- License: mit
- Created: 2025-09-13T07:40:00.000Z (26 days ago)
- Default Branch: main
- Last Pushed: 2025-09-13T17:43:09.000Z (26 days ago)
- Last Synced: 2025-09-13T19:31:24.885Z (26 days ago)
- Topics: jaeger, microservice, observability, opentelemetry, spring-boot, traces
- Language: Java
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# π 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.
## π§© 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 logicPlus:
- `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**
```bash
git clone https://github.com/moshclouds/OpenTelemetry-And-Jaeger-With-Springboot.git
cd OpenTelemetry-And-Jaeger-With-Springboot2. **Build the services**
For each microservice, you might run something like:
```bash
cd
mvn clean package # or ./gradlew build
```3. **Start everything with Docker Compose**
```bash
docker-compose up --build
```This will bring up:
* Jaeger (UI + collector)
* All microservices
* Service registry
* Config server
* Gateway4. **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.
![]()
![]()
![]()
![]()
---
## π‘ 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](LICENSE) for details.
---
## π Acknowledgements
* OpenTelemetry community
* Jaeger project
* Spring Boot / Spring Cloud---
*If you have suggestions or improvements, pull requests are very welcome!* π¬