Debian Codegraph @

example/example.go

raw
1 package main
2
3 import (
4 "github.com/mcuadros/go-gin-prometheus"
5
6 "github.com/gin-gonic/gin"
7 )
8
9 func main() {
10 r := gin.New()
11
12 /* // Optional custom metrics list
13 customMetrics := []*ginprometheus.Metric{
14 &ginprometheus.Metric{
15 ID: "1234", // optional string
16 Name: "test_metric", // required string
17 Description: "Counter test metric", // required string
18 Type: "counter", // required string
19 },
20 &ginprometheus.Metric{
21 ID: "1235", // Identifier
22 Name: "test_metric_2", // Metric Name
23 Description: "Summary test metric", // Help Description
24 Type: "summary", // type associated with prometheus collector
25 },
26 // Type Options:
27 // counter, counter_vec, gauge, gauge_vec,
28 // histogram, histogram_vec, summary, summary_vec
29 }
30 p := ginprometheus.NewPrometheus("gin", customMetrics)
31 */
32
33 p := ginprometheus.NewPrometheus("gin")
34
35 p.Use(r)
36 r.GET("/", func(c *gin.Context) {
37 c.JSON(200, "Hello world!")
38 })
39
40 r.Run(":29090")
41 }