This repository contains a microservices-based application demonstrating the integration of OpenTelemetry and SigNoz for observability. It's designed to showcase how different services such as orders, payments, products, and users can be monitored in a distributed system.
- Docker and Docker Compose installed
- Node.js installed
- Access to MongoDB
-
Clone the repository
git clone https://github.com/your-repository/opentelemetry-signoz-sample.git cd opentelemetry-signoz-sample
-
Build and run the services using Docker Compose
docker-compose up --build
- Backend: Node.js with Express
- Database: MongoDB
- Observability: OpenTelemetry, SigNoz
- Containerization: Docker, Docker Compose
order-service/
: Contains all files related to the Order service including its Dockerfile and server logic.payment-service/
: Contains all files for the Payment service.product-service/
: Manages the Product service files.user-service/
: Holds the User service files.docker-compose.yml
: Defines how the Docker containers are built, run, and interconnect.
server.js
: Each service directory contains aserver.js
which is the entry point for that service, defining APIs and connecting to the database.Dockerfile
: Used to build Docker images for each service.
Each service offers several endpoints for interacting with the application:
-
Orders
GET /orders
: Retrieves all orders, including user details.POST /orders
: Creates a new order and updates the product stock.
-
Payments
GET /payments
: Lists all payments.POST /payments
: Processes a payment for an order.
-
Products
GET /products
: Fetches all products.POST /products
: Adds a new product to the inventory.
-
Users
GET /users
: Returns all registered users.POST /users
: Registers a new user.
If you prefer to build the application from scratch rather than cloning, follow these steps:
- Set up the project structure as outlined above, creating directories and necessary files for each service.
- Write Dockerfiles for each service to containerize the applications.
- Create the Docker Compose file to define and run multi-container Docker applications.
- Implement the server logic in
server.js
for each service to handle API requests and interact with the database. - Integrate OpenTelemetry to capture telemetry data and configure it to communicate with SigNoz for visualizing data.
- Service discovery issues: Ensure all services are correctly referenced in
docker-compose.yml
and network configurations are correct. - Database connectivity issues: Double-check MongoDB URIs and network access settings in Docker.
- Endpoint failures: Verify that all routes are correctly implemented and tested. Check server logs for detailed error messages.
- Configuration errors in Docker Compose: Ensure that ports, volumes, and dependency definitions are correct.