go-server-with-otel 🚀
A powerful and flexible template for building Go HTTP + GRPC servers with full OpenTelemetry (OTEL) support. Bootstrapped with the go-app framework to provide all the bells and whistles right out of the box. Ideal for rapidly creating production-ready microservices.
Check out the go-app framework for more detail there.
🌟 Features
- 📈 OpenTelemetry (OTEL) Metrics & Traces – Comprehensive observability with built-in support for metrics and traces.
- 📝 Logging with Zerolog – High-performance structured logging with zerolog for ultra-fast, leveled logging.
- 💬 GRPC + GRPC-Gateway – Supports RESTful JSON APIs alongside gRPC with auto-generated Swagger (OpenAPI2) specs.
- 🌐 HTTP and GRPC Middleware – Flexible middleware support for HTTP and GRPC to enhance request handling, authentication, and observability.
- 📦 Multi-Arch Builds – Robust Makefile that supports building for multiple architectures (amd64, arm64, etc.).
- 🐳 Docker Image Generation – Easily build Docker images using
make docker
. - 📜 Config Schema Generation – Automatically generate JSON schemas for configuration validation.
- 📝 Proto Compilation – Seamlessly compile .proto files with
make proto
. - 🔄 Project Renaming – Easily rename your project using
make rename NAME=your.gitremote.com/pathto/repo
. - 📦 Helm Chart – Deploy your application with Kubernetes using the provided Helm chart.
- 🤖 Gitea CI Integration – Out-of-the-box Gitea CI pipeline configuration with
.gitea/workflows/ci.yaml
. - ⚙️ Expandable Configuration – Extend your app-specific configuration with go-app's built-in logging, HTTP, and GRPC config support.
📚 Getting Started
-
Install tools:
- Install make, protoc, and go using brew, apt, etc..
- Install protoc plugins (provided in go.mod tool()):
go get -v tool && go install -v tool
-
Rename your package:
make rename NAME=my.gitremote.com/pathto/repo
-
Review the config struct: Update and customize your app-specific configuration. This merges with go-app's configuration, providing logging, HTTP, and GRPC config for free.
-
Generate a new JSON schema:
make schema
- Ensure your structs have
yaml
andjson
tags. - With the
yaml-language-server
LSP plugin, the schema will be auto-detected in yourconfig.yaml
.
- Ensure your structs have
-
Compile proto files:
make proto
- Add paths under
proto/
as necessary.
- Add paths under
-
Implement your application logic.
-
Update Gitea CI configuration: Modify parameters in
.gitea/workflows/ci.yaml
as needed. -
Tag your release:
git tag v0.1.0
and pushgit push --tags
📂 Project Structure
proto/
- Protobuf definitions and generated files.api/
- Auto-generated code for proto, grpc-gateway, and OpenAPI2 specpkg/config/
- Custom config, merged with go-app configurationpkg/demo(http|grpc)/
- HTTP and GRPC server implementationshelm/
- Helm chart for deploying your application to Kubernetes..gitea/workflows/
- CI pipelines for automated builds and tests.
🔥 Ready to build something awesome? Let's go! 🎉
Languages
Go
69.2%
Makefile
25.5%
Dockerfile
5.3%