Skip to content

Commit

Permalink
PTEUDO-1179: adjusting reported dbclaims metrics (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrorichardtoledo authored Oct 28, 2024
1 parent 61da8a4 commit 0e43015
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/databaseclaim/databaseclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ func (r *DatabaseClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reques

if err := validateDBClaim(&dbClaim); err != nil {
res, err := r.manageError(ctx, &dbClaim, err)
if dbClaim.Status.Error != "" {
metrics.ErrorStateClaims.Inc()
}
// TerminalError, do not requeue
return res, reconcile.TerminalError(err)
}
Expand All @@ -169,15 +172,19 @@ func (r *DatabaseClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reques

reqInfo, err := NewRequestInfo(ctx, r.Config.Viper, &dbClaim)
if err != nil {
return r.manageError(ctx, &dbClaim, err)
res, err := r.manageError(ctx, &dbClaim, err)
if dbClaim.Status.Error != "" {
metrics.ErrorStateClaims.Inc()
}
return res, err
}

// name of our custom finalizer
dbFinalizerName := "databaseclaims.persistance.atlas.infoblox.com/finalizer"

if !dbClaim.ObjectMeta.DeletionTimestamp.IsZero() {
// Increment total claims count.
metrics.TotalDatabaseClaims.Dec()
metrics.TotalDatabaseClaimsDeleted.Inc()

// The object is being deleted
if controllerutil.ContainsFinalizer(&dbClaim, dbFinalizerName) {
Expand Down Expand Up @@ -234,14 +241,12 @@ func (r *DatabaseClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}
res, err := r.executeDbClaimRequest(ctx, &reqInfo, &dbClaim)
if err != nil {
if dbClaim.Status.Error != "" {
metrics.ErrorStateClaims.Inc()
}
return res, err
}

// Track claims in error state.
if dbClaim.Status.Error != "" {
metrics.ErrorStateClaims.Inc()
}

// Track migration state.
if dbClaim.Status.MigrationState != "" {
metrics.MigrationStateClaims.WithLabelValues(dbClaim.Status.MigrationState).Inc()
Expand Down
6 changes: 6 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ var (
Help: "Total number of database claims",
},
)
TotalDatabaseClaimsDeleted = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "dbcontroller_total_database_claims_deleted",
Help: "Total number of database claims marked for deletion",
},
)
ExistingSourceClaims = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "dbcontroller_existing_source_claims",
Expand Down

0 comments on commit 0e43015

Please sign in to comment.