-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (31 loc) · 760 Bytes
/
Copy pathmain.go
File metadata and controls
40 lines (31 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"net/http"
ginMonitor "github.com/bancodobrasil/gin-monitor"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
// Initialize Monitoring
monitor, err := ginMonitor.New(
"v1.0.0",
ginMonitor.DefaultErrorMessageKey,
ginMonitor.DefaultBuckets,
)
if err != nil {
panic(err)
}
r := gin.Default()
// Register mux-monitor middleware
r.Use(monitor.Prometheus())
// Register metrics endpoint
r.GET("/metrics", gin.WrapH(promhttp.Handler()))
// Ping Endpoint
r.GET("/ping", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "pong",
})
})
// Metrics Endpoint
r.Run(":9090") // listen and serve on 0.0.0.0:9090 (for windows "localhost:9090")
}