aboutsummaryrefslogtreecommitdiff
path: root/internal/frontend
diff options
context:
space:
mode:
authorJamal Carvalho <jamal@golang.org>2022-10-12 19:01:06 +0000
committerJamal Carvalho <jamal@golang.org>2022-10-13 13:44:31 +0000
commit93bb5d2a0f0272eafc698f9eff73a2bb7afedd2a (patch)
tree9e576dc924408eaeabc5110e9291257d8c36df81 /internal/frontend
parent873fb37c24799199f4b1e129bc425fa0490b1f8d (diff)
downloadgo-x-pkgsite-93bb5d2a0f0272eafc698f9eff73a2bb7afedd2a.tar.xz
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>
Diffstat (limited to 'internal/frontend')
-rw-r--r--internal/frontend/server.go7
-rw-r--r--internal/frontend/server_test.go4
2 files changed, 11 insertions, 0 deletions
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index ae96d2e4..bef46c4f 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -380,6 +380,13 @@ func TagRoute(route string, r *http.Request) string {
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 c1ef69e0..c5763bf7 100644
--- a/internal/frontend/server_test.go
+++ b/internal/frontend/server_test.go
@@ -1501,6 +1501,10 @@ func TestTagRoute(t *testing.T) {
}{
{"/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) {