-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (42 loc) · 1.09 KB
/
main.go
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
41
42
43
44
45
46
47
48
49
50
package main
import (
"time"
_ "github.com/devxp-tech/teste-loki/config"
"github.com/devxp-tech/teste-loki/controllers"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func recordMetrics() {
go func() {
for {
opsProcessed.Inc()
time.Sleep(2 * time.Second)
}
}()
}
var (
opsProcessed = promauto.NewCounter(prometheus.CounterOpts{
Name: "myapp_processed_ops_total",
Help: "The total number of processed events",
})
)
func main() {
recordMetrics()
server := gin.New()
server.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"status": true,
"message": "Hello world for your app teste-loki is fucking running!",
"headers": c.Request.Header,
})
})
server.GET("/metrics", func(c *gin.Context) {
h := promhttp.Handler()
h.ServeHTTP(c.Writer, c.Request)
})
server.GET("/health-check/liveness", controllers.HealthCheckLiveness)
server.GET("/health-check/readiness", controllers.HealthCheckReadiness)
server.Run()
}