Gin framework in Golang

https://gin-gonic.com/

go
I need to set gin mode to release mode. How should I do it?gin.SetMode(gin.ReleaseMode)

Gin plus open telemetry

If you are using otelgin middleware, the traceable context is propagated through ginContext.Request.Context(). So you can pass on this request context instead of ginContext to your gRPC client to propagate trace.

Prometheus with Gin

go
func PrometheusMiddleware() gin.HandlerFunc {
    return func(c *gin.Context) {
        path := c.FullPath() timer :=
        prometheus.NewTimer(MonitoringHttpDuration.WithLabelValues(path)) c.Next()
        timer.ObserveDuration()
    }
}
go
package main
import (
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var cpuTemp = prometheus.NewGauge(prometheus.GaugeOpts{
    Name: "cpu_temperature_celsius",
    Help: "Current temperature of the CPU.",
}
)
func init() {
    prometheus.MustRegister(cpuTemp)
}
func prometheusHandler() gin.HandlerFunc {
    h := promhttp.Handler()
    return func(c *gin.Context) {
        h.ServeHTTP(c.Writer, c.Request)
    }
}
func main() {
    cpuTemp.Set(65.3)
    r := gin.New()
    r.GET("/", func(c *gin.Context) {
        c.JSON(200, "Hello world!")
    })
    r.GET("/metrics", prometheusHandler())
    r.Run()
}

Transform gin.Context to context.Context