Skip to content

Commit 4511c18

Browse files
committed
Remove start parameter from UpdateMetrics and updateMonitoringMetrics
1 parent 73e0ec8 commit 4511c18

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

dnscrypt-proxy/monitoring_ui.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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")

dnscrypt-proxy/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ func (proxy *Proxy) processIncomingQuery(
798798
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
799799

800800
// Update monitoring metrics
801-
updateMonitoringMetrics(proxy, &pluginsState, start)
801+
updateMonitoringMetrics(proxy, &pluginsState)
802802

803803
return response
804804
}

dnscrypt-proxy/query_processing.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,10 @@ func sendResponse(
347347
func updateMonitoringMetrics(
348348
proxy *Proxy,
349349
pluginsState *PluginsState,
350-
start time.Time,
351350
) {
352351
if proxy.monitoringUI.Enabled && proxy.monitoringInstance != nil && pluginsState.questionMsg != nil {
353352
dlog.Debugf("Calling UpdateMetrics for query: %s", pluginsState.qName)
354-
proxy.monitoringInstance.UpdateMetrics(*pluginsState, pluginsState.questionMsg, start)
353+
proxy.monitoringInstance.UpdateMetrics(*pluginsState, pluginsState.questionMsg)
355354
} else {
356355
if !proxy.monitoringUI.Enabled {
357356
dlog.Debugf("Monitoring UI not enabled")

0 commit comments

Comments
 (0)