internal/teeproxy: don't tee expected 404s

Don't tee requests that we expect to 404 on pkg.go.dev, since this makes
the logs noisy and the information isn't useful.

Change-Id: I01217a2a99c943bb1e8639ee00ff0f00d29d53d1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/257971
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
diff --git a/internal/teeproxy/teeproxy.go b/internal/teeproxy/teeproxy.go
index 2f737d1..c0e7b12 100644
--- a/internal/teeproxy/teeproxy.go
+++ b/internal/teeproxy/teeproxy.go
@@ -74,25 +74,33 @@
 }
 
 var gddoToPkgGoDevRequest = map[string]string{
-	"/":                              "/",
-	"/-/about":                       "/about",
-	"/-/bootstrap.min.css":           "/404",
-	"/-/bootstrap.min.js":            "/404",
-	"/-/bot":                         "/404",
-	"/-/go":                          "/std",
-	"/-/jquery-2.0.3.min.js":         "/404",
-	"/-/refresh":                     "/404",
-	"/-/sidebar.css":                 "/404",
-	"/-/site.css":                    "/404",
-	"/-/subrepo":                     "/404",
-	"/BingSiteAuth.xml":              "/404",
-	"/C":                             "/C",
-	"/favicon.ico":                   "/favicon.ico",
-	"/google3d2f3cd4cc2bb44b.html":   "/404",
-	"/humans.txt":                    "/404",
-	"/robots.txt":                    "/404",
-	"/site.js":                       "/404",
-	"/third_party/jquery.timeago.js": "/404",
+	"/":            "/",
+	"/-/about":     "/about",
+	"/-/go":        "/std",
+	"/C":           "/C",
+	"/favicon.ico": "/favicon.ico",
+}
+
+// expected404s are a list of godoc.org URLs that we expected to 404 on
+// pkg.go.dev.
+var expected404s = map[string]bool{
+	"/-/bootstrap.min.css":           true,
+	"/-/bootstrap.min.js":            true,
+	"/-/bot":                         true,
+	"/-/jquery-2.0.3.min.js":         true,
+	"/-/refresh":                     true,
+	"/-/sidebar.css":                 true,
+	"/-/site.css":                    true,
+	"/-/site.js":                     true,
+	"/BingSiteAuth.xml":              true,
+	"/google3d2f3cd4cc2bb44b.html":   true,
+	"/humans.txt":                    true,
+	"/robots.txt":                    true,
+	"/third_party/jquery.timeago.js": true,
+
+	// TODO: add a replacement page for this before redirecting godoc.org
+	// traffic.
+	"/-/subrepo": true,
 }
 
 // statusRedBreaker is a custom HTTP status code that denotes that a request
@@ -268,6 +276,21 @@
 	results = map[string]*RequestEvent{
 		"godoc.org": gddoEvent,
 	}
+	if _, ok := expected404s[gddoEvent.Path]; ok {
+		// Don't tee these requests, since we know they will 404.
+		return results, http.StatusOK, nil
+	}
+	for _, s := range []string{
+		"?import-graph",
+		"?status.png",
+		"?status.svg",
+		"api.godoc.org",
+	} {
+		if strings.Contains(gddoEvent.URL, s) {
+			// Don't tee these requests, since we know they will 404.
+			return results, http.StatusOK, nil
+		}
+	}
 	if len(s.hosts) > 0 {
 		rateLimited := !s.limiter.Allow()
 		for _, host := range s.hosts {