mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 02:03:20 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			477 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			477 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package metrics
 | |
| 
 | |
| import (
 | |
| 	"github.com/coredns/coredns/core/dnsserver"
 | |
| 
 | |
| 	"github.com/mholt/caddy"
 | |
| 	"github.com/prometheus/client_golang/prometheus"
 | |
| )
 | |
| 
 | |
| // MustRegister registers the prometheus Collectors when the metrics plugin is used.
 | |
| func MustRegister(c *caddy.Controller, cs ...prometheus.Collector) {
 | |
| 	m := dnsserver.GetConfig(c).Handler("prometheus")
 | |
| 	if m == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	x, ok := m.(*Metrics)
 | |
| 	if !ok {
 | |
| 		return
 | |
| 	}
 | |
| 	for _, c := range cs {
 | |
| 		x.MustRegister(c)
 | |
| 	}
 | |
| }
 |