Files
openlan/pkg/switch/prome.go
2024-03-12 15:00:53 +00:00

31 lines
483 B
Go

package cswitch
import (
"time"
"github.com/luscis/openlan/pkg/libol"
"github.com/prometheus/client_golang/prometheus"
)
var (
metrics = prometheus.NewRegistry()
helloMetric = prometheus.NewCounter(prometheus.CounterOpts{
Name: "hello_ops_total",
Help: "The total hello number",
})
)
func recordMetrics() {
libol.Go(func() {
for {
helloMetric.Inc()
time.Sleep(2 * time.Second)
}
})
}
func init() {
recordMetrics()
metrics.MustRegister(helloMetric)
}