You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/03/14 22:01:45 UTC

[GitHub] [trafficcontrol] srijeet0406 commented on a change in pull request #6620: Adding access.log to Traffic Monitor

srijeet0406 commented on a change in pull request #6620:
URL: https://github.com/apache/trafficcontrol/pull/6620#discussion_r826416062



##########
File path: traffic_monitor/datareq/datareq.go
##########
@@ -286,24 +287,56 @@ func WrapAgeErr(errorCount threadsafe.Uint, f func() ([]byte, time.Time, error),
 	}
 }
 
+func accessLogTime(t time.Time) float64 {
+	return float64(t.UnixMilli()) / 1000.0
+}
+
+func accessLogStr(
+	timestamp time.Time, // prefix
+	remoteAddress string, // chi
+	reqMethod string, // cqhm
+	reqPath string, // url
+	reqRawQuery string,
+	statusCode int, // pssc
+	respSize int, // b
+	reqServeTimeMs int, // ttms
+	userAgent string, // uas
+) string {
+	return fmt.Sprintf("%.3f chi=%s cqhm=%s url=\"%s?%s\" pssc=%d b=%d ttms=%d uas=\"%s\"",
+		accessLogTime(timestamp),
+		remoteAddress,
+		reqMethod,
+		reqPath,
+		reqRawQuery,
+		statusCode,
+		respSize,
+		reqServeTimeMs,
+		userAgent)
+}
+
 // WrapUnpolledCheck wraps an http.HandlerFunc, returning ServiceUnavailable if all caches have't been polled; else, calling the wrapped func. Once all caches have been polled, we never return a 503 again, even if the CRConfig has been changed and new, unpolled caches exist. This is because, before those new caches existed in the CRConfig, they weren't being routed to, so it doesn't break anything to continue not routing to them until they're polled, while still serving polled caches as available. Whereas, on startup, if we were to return data with some caches unpolled, we would be telling clients that existing, potentially-available caches are unavailable, simply because we hadn't polled them yet.
 func wrapUnpolledCheck(unpolledCaches threadsafe.UnpolledCaches, errorCount threadsafe.Uint, f http.HandlerFunc) http.HandlerFunc {
+	start := time.Now()

Review comment:
       Good catch! Fixed now.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org