fix(coderd): workspaceapps: update last_used_at when workspace app reports stats (#11603)

- Adds a new query BatchUpdateLastUsedAt
- Adds calls to BatchUpdateLastUsedAt in app stats handler upon flush
- Passes a stats flush channel to apptest setup scaffolding and updates unit tests to assert modifications to LastUsedAt.
This commit is contained in:
Cian Johnston
2024-01-16 14:06:39 +00:00
committed by GitHub
parent 5bfbf9f9e6
commit d583acad00
16 changed files with 186 additions and 15 deletions

View File

@ -114,6 +114,13 @@ func (m metricsStore) ArchiveUnusedTemplateVersions(ctx context.Context, arg dat
return r0, r1
}
func (m metricsStore) BatchUpdateWorkspaceLastUsedAt(ctx context.Context, arg database.BatchUpdateWorkspaceLastUsedAtParams) error {
start := time.Now()
r0 := m.s.BatchUpdateWorkspaceLastUsedAt(ctx, arg)
m.queryLatencies.WithLabelValues("BatchUpdateWorkspaceLastUsedAt").Observe(time.Since(start).Seconds())
return r0
}
func (m metricsStore) CleanTailnetCoordinators(ctx context.Context) error {
start := time.Now()
err := m.s.CleanTailnetCoordinators(ctx)