mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(coderd/database/dbmetrics): add query_counts_total metric (#21506)
Adds a new Prometheus metric `coderd_db_query_counts_total` that tracks the total number of queries by route, method, and query name. This is aimed at helping us track down potential optimization candidates for HTTP handlers that may trigger a number of queries. It is expected to be used alongside `coderd_api_requests_processed_total` for correlation. Depends upon new middleware introduced in https://github.com/coder/coder/pull/21498 Relates to https://github.com/coder/internal/issues/1214
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -55,8 +55,9 @@ func run() error {
|
||||
start := time.Now()
|
||||
%s := m.s.%s(%s)
|
||||
m.queryLatencies.WithLabelValues("%s").Observe(time.Since(start).Seconds())
|
||||
m.queryCounts.WithLabelValues(httpmw.ExtractHTTPRoute(ctx), httpmw.ExtractHTTPMethod(ctx), "%s").Inc()
|
||||
return %s
|
||||
`, params.Returns, params.FuncName, params.Parameters, params.FuncName, params.Returns)
|
||||
`, params.Returns, params.FuncName, params.Parameters, params.FuncName, params.FuncName, params.Returns)
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("stub dbmetrics: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user