mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 10:43:20 -05:00 
			
		
		
		
	* - ensure plugins that use prometheus.MustRegister, re-register after reload - removing once.Do on the startup function was simplest way to do it. * - fix underscored names (advice of bot) * - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics * - ensure different ports for tests that can run in same time ..
		
			
				
	
	
		
			37 lines
		
	
	
		
			1018 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1018 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package proxy
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/coredns/coredns/plugin"
 | 
						|
 | 
						|
	"github.com/prometheus/client_golang/prometheus"
 | 
						|
)
 | 
						|
 | 
						|
// Metrics the proxy plugin exports.
 | 
						|
var (
 | 
						|
	RequestCount = prometheus.NewCounterVec(prometheus.CounterOpts{
 | 
						|
		Namespace: plugin.Namespace,
 | 
						|
		Subsystem: "proxy",
 | 
						|
		Name:      "request_count_total",
 | 
						|
		Help:      "Counter of requests made per protocol, proxy protocol, family and upstream.",
 | 
						|
	}, []string{"server", "proto", "proxy_proto", "family", "to"})
 | 
						|
	RequestDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
 | 
						|
		Namespace: plugin.Namespace,
 | 
						|
		Subsystem: "proxy",
 | 
						|
		Name:      "request_duration_seconds",
 | 
						|
		Buckets:   plugin.TimeBuckets,
 | 
						|
		Help:      "Histogram of the time (in seconds) each request took.",
 | 
						|
	}, []string{"server", "proto", "proxy_proto", "family", "to"})
 | 
						|
)
 | 
						|
 | 
						|
// familyToString returns the string form of either 1, or 2. Returns
 | 
						|
// empty string is not a known family
 | 
						|
func familyToString(f int) string {
 | 
						|
	if f == 1 {
 | 
						|
		return "1"
 | 
						|
	}
 | 
						|
	if f == 2 {
 | 
						|
		return "2"
 | 
						|
	}
 | 
						|
	return ""
 | 
						|
}
 |