@@ -246,7 +246,7 @@ func (ui *MonitoringUI) Stop() error {
246246}
247247
248248// UpdateMetrics - Updates metrics with a new query
249- func (ui * MonitoringUI ) UpdateMetrics (pluginsState PluginsState , msg * dns.Msg , start time. Time ) {
249+ func (ui * MonitoringUI ) UpdateMetrics (pluginsState PluginsState , msg * dns.Msg ) {
250250 if ! ui .config .Enabled {
251251 return
252252 }
@@ -306,7 +306,7 @@ func (ui *MonitoringUI) UpdateMetrics(pluginsState PluginsState, msg *dns.Msg, s
306306 }
307307
308308 // Update response time - back to counters lock
309- responseTime := time .Since (start ).Milliseconds ()
309+ responseTime := time .Since (pluginsState . requestStart ).Milliseconds ()
310310
311311 // Cap at timeout to handle system sleep/suspend
312312 maxResponseTime := pluginsState .timeout .Milliseconds ()
@@ -778,16 +778,18 @@ func (ui *MonitoringUI) handleTestQuery(w http.ResponseWriter, r *http.Request)
778778 msg .SetQuestion ("test.example.com." , dns .TypeA )
779779
780780 // Create a fake plugin state
781+ testStart := time .Now ().Add (- 10 * time .Millisecond )
781782 pluginsState := PluginsState {
782- qName : "test.example.com" ,
783- serverName : "cloudflare" ,
784- clientProto : "udp" ,
785- questionMsg : msg ,
786- cacheHit : false ,
783+ qName : "test.example.com" ,
784+ serverName : "cloudflare" ,
785+ clientProto : "udp" ,
786+ questionMsg : msg ,
787+ cacheHit : false ,
788+ requestStart : testStart ,
787789 }
788790
789791 // Update metrics
790- ui .UpdateMetrics (pluginsState , msg , time . Now (). Add ( - 10 * time . Millisecond ) )
792+ ui .UpdateMetrics (pluginsState , msg )
791793
792794 // Return success
793795 w .Header ().Set ("Content-Type" , "text/plain" )
0 commit comments