Skip to content

PTEUDO-1658: refining metrics. #357

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 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/databaseclaim/databaseclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ func (r *DatabaseClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}
}

// Increment total claims count.
metrics.TotalDatabaseClaims.Inc()

// Track if the claim is using an existing source.
if dbClaim.Spec.UseExistingSource != nil && *dbClaim.Spec.UseExistingSource {
metrics.ExistingSourceClaims.WithLabelValues("true").Inc()
Expand Down Expand Up @@ -257,6 +254,13 @@ func (r *DatabaseClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reques
metrics.ActiveDBState.WithLabelValues(string(dbClaim.Status.ActiveDB.DbState)).Inc()
}

var databaseClaims v1.DatabaseClaimList
if err := r.List(ctx, &databaseClaims); err != nil {
logr.Error(err, "unable to list database claims")
} else {
metrics.TotalDatabaseClaims.WithLabelValues("total_claims").Set(float64(len(databaseClaims.Items)))
}

return res, nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ var (
// -----------------------------------------------------------------------
// Database controller metrics

TotalDatabaseClaims = prometheus.NewGauge(
TotalDatabaseClaims = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "dbcontroller_total_database_claims",
Help: "Total number of database claims",
},
[]string{"total_claims"},
)
TotalDatabaseClaimsDeleted = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand Down
Loading