chore: track the first time html is served in telemetry (#16334)

Addresses https://github.com/coder/nexus/issues/175.

## Changes

- Adds the `telemetry_items` database table. It's a key value store for
telemetry events that don't fit any other database tables.
- Adds a telemetry report when HTML is served for the first time in
`site.go`.
This commit is contained in:
Hugo Dutka
2025-01-31 13:55:46 +01:00
committed by GitHub
parent f6e990ed87
commit 2ace044e0b
21 changed files with 521 additions and 12 deletions

View File

@ -964,7 +964,7 @@ func TestServer(t *testing.T) {
server := httptest.NewServer(r)
defer server.Close()
inv, _ := clitest.New(t,
inv, cfg := clitest.New(t,
"server",
"--in-memory",
"--http-address", ":0",
@ -977,6 +977,25 @@ func TestServer(t *testing.T) {
<-deployment
<-snapshot
accessURL := waitAccessURL(t, cfg)
ctx := testutil.Context(t, testutil.WaitMedium)
client := codersdk.New(accessURL)
body, err := client.Request(ctx, http.MethodGet, "/", nil)
require.NoError(t, err)
require.NoError(t, body.Body.Close())
require.Eventually(t, func() bool {
snap := <-snapshot
htmlFirstServedFound := false
for _, item := range snap.TelemetryItems {
if item.Key == string(telemetry.TelemetryItemKeyHTMLFirstServedAt) {
htmlFirstServedFound = true
}
}
return htmlFirstServedFound
}, testutil.WaitMedium, testutil.IntervalFast, "no html_first_served telemetry item")
})
t.Run("Prometheus", func(t *testing.T) {
t.Parallel()