internal/frontend: add separate tag route for search page types

To improve monitoring of the latency of these pages we separate
the search modes into different request tags.

Change-Id: I3f0cf887b78fa3e6c065324bd5473433b963769e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/442555
TryBot-Result: kokoro <noreply+kokoro@google.com>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index ae96d2e..bef46c4 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -380,6 +380,13 @@
 			tag += tab
 		}
 	}
+	if tag == "search" {
+		switch m := r.URL.Query().Get("m"); m {
+		case "symbol", "package", "vuln":
+			fmt.Println(tag, m)
+			tag += "-" + m
+		}
+	}
 	return tag
 }
 
diff --git a/internal/frontend/server_test.go b/internal/frontend/server_test.go
index c1ef69e..c5763bf 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -1501,6 +1501,10 @@
 	}{
 		{"/pkg", mustRequest("http://localhost/pkg/foo?tab=versions"), "pkg-versions"},
 		{"/", mustRequest("http://localhost/foo?tab=imports"), "imports"},
+		{"/search", mustRequest("http://localhost/search?q=net&m=vuln"), "search-vuln"},
+		{"/search", mustRequest("http://localhost/search?q=net&m=package"), "search-package"},
+		{"/search", mustRequest("http://localhost/search?q=net&m=symbol"), "search-symbol"},
+		{"/search", mustRequest("http://localhost/search?q=net"), "search"},
 	}
 	for _, test := range tests {
 		t.Run(test.want, func(t *testing.T) {