Skip to content

Commit 251c488

Browse files
chandankumar4juliev0
authored andcommitted
fix: Update numaplane progressive metrics (#927)
Signed-off-by: chandankumar4 <chandan.kr404@gmail.com>
1 parent 619d427 commit 251c488

File tree

9 files changed

+83
-62
lines changed

9 files changed

+83
-62
lines changed

internal/controller/isbservicerollout/isbservicerollout_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,9 @@ func (r *ISBServiceRolloutReconciler) processExistingISBService(ctx context.Cont
477477
// assessmentResult value indicates that the progressive rollout is completed, so we can generate the metrics for the same
478478
assessmentResult := metrics.EvaluateSuccessStatusForMetrics(isbServiceRollout.GetUpgradingChildStatus().AssessmentResult)
479479
if assessmentResult != "" {
480-
r.customMetrics.IncISBSvcProgressiveResults(isbServiceRollout.GetRolloutObjectMeta().GetNamespace(), isbServiceRollout.GetRolloutObjectMeta().GetName(),
480+
r.customMetrics.IncISBServiceProgressiveCompleted(isbServiceRollout.GetRolloutObjectMeta().GetNamespace(), isbServiceRollout.GetRolloutObjectMeta().GetName(),
481481
isbServiceRollout.GetUpgradingChildStatus().Name, metrics.EvaluateSuccessStatusForMetrics(isbServiceRollout.GetUpgradingChildStatus().BasicAssessmentResult),
482-
assessmentResult, isbServiceRollout.GetUpgradingChildStatus().ForcedSuccess, true)
482+
assessmentResult, isbServiceRollout.GetUpgradingChildStatus().ForcedSuccess)
483483
}
484484
}
485485
} else {

internal/controller/isbservicerollout/isbservicerollout_progressive.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/numaproj/numaplane/internal/util"
1717
"github.com/numaproj/numaplane/internal/util/kubernetes"
1818
"github.com/numaproj/numaplane/internal/util/logger"
19-
"github.com/numaproj/numaplane/internal/util/metrics"
2019
apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1"
2120
)
2221

@@ -221,15 +220,10 @@ func (r *ISBServiceRolloutReconciler) ProcessUpgradingChildPostUpgrade(
221220
return false, nil
222221
}
223222

224-
func (r *ISBServiceRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject, completed bool) {
223+
func (r *ISBServiceRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject) {
225224
if rolloutObject.GetUpgradingChildStatus() != nil {
226225
childName := rolloutObject.GetUpgradingChildStatus().Name
227-
successStatus := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().AssessmentResult)
228-
forcedSuccess := rolloutObject.GetUpgradingChildStatus().ForcedSuccess
229-
basicAssessmentResult := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().BasicAssessmentResult)
230-
231-
r.customMetrics.IncISBSvcProgressiveResults(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(),
232-
childName, basicAssessmentResult, successStatus, forcedSuccess, completed)
226+
r.customMetrics.IncIBSServiceProgressiveStarted(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(), childName)
233227
}
234228
}
235229

internal/controller/monovertexrollout/monovertexrollout_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ func (r *MonoVertexRolloutReconciler) processExistingMonoVertex(ctx context.Cont
382382
// assessmentResult value indicates that the progressive rollout is completed, so we can generate the metrics for the same
383383
assessmentResult := metrics.EvaluateSuccessStatusForMetrics(monoVertexRollout.GetUpgradingChildStatus().AssessmentResult)
384384
if assessmentResult != "" {
385-
r.customMetrics.IncMonovertexProgressiveResults(monoVertexRollout.GetRolloutObjectMeta().GetNamespace(), monoVertexRollout.GetRolloutObjectMeta().GetName(),
385+
r.customMetrics.IncMonovertexProgressiveCompleted(monoVertexRollout.GetRolloutObjectMeta().GetNamespace(), monoVertexRollout.GetRolloutObjectMeta().GetName(),
386386
monoVertexRollout.GetUpgradingChildStatus().Name, metrics.EvaluateSuccessStatusForMetrics(monoVertexRollout.GetUpgradingChildStatus().BasicAssessmentResult),
387-
assessmentResult, monoVertexRollout.GetUpgradingChildStatus().ForcedSuccess, true)
387+
assessmentResult, monoVertexRollout.GetUpgradingChildStatus().ForcedSuccess)
388388
}
389389
}
390390
} else {

internal/controller/monovertexrollout/monovertexrollout_progressive.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/numaproj/numaplane/internal/util"
1919
"github.com/numaproj/numaplane/internal/util/kubernetes"
2020
"github.com/numaproj/numaplane/internal/util/logger"
21-
"github.com/numaproj/numaplane/internal/util/metrics"
2221
apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1"
2322

2423
"github.com/numaproj/numaplane/internal/common"
@@ -757,14 +756,9 @@ func (r *MonoVertexRolloutReconciler) ProgressiveUnsupported(ctx context.Context
757756
return false
758757
}
759758

760-
func (r *MonoVertexRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject, completed bool) {
759+
func (r *MonoVertexRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject) {
761760
if rolloutObject.GetUpgradingChildStatus() != nil {
762761
childName := rolloutObject.GetUpgradingChildStatus().Name
763-
successStatus := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().AssessmentResult)
764-
forcedSuccess := rolloutObject.GetUpgradingChildStatus().ForcedSuccess
765-
basicAssessmentResult := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().BasicAssessmentResult)
766-
767-
r.customMetrics.IncMonovertexProgressiveResults(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(),
768-
childName, basicAssessmentResult, successStatus, forcedSuccess, completed)
762+
r.customMetrics.IncMonovertexProgressiveStarted(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(), childName)
769763
}
770764
}

internal/controller/pipelinerollout/pipelinerollout_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,9 @@ func (r *PipelineRolloutReconciler) processExistingPipeline(ctx context.Context,
638638
// assessmentResult value indicates that the progressive rollout is completed, so we can generate the metrics for the same
639639
assessmentResult := metrics.EvaluateSuccessStatusForMetrics(pipelineRollout.GetUpgradingChildStatus().AssessmentResult)
640640
if assessmentResult != "" {
641-
r.customMetrics.IncPipelineProgressiveResults(pipelineRollout.GetRolloutObjectMeta().GetNamespace(), pipelineRollout.GetRolloutObjectMeta().GetName(),
641+
r.customMetrics.IncPipelineProgressiveCompleted(pipelineRollout.GetRolloutObjectMeta().GetNamespace(), pipelineRollout.GetRolloutObjectMeta().GetName(),
642642
pipelineRollout.GetUpgradingChildStatus().Name, metrics.EvaluateSuccessStatusForMetrics(pipelineRollout.GetUpgradingChildStatus().BasicAssessmentResult),
643-
assessmentResult, pipelineRollout.GetUpgradingChildStatus().ForcedSuccess, true)
643+
assessmentResult, pipelineRollout.GetUpgradingChildStatus().ForcedSuccess)
644644
}
645645
}
646646
} else {

internal/controller/pipelinerollout/pipelinerollout_progressive.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/numaproj/numaplane/internal/util"
2121
"github.com/numaproj/numaplane/internal/util/kubernetes"
2222
"github.com/numaproj/numaplane/internal/util/logger"
23-
"github.com/numaproj/numaplane/internal/util/metrics"
2423
apiv1 "github.com/numaproj/numaplane/pkg/apis/numaplane/v1alpha1"
2524
)
2625

@@ -788,14 +787,9 @@ func (r *PipelineRolloutReconciler) ProgressiveUnsupported(ctx context.Context,
788787
return false
789788
}
790789

791-
func (r *PipelineRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject, completed bool) {
790+
func (r *PipelineRolloutReconciler) UpdateProgressiveMetrics(rolloutObject progressive.ProgressiveRolloutObject) {
792791
if rolloutObject.GetUpgradingChildStatus() != nil {
793792
childName := rolloutObject.GetUpgradingChildStatus().Name
794-
successStatus := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().AssessmentResult)
795-
forcedSuccess := rolloutObject.GetUpgradingChildStatus().ForcedSuccess
796-
basicAssessmentResult := metrics.EvaluateSuccessStatusForMetrics(rolloutObject.GetUpgradingChildStatus().BasicAssessmentResult)
797-
798-
r.customMetrics.IncPipelineProgressiveResults(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(),
799-
childName, basicAssessmentResult, successStatus, forcedSuccess, completed)
793+
r.customMetrics.IncPipelineProgressiveStarted(rolloutObject.GetRolloutObjectMeta().GetNamespace(), rolloutObject.GetRolloutObjectMeta().GetName(), childName)
800794
}
801795
}

internal/controller/progressive/progressive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type progressiveController interface {
8888
// ProgressiveUnsupported checks to see if Full Progressive Rollout (with assessment) is unsupported for this Rollout
8989
ProgressiveUnsupported(ctx context.Context, rolloutObject ProgressiveRolloutObject) bool
9090

91-
UpdateProgressiveMetrics(rolloutObject ProgressiveRolloutObject, completed bool)
91+
UpdateProgressiveMetrics(rolloutObject ProgressiveRolloutObject)
9292
}
9393

9494
// ProgressiveRolloutObject describes a Rollout instance that supports progressive upgrade
@@ -816,7 +816,7 @@ func startUpgradeProcess(
816816
}
817817

818818
// Update progressive metrics after creating the upgrading child
819-
controller.UpdateProgressiveMetrics(rolloutObject, false)
819+
controller.UpdateProgressiveMetrics(rolloutObject)
820820

821821
return newUpgradingChildDef, false, nil
822822
}

internal/controller/progressive/progressive_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

3030
type fakeProgressiveController struct{}
3131

32-
func (fpc fakeProgressiveController) UpdateProgressiveMetrics(rolloutObject ProgressiveRolloutObject, completed bool) {
32+
func (fpc fakeProgressiveController) UpdateProgressiveMetrics(rolloutObject ProgressiveRolloutObject) {
3333
}
3434

3535
func (fpc fakeProgressiveController) CreateUpgradingChildDefinition(ctx context.Context, rolloutObject ProgressiveRolloutObject, name string) (*unstructured.Unstructured, error) {

internal/util/metrics/metrics.go

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,12 @@ type CustomMetrics struct {
9494
ISBServicePausedSeconds *prometheus.GaugeVec
9595

9696
// Progressive Rollout Metrics
97-
PipelineProgressiveResults *prometheus.CounterVec
98-
IsbSvcProgressiveResults *prometheus.CounterVec
99-
MonoVertexProgressiveResults *prometheus.CounterVec
97+
PipelineProgressiveStarted *prometheus.CounterVec
98+
PipelineProgressiveCompleted *prometheus.CounterVec
99+
ISBServiceProgressiveStarted *prometheus.CounterVec
100+
ISBServiceProgressiveCompleted *prometheus.CounterVec
101+
MonovertexProgressiveStarted *prometheus.CounterVec
102+
MonovertexProgressiveCompleted *prometheus.CounterVec
100103
}
101104

102105
const (
@@ -351,26 +354,47 @@ var (
351354
ConstLabels: defaultLabels,
352355
}, []string{})
353356

354-
// pipelineProgressiveResults count the total number of pipeline progressive rollout results
355-
pipelineProgressiveResults = promauto.NewCounterVec(prometheus.CounterOpts{
356-
Name: "numaplane_pipeline_progressive_results_total",
357-
Help: "The total number of pipeline progressive rollout results",
357+
// pipelineProgressiveStarted count the total number of pipeline progressive rollouts started
358+
pipelineProgressiveStarted = promauto.NewCounterVec(prometheus.CounterOpts{
359+
Name: "numaplane_pipeline_progressive_started",
360+
Help: "The total number of pipeline progressive rollout started",
358361
ConstLabels: defaultLabels,
359-
}, []string{LabelNamespace, LabelName, LabelRolloutName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess, LabelCompleted})
362+
}, []string{LabelNamespace, LabelRolloutName, LabelName})
360363

361-
//ISBSvcProgressiveResults count the total number of isbsvc progressive rollout results
362-
isbSvcProgressiveResults = promauto.NewCounterVec(prometheus.CounterOpts{
363-
Name: "numaplane_isbsvc_progressive_results_total",
364-
Help: "The total number of isbsvc progressive rollout results",
364+
// pipelineProgressiveResults count the total number of pipeline progressive rollouts completed
365+
pipelineProgressiveCompleted = promauto.NewCounterVec(prometheus.CounterOpts{
366+
Name: "numaplane_pipeline_progressive_completed",
367+
Help: "The total number of pipeline progressive rollout completed",
365368
ConstLabels: defaultLabels,
366-
}, []string{LabelNamespace, LabelName, LabelRolloutName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess, LabelCompleted})
369+
}, []string{LabelNamespace, LabelRolloutName, LabelName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess})
367370

368-
// MonoVertexProgressiveResults count the total number of monovertex progressive rollout results
369-
monoVertexProgressiveResults = promauto.NewCounterVec(prometheus.CounterOpts{
370-
Name: "numaplane_monovertex_progressive_results_total",
371-
Help: "The total number of monovertex progressive rollout results",
371+
// isbServiceProgressiveStarted count the total number of ISB Service progressive rollouts started
372+
isbServiceProgressiveStarted = promauto.NewCounterVec(prometheus.CounterOpts{
373+
Name: "numaplane_isbsvc_progressive_started",
374+
Help: "The total number of pipeline isbsvc rollout started",
372375
ConstLabels: defaultLabels,
373-
}, []string{LabelNamespace, LabelName, LabelRolloutName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess, LabelCompleted})
376+
}, []string{LabelNamespace, LabelRolloutName, LabelName})
377+
378+
//isbServiceProgressiveCompleted count the total number of isbsvc progressive rollouts completed
379+
isbServiceProgressiveCompleted = promauto.NewCounterVec(prometheus.CounterOpts{
380+
Name: "numaplane_isbsvc_progressive_completed",
381+
Help: "The total number of isbsvc progressive rollout completed",
382+
ConstLabels: defaultLabels,
383+
}, []string{LabelNamespace, LabelRolloutName, LabelName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess})
384+
385+
// monovertexProgressiveStarted count the total number of monovertex progressive rollouts started
386+
monovertexProgressiveStarted = promauto.NewCounterVec(prometheus.CounterOpts{
387+
Name: "numaplane_monovertex_progressive_started",
388+
Help: "The total number of monovertex rollout started",
389+
ConstLabels: defaultLabels,
390+
}, []string{LabelNamespace, LabelRolloutName, LabelName})
391+
392+
// monovertexProgressiveCompleted count the total number of monovertex progressive rollout completed
393+
monovertexProgressiveCompleted = promauto.NewCounterVec(prometheus.CounterOpts{
394+
Name: "numaplane_monovertex_progressive_completed",
395+
Help: "The total number of monovertex progressive rollout completed",
396+
ConstLabels: defaultLabels,
397+
}, []string{LabelNamespace, LabelRolloutName, LabelName, LabelSuccess, LabelForcedSuccess, LabelResourceHealthSuccess})
374398
)
375399

376400
// RegisterCustomMetrics registers the custom metrics to the existing global prometheus registry for pipelines, ISB service and numaflow controller
@@ -382,8 +406,8 @@ func RegisterCustomMetrics(numaLogger *logger.NumaLogger) *CustomMetrics {
382406
numaflowControllerRolloutsHealth, numaflowControllerRolloutsRunning, numaflowControllerRolloutSyncs, numaflowControllerRolloutSyncErrors, numaflowControllerRolloutPausedSeconds,
383407
numaflowControllersHealth, numaflowControllerSyncs, numaflowControllerSyncErrors, numaflowControllerKubectlExecutionCounter,
384408
reconciliationDuration, kubeRequestCounter, kubeResourceCacheMonitored,
385-
kubeResourceCache, clusterCacheError, pipelinePausedSeconds, pipelinePausingSeconds, isbServicePausedSeconds, pipelineProgressiveResults,
386-
isbSvcProgressiveResults, monoVertexProgressiveResults)
409+
kubeResourceCache, clusterCacheError, pipelinePausedSeconds, pipelinePausingSeconds, isbServicePausedSeconds,
410+
pipelineProgressiveStarted, pipelineProgressiveCompleted, isbServiceProgressiveStarted, isbServiceProgressiveCompleted, monovertexProgressiveStarted, monovertexProgressiveCompleted)
387411

388412
return &CustomMetrics{
389413
NumaLogger: numaLogger,
@@ -421,9 +445,12 @@ func RegisterCustomMetrics(numaLogger *logger.NumaLogger) *CustomMetrics {
421445
PipelinePausedSeconds: pipelinePausedSeconds,
422446
PipelinePausingSeconds: pipelinePausingSeconds,
423447
ISBServicePausedSeconds: isbServicePausedSeconds,
424-
PipelineProgressiveResults: pipelineProgressiveResults,
425-
IsbSvcProgressiveResults: isbSvcProgressiveResults,
426-
MonoVertexProgressiveResults: monoVertexProgressiveResults,
448+
PipelineProgressiveStarted: pipelineProgressiveStarted,
449+
PipelineProgressiveCompleted: pipelineProgressiveCompleted,
450+
ISBServiceProgressiveStarted: isbServiceProgressiveStarted,
451+
ISBServiceProgressiveCompleted: isbServiceProgressiveCompleted,
452+
MonovertexProgressiveStarted: monovertexProgressiveStarted,
453+
MonovertexProgressiveCompleted: monovertexProgressiveCompleted,
427454
}
428455
}
429456

@@ -600,16 +627,28 @@ func (m *CustomMetrics) IncProgressivePipelineDrains(namespace, pipelineRolloutN
600627
m.ProgressivePipelineDrains.WithLabelValues(namespace, pipelineRolloutName, pipelineName, strconv.FormatBool(drainComplete), string(drainResult)).Inc()
601628
}
602629

603-
func (m *CustomMetrics) IncPipelineProgressiveResults(namespace, name, childName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess, completed bool) {
604-
m.PipelineProgressiveResults.WithLabelValues(namespace, childName, name, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString(), strconv.FormatBool(completed)).Inc()
630+
func (m *CustomMetrics) IncPipelineProgressiveStarted(namespace, rolloutName, pipelineName string) {
631+
m.PipelineProgressiveStarted.WithLabelValues(namespace, rolloutName, pipelineName).Inc()
632+
}
633+
634+
func (m *CustomMetrics) IncPipelineProgressiveCompleted(namespace, rolloutName, pipelineName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess bool) {
635+
m.PipelineProgressiveCompleted.WithLabelValues(namespace, rolloutName, pipelineName, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString()).Inc()
636+
}
637+
638+
func (m *CustomMetrics) IncIBSServiceProgressiveStarted(namespace, rolloutName, isbServiceName string) {
639+
m.ISBServiceProgressiveStarted.WithLabelValues(namespace, rolloutName, isbServiceName).Inc()
640+
}
641+
642+
func (m *CustomMetrics) IncISBServiceProgressiveCompleted(namespace, rolloutName, isbServiceName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess bool) {
643+
m.ISBServiceProgressiveCompleted.WithLabelValues(namespace, rolloutName, isbServiceName, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString()).Inc()
605644
}
606645

607-
func (m *CustomMetrics) IncISBSvcProgressiveResults(namespace, name, childName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess, completed bool) {
608-
m.IsbSvcProgressiveResults.WithLabelValues(namespace, childName, name, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString(), strconv.FormatBool(completed)).Inc()
646+
func (m *CustomMetrics) IncMonovertexProgressiveStarted(namespace, rolloutName, monovertexName string) {
647+
m.MonovertexProgressiveStarted.WithLabelValues(namespace, rolloutName, monovertexName).Inc()
609648
}
610649

611-
func (m *CustomMetrics) IncMonovertexProgressiveResults(namespace, name, childName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess, completed bool) {
612-
m.MonoVertexProgressiveResults.WithLabelValues(namespace, childName, name, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString(), strconv.FormatBool(completed)).Inc()
650+
func (m *CustomMetrics) IncMonovertexProgressiveCompleted(namespace, rolloutName, monovertexName string, basicAssessmentResult, successStatus util.OptionalBoolStr, forcedSuccess bool) {
651+
m.MonovertexProgressiveCompleted.WithLabelValues(namespace, rolloutName, monovertexName, successStatus.ToString(), strconv.FormatBool(forcedSuccess), basicAssessmentResult.ToString()).Inc()
613652
}
614653

615654
func EvaluateSuccessStatusForMetrics(assessmentResult apiv1.AssessmentResult) util.OptionalBoolStr {

0 commit comments

Comments
 (0)