# 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](https://gitea.libretechconsulting.com/rmcguire/go-app) 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 1. 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` 1. **Rename your package:** ```sh make rename NAME=my.gitremote.com/pathto/repo ``` 1. **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. 1. **Generate a new JSON schema:** ```sh make schema ``` - Ensure your structs have `yaml` and `json` tags. - With the `yaml-language-server` LSP plugin, the schema will be auto-detected in your `config.yaml`. 1. **Compile proto files:** ```sh make proto ``` - Add paths under `proto/` as necessary. 1. **Implement your application logic.** 1. **Update Gitea CI configuration:** Modify parameters in `.gitea/workflows/ci.yaml` as needed. 1. Tag your release: `git tag v0.1.0` and push `git push --tags` --- ## 📂 Project Structure - `proto/` - Protobuf definitions and generated files. - `api/` - Auto-generated code for proto, grpc-gateway, and OpenAPI2 spec - `pkg/config/` - Custom config, merged with go-app configuration - `pkg/demo(http|grpc)/` - HTTP and GRPC server implementations - `helm/` - 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! 🎉