feat: Add workspace metrics export to Prometheus (#3421)

This adds workspace totals indexed by status. It could be any
codersdk.ProvisionerJobStatus.
This commit is contained in:
Kyle Carberry
2022-08-09 01:08:42 +00:00
committed by GitHub
parent e62677efab
commit 7bdb8ff9cf
10 changed files with 329 additions and 31 deletions
+8 -2
View File
@@ -402,11 +402,17 @@ func server() *cobra.Command {
}
if promEnabled {
options.PrometheusRegistry = prometheus.NewRegistry()
closeFunc, err := prometheusmetrics.ActiveUsers(ctx, options.PrometheusRegistry, options.Database, 0)
closeUsersFunc, err := prometheusmetrics.ActiveUsers(ctx, options.PrometheusRegistry, options.Database, 0)
if err != nil {
return xerrors.Errorf("register active users prometheus metric: %w", err)
}
defer closeFunc()
defer closeUsersFunc()
closeWorkspacesFunc, err := prometheusmetrics.Workspaces(ctx, options.PrometheusRegistry, options.Database, 0)
if err != nil {
return xerrors.Errorf("register workspaces prometheus metric: %w", err)
}
defer closeWorkspacesFunc()
//nolint:revive
defer serveHandler(ctx, logger, promhttp.InstrumentMetricHandler(