A Go-based microservice with Couchbase integration, metrics, logging and OpenTelemetry support.
This service provides REST API endpoints for managing products, utilizing Couchbase as the primary database and implementing distributed tracing with OpenTelemetry.
- Go 1.23.4
- Docker and Docker Compose
- Couchbase Server
- Language: Go
- Database: Couchbase
- Distributed Tracing: OpenTelemetry, Jaeger
- Container: Docker
- Config: Viper
- Logger: Zap
- Metrics: Prometheus
- Monitoring: Grafana
├── app
│ └── healthcheck
│── └── health.go
│ └── product
│── └── create_product_handler.go
│── └── get_product_handler.go
│── └── repository.go
├── config
│ └── config.yaml -- App Configuration File
├── domain
│ └── product.go
├── infra
│ └── couchbase
│── └── repository.go
│ └── postgres
│── └── repository.go
├── pkg
│ └── config
│── └── config.go
│ └── log
│── └── log.go
├── Dockerfile
├── docker-compose.yml
├── main.go
-
Clone the repository:
git clone https://github.com/mstrYoda/production-ready-microservice-example.git
-
Start the required services using Docker Compose:
docker-compose up -d
-
Run the application:
go run main.go
POST /products
- Create a new productGET /products/{id}
- Retrieve a product by ID
Configuration is managed through environment variables and config files and can be set in the docker-compose.yml
file. Key configuration parameters include:
- Couchbase connection settings
- OpenTelemetry configuration
- Application port
docker build -t product-service .
go test ./...
This service implements OpenTelemetry for distributed tracing, allowing you to monitor and debug requests across your distributed system.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
[Add your license information here]