mirror of
https://github.com/safing/portmaster
synced 2025-09-04 03:29:12 +00:00
Fix slow queries sensor value calculation
This commit is contained in:
parent
7958dfd41d
commit
a2b2021360
1 changed files with 8 additions and 6 deletions
|
@ -31,13 +31,15 @@ func reportRequestDuration(started time.Time, resolver *Resolver) {
|
||||||
// getSlowQueriesSensorValue returns the current avg query time recorded by the
|
// getSlowQueriesSensorValue returns the current avg query time recorded by the
|
||||||
// slow queries sensor.
|
// slow queries sensor.
|
||||||
func getSlowQueriesSensorValue() (avgQueryTime time.Duration) {
|
func getSlowQueriesSensorValue() (avgQueryTime time.Duration) {
|
||||||
return time.Duration(
|
// Get values and check them.
|
||||||
slowQueriesSensorSum.Load() / slowQueriesSensorCnt.Load(),
|
sum := slowQueriesSensorSum.Load()
|
||||||
)
|
cnt := slowQueriesSensorCnt.Load()
|
||||||
}
|
if cnt < 1 {
|
||||||
|
cnt = 1
|
||||||
|
}
|
||||||
|
|
||||||
// getAndResetSlowQueriesSensorValue returns the current avg query time
|
return time.Duration(sum / cnt)
|
||||||
// recorded by the slow queries sensor and reset the sensor values.
|
}
|
||||||
|
|
||||||
// resetSlowQueriesSensorValue reset the slow queries sensor values.
|
// resetSlowQueriesSensorValue reset the slow queries sensor values.
|
||||||
func resetSlowQueriesSensorValue() {
|
func resetSlowQueriesSensorValue() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue