Skip to content

Commit

Permalink
consider only valid upstreams for response times
Browse files Browse the repository at this point in the history
  • Loading branch information
sholdee committed Jul 8, 2024
1 parent 02c5da2 commit 99aab28
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adguard_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ func (mc *MetricsCollector) UpdateMetrics(data map[string]interface{}) {

mc.lock.Lock()
mc.responseTimes = append(mc.responseTimes, TimeValue{Time: currentTime, Value: elapsedMs})
if upstream != "unknown" {
// Exclude metrics with unknown upstreams
if upstream != "unknown" && upstream != "" {
mc.upstreamResponseTimes[upstream] = append(mc.upstreamResponseTimes[upstream], TimeValue{Time: currentTime, Value: elapsedMs})
}
mc.lock.Unlock()
Expand Down Expand Up @@ -273,6 +274,9 @@ func (mc *MetricsCollector) ProcessMetrics() {
}

for upstream, times := range mc.upstreamResponseTimes {
if upstream == "unknown" || upstream == "" {
continue // Skip processing for unknown upstreams
}
recentTimes := mc.filterRecentTimes(times, cutoffTime)
if len(recentTimes) > 0 {
avgUpstreamTime := mc.calculateAverage(recentTimes)
Expand Down

0 comments on commit 99aab28

Please sign in to comment.