mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 09:43:17 -04:00 
			
		
		
		
	* plugin/prometheus: write rcode properly to the metrics Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
		
			
				
	
	
		
			29 lines
		
	
	
		
			784 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			784 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package metrics
 | |
| 
 | |
| import (
 | |
| 	"runtime"
 | |
| 
 | |
| 	"github.com/coredns/coredns/plugin/pkg/dnstest"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| // Recorder is a dnstest.Recorder specific to the metrics plugin.
 | |
| type Recorder struct {
 | |
| 	*dnstest.Recorder
 | |
| 	// CallerN holds the string return value of the call to runtime.Caller(N+1)
 | |
| 	Caller [3]string
 | |
| }
 | |
| 
 | |
| // NewRecorder makes and returns a new Recorder.
 | |
| func NewRecorder(w dns.ResponseWriter) *Recorder { return &Recorder{Recorder: dnstest.NewRecorder(w)} }
 | |
| 
 | |
| // WriteMsg records the status code and calls the
 | |
| // underlying ResponseWriter's WriteMsg method.
 | |
| func (r *Recorder) WriteMsg(res *dns.Msg) error {
 | |
| 	_, r.Caller[0], _, _ = runtime.Caller(1)
 | |
| 	_, r.Caller[1], _, _ = runtime.Caller(2)
 | |
| 	_, r.Caller[2], _, _ = runtime.Caller(3)
 | |
| 	return r.Recorder.WriteMsg(res)
 | |
| }
 |