You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2021/09/21 22:08:53 UTC
[trafficcontrol] 02/09: Fixed crs/stats fields to report time correctly and not overflow and … (#6211)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit c89911f7ff59be3c132d128687b3f696f4e33f73
Author: mattjackson220 <33...@users.noreply.github.com>
AuthorDate: Wed Sep 15 10:18:56 2021 -0600
Fixed crs/stats fields to report time correctly and not overflow and … (#6211)
* Fixed crs/stats fields to report time correctly and not overflow and removed unused fields from TO
* fixed spaces
(cherry picked from commit 296051a1fa8ae36d3f38bd08e2dde929dd80a361)
---
CHANGELOG.md | 1 +
lib/go-tc/crsstats.go | 36 ++--------------------
.../traffic_router/core/router/StatTracker.java | 21 ++++++++++++-
3 files changed, 23 insertions(+), 35 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e6e20f..0e01602 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -105,6 +105,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#6174](https://github.com/apache/trafficcontrol/issues/6174) - Fixed t3c-apply with no hostname failing if the OS hostname returns a full FQDN
- Fixed Federations IMS so TR federations watcher will get updates.
- [#5129](https://github.com/apache/trafficcontrol/issues/5129) - Updated TM so that it returns a 404 if the endpoint is not supported.
+- Fixed Traffic Router crs/stats to prevent overflow and to correctly record the time used in averages.
### Changed
- Migrated completely off of bower in favor of npm
diff --git a/lib/go-tc/crsstats.go b/lib/go-tc/crsstats.go
index 11e56d9..945b66c 100644
--- a/lib/go-tc/crsstats.go
+++ b/lib/go-tc/crsstats.go
@@ -36,15 +36,8 @@ type CRSStatsApp struct {
// CRSStatsStats represents stats about a given TR.
type CRSStatsStats struct {
- DNSMap map[string]CRSStatsStat
- HTTPMap map[string]CRSStatsStat
- TotalDNSCount uint64 `json:"totalDnsCount"`
- TotalHTTPCount uint64 `json:"totalHttpCount"`
- TotalDSMissCount uint64 `json:"totalDsMissCount"`
- AppStartTime uint64 `json:"appStartTime"`
- AverageDnsTime uint64 `json:"averageDnsTime"`
- AverageHttpTime uint64 `json:"averageHttpTime"`
- UpdateTracker CRSStatsUpdateTracker `json:"updateTracker"`
+ DNSMap map[string]CRSStatsStat
+ HTTPMap map[string]CRSStatsStat
}
// CRSStatsStat represents an individual stat.
@@ -61,31 +54,6 @@ type CRSStatsStat struct {
RegionalAlternateCount uint64 `json:"regionalAlternateCount"`
}
-// CRSStatsUpdateTracker is a collection of miscellaneous statistics about a
-// Traffic Router instance.
-//
-// This is named with "CRS" because of legacy naming conventions for Traffic
-// Router.
-type CRSStatsUpdateTracker struct {
- LastHttpsCertificatesCheck uint64 `json:"lastHttpsCertificatesCheck"`
- LastGeolocationDatabaseUpdaterUpdate uint64 `json:"lastGeolocationDatabaseUpdaterUpdate"`
- LastCacheStateCheck uint64 `json:"lastCacheStateCheck"`
- LastCacheStateChange uint64 `json:"lastCacheStateChange"`
- LastNetworkUpdaterUpdate uint64 `json:"lastNetworkUpdaterUpdate"`
- LastHTTPSCertificatesUpdate uint64 `json:"lastHttpsCertificatesUpdate"`
- LastConfigCheck uint64 `json:"lastConfigCheck"`
- LastConfigChange uint64 `json:"lastConfigChange"`
- LastHTTPSCertificatesFetchFail uint64 `json:"lastHttpsCertificatesFetchFail"`
- LastNetworkUpdaterCheck uint64 `json:"lastNetworkUpdaterCheck"`
- NewDNSSECKeysFound uint64 `json:"newDnsSecKeysFound"`
- LastGeolocationDatabaseUpdaterCheck uint64 `json:"lastGeolocationDatabaseUpdaterCheck"`
- LastHTTPSCertificatesFetchSuccess uint64 `json:"lastHttpsCertificatesFetchSuccess"`
- LastSteeringWatcherCheck uint64 `json:"lastSteeringWatcherCheck"`
- LastDNSSECKeysCheck uint64 `json:"lastDnsSecKeysCheck"`
- LastFederationsWatcherCheck uint64 `json:"lastFederationsWatcherCheck"`
- LastHTTPSCertificatesFetchAttempt uint64 `json:"lastHttpsCertificatesFetchAttempt"`
-}
-
// Routing represents the aggregated routing percentages across CDNs or for a DS.
type Routing struct {
StaticRoute float64 `json:"staticRoute"`
diff --git a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/router/StatTracker.java b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/router/StatTracker.java
index b926a76..d93f62a 100644
--- a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/router/StatTracker.java
+++ b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/router/StatTracker.java
@@ -368,6 +368,11 @@ public class StatTracker {
if (t.routeType == RouteType.DNS) {
totalDnsCount++;
totalDnsTime += t.time;
+ if (totalDnsTime < 0 || totalDnsCount < 0) {
+ this.resetDnsStatsFromOverflow();
+ totalDnsCount++;
+ totalDnsTime += t.time;
+ }
map = dnsMap;
if (t.resultDetails == Track.ResultDetails.LOCALIZED_DNS) {
@@ -377,6 +382,11 @@ public class StatTracker {
} else {
totalHttpCount++;
totalHttpTime += t.time;
+ if (totalHttpTime < 0 || totalHttpCount < 0) {
+ this.resetHttpStatsFromOverflow();
+ totalHttpCount++;
+ totalHttpTime += t.time;
+ }
map = httpMap;
}
map.putIfAbsent(fqdn, new Tallies());
@@ -452,11 +462,20 @@ public class StatTracker {
t.setRouteType(rt, dsName.toString());
t.setResult(ResultType.INIT);
- t.end();
saveTrack(t);
}
}
}
}
+
+ private void resetHttpStatsFromOverflow() {
+ totalHttpCount = 0;
+ totalHttpTime = 0;
+ }
+
+ private void resetDnsStatsFromOverflow() {
+ totalDnsCount = 0;
+ totalDnsTime = 0;
+ }
}