Pull request 2334: AGDNS-2627-query-statistics

Merge in DNS/adguard-home from AGDNS-2627-query-statistics to master

Squashed commit of the following:

commit 9bfdadfddda04404742683d69f6455a56ae68763
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Jan 30 14:40:06 2025 +0300

    chlog: fix typo

commit 73764b79bda4dd26695160ab7cee6f222ed0e3a9
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Jan 30 14:14:56 2025 +0300

    chlog: fix typo

commit 5900b360feb12ced95d10fd11510d81450cd5443
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Jan 30 14:10:34 2025 +0300

    all: upd chlog

commit 4a9d79a2596839d16f18e45dd13939cdc011361e
Merge: 76d037122 cc2006f61
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Jan 30 14:01:46 2025 +0300

    Merge branch 'master' into AGDNS-2627-query-statistics

commit 76d0371220c3a6268e0fb0e775a01ab5a609e443
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Mon Jan 27 20:32:44 2025 +0300

    all: upd chlog

commit 496cbba94ec8c1684001f8ed0245b51a73d5bffe
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Thu Jan 23 19:44:26 2025 +0300

    all: imp code

commit 4795a2c8fbf49cede106641e97892c008dccd2e9
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Jan 21 17:48:00 2025 +0300

    all: query statistics
This commit is contained in:
Stanislav Chzhen
2025-01-30 15:08:01 +03:00
parent cc2006f616
commit d3dea0f46c
6 changed files with 44 additions and 24 deletions

View File

@@ -10,6 +10,7 @@ import (
"time"
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
"github.com/AdguardTeam/dnsproxy/proxy"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/logutil/slogutil"
"go.etcd.io/bbolt"
@@ -62,8 +63,9 @@ type Entry struct {
// Domain is the domain name requested.
Domain string
// Upstream is the upstream DNS server.
Upstream string
// UpstreamStats contains the DNS query statistics for both the upstream and
// fallback DNS servers.
UpstreamStats []*proxy.UpstreamStatistics
// Result is the result of processing the request.
Result Result
@@ -71,9 +73,6 @@ type Entry struct {
// ProcessingTime is the duration of the request processing from the start
// of the request including timeouts.
ProcessingTime time.Duration
// UpstreamTime is the duration of the successful request to the upstream.
UpstreamTime time.Duration
}
// validate returns an error if entry is not valid.
@@ -329,10 +328,14 @@ func (u *unit) add(e *Entry) {
u.timeSum += pt
u.nTotal++
if e.Upstream != "" {
u.upstreamsResponses[e.Upstream]++
ut := uint64(e.UpstreamTime.Microseconds())
u.upstreamsTimeSum[e.Upstream] += ut
for _, s := range e.UpstreamStats {
if s.IsCached || s.Error != nil {
continue
}
addr := s.Address
u.upstreamsResponses[addr]++
u.upstreamsTimeSum[addr] += uint64(s.QueryDuration.Microseconds())
}
}