Go gRPC Clean architecture microservice with Prometheus, Grafana monitoring and Jaeger opentracing ⚡️

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • Go-GRPC-Auth-Microservice

    Go GRPC Auth Microservice

  • Let's try to create closer to real world gRPC microservice with tracing and monitoring 👋: Source code u can find here Core tools used what will be used: 🚀 PostgreSQL as database Redis for sessions and caching Jaeger open source, end-to-end distributed tracing Prometheus monitoring and alerting Grafana for to compose observability dashboards with everything from Prometheus

  • validator

    :100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

  • Then we usually have to validate request input, for errors gRPC has packages status and codes I found good practice to parse and log errors in handler layer, here i use ParseGRPCErrStatusCode method, which parse err and returns matched gRPC code. Validator is good solution for validation.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • gomock

    Discontinued GoMock is a mocking framework for the Go programming language. (by golang)

  • Every app must be covered by tests, I didn't completely cover all code this one, but wrote some test of course. For testing and mocking testify and gomock is very good tools.

  • redigo

    Go client for Redis

  • Setup postgres and redis Usually production SQL db standard solution for these days is combination of sqlx and pgx. Good Redis Go clients is go-redis and redigo, i used first.

  • go-grpc-middleware

    Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.

  • I found this is very good gRPC Middleware repository, but we easy can create our own, for example logger interceptor:

  • evans

    Evans: more expressive universal gRPC client

  • I like to use evans for simple testing gRPC.

  • viper

    Go configuration with fangs

  • In cmd folder let's init all dependencies and start the app. Viper is very good and common choice as complete configuration solution for Go applications. We use here config-local.yml file approach.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • zap

    Blazing fast, structured, leveled logging in Go.

  • Next let's create logger, here i used Uber's Zap under the hood, important here is to create Logger interface for be able to replace logger in the future if it's need.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts