From be5bcf4d3fcf8220acc0817ca6325a1e7d0f7936 Mon Sep 17 00:00:00 2001 From: odubajDT Date: Wed, 5 Oct 2022 15:40:19 +0200 Subject: [PATCH] pr review Signed-off-by: odubajDT --- operator/config/manager/kustomization.yaml | 2 +- operator/controllers/keptntask/controller.go | 4 ++-- operator/controllers/keptnworkloadinstance/controller.go | 4 ++-- operator/main.go | 5 +++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/operator/config/manager/kustomization.yaml b/operator/config/manager/kustomization.yaml index c340bd19a8a..dbd1ddd4169 100644 --- a/operator/config/manager/kustomization.yaml +++ b/operator/config/manager/kustomization.yaml @@ -11,4 +11,4 @@ kind: Kustomization images: - name: controller newName: docker.io/odubajdt/keptn-lifecycle-operator - newTag: metrics10 + newTag: latest diff --git a/operator/controllers/keptntask/controller.go b/operator/controllers/keptntask/controller.go index fac2b3bb8b8..a79ebadc60d 100644 --- a/operator/controllers/keptntask/controller.go +++ b/operator/controllers/keptntask/controller.go @@ -66,8 +66,8 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( if !task.IsStartTimeSet() { // metrics: increment active task counter r.Meters.TaskActive.Add(ctx, 1, task.GetActiveMetricsAttributes()...) + task.SetStartTime() } - task.SetStartTime() err := r.Client.Status().Update(ctx, task) if err != nil { @@ -103,8 +103,8 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( if !task.IsEndTimeSet() { // metrics: decrement active task counter r.Meters.TaskActive.Add(ctx, -1, task.GetActiveMetricsAttributes()...) + task.SetEndTime() } - task.SetEndTime() err = r.Client.Status().Update(ctx, task) if err != nil { diff --git a/operator/controllers/keptnworkloadinstance/controller.go b/operator/controllers/keptnworkloadinstance/controller.go index 21c86ac2382..d06bbc879de 100644 --- a/operator/controllers/keptnworkloadinstance/controller.go +++ b/operator/controllers/keptnworkloadinstance/controller.go @@ -95,8 +95,8 @@ func (r *KeptnWorkloadInstanceReconciler) Reconcile(ctx context.Context, req ctr if !workloadInstance.IsStartTimeSet() { // metrics: increment active deployment counter r.Meters.DeploymentActive.Add(ctx, 1, workloadInstance.GetActiveMetricsAttributes()...) + workloadInstance.SetStartTime() } - workloadInstance.SetStartTime() if !workloadInstance.IsPreDeploymentCompleted() { r.Log.Info("Pre deployment checks not finished") @@ -133,8 +133,8 @@ func (r *KeptnWorkloadInstanceReconciler) Reconcile(ctx context.Context, req ctr if !workloadInstance.IsEndTimeSet() { // metrics: decrement active deployment counter r.Meters.DeploymentActive.Add(ctx, -1, workloadInstance.GetActiveMetricsAttributes()...) + workloadInstance.SetEndTime() } - workloadInstance.SetEndTime() err = r.Client.Status().Update(ctx, workloadInstance) if err != nil { diff --git a/operator/main.go b/operator/main.go index 5ec42f50fa8..7ff317ea1e7 100644 --- a/operator/main.go +++ b/operator/main.go @@ -37,6 +37,7 @@ import ( otelprom "go.opentelemetry.io/otel/exporters/prometheus" "go.opentelemetry.io/otel/metric/instrument" + "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/sdk/metric" "sigs.k8s.io/controller-runtime/pkg/webhook" @@ -88,7 +89,7 @@ func main() { if err != nil { setupLog.Error(err, "unable to start OTel") } - deploymentDuration, err := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn deployment")) + deploymentDuration, err := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn deployment"), instrument.WithUnit(unit.Unit("s"))) if err != nil { setupLog.Error(err, "unable to start OTel") } @@ -100,7 +101,7 @@ func main() { if err != nil { setupLog.Error(err, "unable to start OTel") } - taskDuration, err := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn tasks")) + taskDuration, err := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn tasks"), instrument.WithUnit(unit.Unit("s"))) if err != nil { setupLog.Error(err, "unable to start OTel") }