Skip to content

feat: expose template insights as Prometheus metrics #10325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Oct 19, 2023
Prev Previous commit
Next Next commit
debug
  • Loading branch information
mtojek committed Oct 13, 2023
commit 86f45a064028a6f797dc94c5a7c23c20804fe05b
8 changes: 6 additions & 2 deletions coderd/prometheusmetrics/insights/metricscollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"context"
"time"

"cdr.dev/slog"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/xerrors"

"cdr.dev/slog"

"github.com/coder/coder/v2/coderd/database"
)

Expand Down Expand Up @@ -52,15 +53,18 @@ func (mc *MetricsCollector) Run(ctx context.Context) (func(), error) {

now := time.Now()

// TODO collect iteration time

parameterRows, err := mc.database.GetTemplateInsights(ctx, database.GetTemplateInsightsParams{
StartTime: now.Add(-mc.duration),
EndTime: now,
})
if err != nil {
mc.logger.Error(ctx, "unable to fetch template insights from database: %w", err)
mc.logger.Error(ctx, "unable to fetch template insights from database", slog.Error(err))
return
}

mc.logger.Info(ctx, "debug", slog.F("parameter_rows", parameterRows))
}

go func() {
Expand Down