mirror of
				https://github.com/luscis/openlan.git
				synced 2025-10-31 20:42:35 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			483 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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)
 | |
| }
 | 
