mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add prometheus metrics to database.Store (#7713)
* Adds dbmetrics package and wraps database.Store with a Prometheus HistogramVec of timings. * Adds Wrappers method to database.Store to avoid double-wrapping interfaces * Fixes test flake in TestLicensesListFake
This commit is contained in:
@@ -140,6 +140,7 @@ func TestLicensesListFake(t *testing.T) {
|
||||
// so instead we have to fake the HTTP interaction.
|
||||
t.Run("Mainline", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
expectedLicenseExpires := time.Date(2024, 4, 6, 16, 53, 35, 0, time.UTC)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
defer cancel()
|
||||
inv := setupFakeLicenseServerTest(t, "licenses", "list")
|
||||
@@ -158,7 +159,13 @@ func TestLicensesListFake(t *testing.T) {
|
||||
assert.Equal(t, "claim1", licenses[0].Claims["h1"])
|
||||
assert.Equal(t, int32(5), licenses[1].ID)
|
||||
assert.Equal(t, "claim2", licenses[1].Claims["h2"])
|
||||
assert.Equal(t, "2024-04-06T16:53:35Z", licenses[0].Claims["license_expires"])
|
||||
expiresClaim := licenses[0].Claims["license_expires"]
|
||||
expiresString, ok := expiresClaim.(string)
|
||||
require.True(t, ok, "license_expires claim is not a string")
|
||||
assert.NotEmpty(t, expiresClaim)
|
||||
expiresTime, err := time.Parse(time.RFC3339, expiresString)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, expectedLicenseExpires, expiresTime.UTC())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user