summaryrefslogtreecommitdiffhomepage
path: root/tsweb
diff options
context:
space:
mode:
authorWill Norris <will@tailscale.com>2024-05-03 15:49:19 -0700
committerWill Norris <will@willnorris.com>2024-05-05 18:04:58 -0700
commit80decd83c19d1536df482ee1a171663d923a7d7b (patch)
tree39c20aac4445a05308c7293fee56db4f4be674f6 /tsweb
parented843e643f9f311fc00808253abb4e829adf7af3 (diff)
downloadtailscale-80decd83c19d1536df482ee1a171663d923a7d7b.tar.xz
tailscale-80decd83c19d1536df482ee1a171663d923a7d7b.zip
tsweb: remove redundant bumpStartIfNeeded func
Updates #12001 Signed-off-by: Will Norris <will@tailscale.com>
Diffstat (limited to 'tsweb')
-rw-r--r--tsweb/tsweb.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go
index 3228edc64..ad9f90eb3 100644
--- a/tsweb/tsweb.go
+++ b/tsweb/tsweb.go
@@ -312,7 +312,6 @@ func (h retHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
var bucket string
- bumpStartIfNeeded := func() {}
var startRecorded bool
if bs := h.opts.BucketedStats; bs != nil {
bucket = bs.bucketForRequest(r)
@@ -320,13 +319,11 @@ func (h retHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch v := bs.Started.Map.Get(bucket).(type) {
case *expvar.Int:
// If we've already seen this bucket for, count it immediately.
- v.Add(1)
- startRecorded = true
- case nil:
// Otherwise, for newly seen paths, only count retroactively
// (so started-finished doesn't go negative) so we don't fill
// this LabelMap up with internet scanning spam.
- bumpStartIfNeeded = func() { bs.Started.Add(bucket, 1) }
+ v.Add(1)
+ startRecorded = true
}
}
}
@@ -445,8 +442,12 @@ func (h retHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// gets most of the way there but there are also plenty of URLs that are
// almost right but result in 400s too. Seem easier to just only ignore
// all 4xx and 5xx.
- if startRecorded || msg.Code < 400 {
- bumpStartIfNeeded()
+ if startRecorded {
+ bs.Finished.Add(bucket, 1)
+ } else if msg.Code < 400 {
+ // This is the first non-error request for this bucket,
+ // so count it now retroactively.
+ bs.Started.Add(bucket, 1)
bs.Finished.Add(bucket, 1)
}
}