Skip to content

Commit 788e3a5

Browse files
committed
Only count cache statistics for queries that participate in caching
1 parent fa59f99 commit 788e3a5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

dnscrypt-proxy/monitoring_ui.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,17 @@ func (ui *MonitoringUI) UpdateMetrics(pluginsState PluginsState, msg *dns.Msg) {
296296
}
297297

298298
// Update cache hits/misses
299-
if pluginsState.cacheHit {
300-
mc.cacheHits++
301-
} else {
302-
mc.cacheMisses++
299+
// Only count cache statistics for queries that participate in caching:
300+
// - Cache hits (cacheHit == true)
301+
// - Cache misses (queries that went to a DNS server: serverName != "-")
302+
// This excludes blocked queries (REJECT/DROP) that never reach the cache or server
303+
shouldCountCacheStats := pluginsState.cacheHit || pluginsState.serverName != "-"
304+
if shouldCountCacheStats {
305+
if pluginsState.cacheHit {
306+
mc.cacheHits++
307+
} else {
308+
mc.cacheMisses++
309+
}
303310
}
304311

305312
// Update blocked queries count

0 commit comments

Comments
 (0)