From a7475c2ae13479fed55fa4a322af3c2a47649fa1 Mon Sep 17 00:00:00 2001 From: odubajDT <93584209+odubajDT@users.noreply.github.com> Date: Wed, 17 May 2023 13:03:25 +0200 Subject: [PATCH] chore(operator): bump OTel dependencies to the latest version (#1419) Signed-off-by: odubajDT --- .../apis/lifecycle/v1alpha1/common/common.go | 19 +- .../apis/lifecycle/v1alpha2/common/common.go | 19 +- .../apis/lifecycle/v1alpha3/common/common.go | 19 +- operator/controllers/common/metrics.go | 15 +- operator/controllers/common/metrics_test.go | 21 +- operator/controllers/common/otel_utils.go | 93 ++-- .../controllers/common/otel_utils_test.go | 87 +--- operator/controllers/common/test_utils.go | 15 +- .../fake/activemetricsobject_mock.go | 9 +- .../fake/async/tracer_provider_float_mock.go | 179 -------- .../fake/async/tracer_provider_int_mock.go | 179 -------- .../lifecycle/interfaces/fake/meter_mock.go | 402 ++++++++++++------ .../interfaces/fake/spanitem_mock.go | 9 +- .../fake/sync/tracer_provider_float_mock.go | 179 -------- .../fake/sync/tracer_provider_int_mock.go | 179 -------- .../controllers/lifecycle/interfaces/meter.go | 26 +- .../lifecycle/keptnappversion/controller.go | 5 +- .../lifecycle/keptnevaluation/controller.go | 5 +- .../lifecycle/keptntask/controller.go | 5 +- .../keptnworkloadinstance/controller.go | 5 +- operator/go.mod | 23 +- operator/go.sum | 47 +- operator/test/component/common/common.go | 23 +- 23 files changed, 466 insertions(+), 1097 deletions(-) delete mode 100644 operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_float_mock.go delete mode 100644 operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_int_mock.go delete mode 100644 operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_float_mock.go delete mode 100644 operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_int_mock.go diff --git a/operator/apis/lifecycle/v1alpha1/common/common.go b/operator/apis/lifecycle/v1alpha1/common/common.go index 73a93f495c..b714e7b71a 100644 --- a/operator/apis/lifecycle/v1alpha1/common/common.go +++ b/operator/apis/lifecycle/v1alpha1/common/common.go @@ -6,8 +6,7 @@ import ( "math/rand" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric" ) const WorkloadAnnotation = "keptn.sh/workload" @@ -132,14 +131,14 @@ const PreDeploymentEvaluationCheckType CheckType = "pre-eval" const PostDeploymentEvaluationCheckType CheckType = "post-eval" type KeptnMeters struct { - TaskCount syncint64.Counter - TaskDuration syncfloat64.Histogram - DeploymentCount syncint64.Counter - DeploymentDuration syncfloat64.Histogram - AppCount syncint64.Counter - AppDuration syncfloat64.Histogram - EvaluationCount syncint64.Counter - EvaluationDuration syncfloat64.Histogram + TaskCount metric.Int64Counter + TaskDuration metric.Float64Histogram + DeploymentCount metric.Int64Counter + DeploymentDuration metric.Float64Histogram + AppCount metric.Int64Counter + AppDuration metric.Float64Histogram + EvaluationCount metric.Int64Counter + EvaluationDuration metric.Float64Histogram } const ( diff --git a/operator/apis/lifecycle/v1alpha2/common/common.go b/operator/apis/lifecycle/v1alpha2/common/common.go index 92a8605524..4f758bbb6a 100644 --- a/operator/apis/lifecycle/v1alpha2/common/common.go +++ b/operator/apis/lifecycle/v1alpha2/common/common.go @@ -6,8 +6,7 @@ import ( "math/rand" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric" ) const WorkloadAnnotation = "keptn.sh/workload" @@ -134,14 +133,14 @@ const PreDeploymentEvaluationCheckType CheckType = "pre-eval" const PostDeploymentEvaluationCheckType CheckType = "post-eval" type KeptnMeters struct { - TaskCount syncint64.Counter - TaskDuration syncfloat64.Histogram - DeploymentCount syncint64.Counter - DeploymentDuration syncfloat64.Histogram - AppCount syncint64.Counter - AppDuration syncfloat64.Histogram - EvaluationCount syncint64.Counter - EvaluationDuration syncfloat64.Histogram + TaskCount metric.Int64Counter + TaskDuration metric.Float64Histogram + DeploymentCount metric.Int64Counter + DeploymentDuration metric.Float64Histogram + AppCount metric.Int64Counter + AppDuration metric.Float64Histogram + EvaluationCount metric.Int64Counter + EvaluationDuration metric.Float64Histogram } const ( diff --git a/operator/apis/lifecycle/v1alpha3/common/common.go b/operator/apis/lifecycle/v1alpha3/common/common.go index 40c9a368c3..51e33a2318 100644 --- a/operator/apis/lifecycle/v1alpha3/common/common.go +++ b/operator/apis/lifecycle/v1alpha3/common/common.go @@ -8,8 +8,7 @@ import ( "strconv" "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric" ) const WorkloadAnnotation = "keptn.sh/workload" @@ -148,14 +147,14 @@ const PreDeploymentEvaluationCheckType CheckType = "pre-eval" const PostDeploymentEvaluationCheckType CheckType = "post-eval" type KeptnMeters struct { - TaskCount syncint64.Counter - TaskDuration syncfloat64.Histogram - DeploymentCount syncint64.Counter - DeploymentDuration syncfloat64.Histogram - AppCount syncint64.Counter - AppDuration syncfloat64.Histogram - EvaluationCount syncint64.Counter - EvaluationDuration syncfloat64.Histogram + TaskCount metric.Int64Counter + TaskDuration metric.Float64Histogram + DeploymentCount metric.Int64Counter + DeploymentDuration metric.Float64Histogram + AppCount metric.Int64Counter + AppDuration metric.Float64Histogram + EvaluationCount metric.Int64Counter + EvaluationDuration metric.Float64Histogram } const ( diff --git a/operator/controllers/common/metrics.go b/operator/controllers/common/metrics.go index 4d002a1229..298a4b8f78 100644 --- a/operator/controllers/common/metrics.go +++ b/operator/controllers/common/metrics.go @@ -7,12 +7,11 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" + "go.opentelemetry.io/otel/metric" "sigs.k8s.io/controller-runtime/pkg/client" ) -func ObserveDeploymentDuration(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge asyncfloat64.Gauge) error { +func ObserveDeploymentDuration(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge metric.Float64ObservableGauge, o metric.Observer) error { err := client.List(ctx, reconcileObjectList) if err != nil { return fmt.Errorf(controllererrors.ErrCannotRetrieveInstancesMsg, err) @@ -27,14 +26,14 @@ func ObserveDeploymentDuration(ctx context.Context, client client.Client, reconc reconcileObject, _ := interfaces.NewMetricsObjectWrapperFromClientObject(ro) if reconcileObject.IsEndTimeSet() { duration := reconcileObject.GetEndTime().Sub(reconcileObject.GetStartTime()) - gauge.Observe(ctx, duration.Seconds(), reconcileObject.GetDurationMetricsAttributes()...) + o.ObserveFloat64(gauge, duration.Seconds(), metric.WithAttributes(reconcileObject.GetDurationMetricsAttributes()...)) } } return nil } -func ObserveDeploymentInterval(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge asyncfloat64.Gauge) error { +func ObserveDeploymentInterval(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge metric.Float64ObservableGauge, o metric.Observer) error { err := client.List(ctx, reconcileObjectList) if err != nil { return fmt.Errorf(controllererrors.ErrCannotRetrieveInstancesMsg, err) @@ -59,7 +58,7 @@ func ObserveDeploymentInterval(ctx context.Context, client client.Client, reconc } previousInterval := reconcileObject.GetEndTime().Sub(predecessor.GetEndTime()) - gauge.Observe(ctx, previousInterval.Seconds(), reconcileObject.GetDurationMetricsAttributes()...) + o.ObserveFloat64(gauge, previousInterval.Seconds(), metric.WithAttributes(reconcileObject.GetDurationMetricsAttributes()...)) } } @@ -84,7 +83,7 @@ func getPredecessor(successor *interfaces.MetricsObjectWrapper, items []client.O return predecessor } -func ObserveActiveInstances(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge asyncint64.Gauge) error { +func ObserveActiveInstances(ctx context.Context, client client.Client, reconcileObjectList client.ObjectList, gauge metric.Int64ObservableGauge, o metric.Observer) error { err := client.List(ctx, reconcileObjectList) if err != nil { return fmt.Errorf(controllererrors.ErrCannotRetrieveInstancesMsg, err) @@ -102,7 +101,7 @@ func ObserveActiveInstances(ctx context.Context, client client.Client, reconcile gaugeValue = int64(1) } - gauge.Observe(ctx, gaugeValue, activeMetricsObject.GetActiveMetricsAttributes()...) + o.ObserveInt64(gauge, gaugeValue, metric.WithAttributes(activeMetricsObject.GetActiveMetricsAttributes()...)) } return nil diff --git a/operator/controllers/common/metrics_test.go b/operator/controllers/common/metrics_test.go index 780fd1174a..4bfcfb46f1 100644 --- a/operator/controllers/common/metrics_test.go +++ b/operator/controllers/common/metrics_test.go @@ -9,8 +9,8 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" "github.com/stretchr/testify/require" - noop "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" + "go.opentelemetry.io/otel/metric" + "go.opentelemetry.io/otel/metric/noop" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" @@ -18,16 +18,14 @@ import ( ) func TestMetrics_ObserveDeploymentDuration(t *testing.T) { - - gauge, err := noop.NewNoopMeter().AsyncFloat64().Gauge("mine") - require.Nil(t, err) + gauge := noop.Float64ObservableGauge{} tests := []struct { name string clientObjects client.ObjectList list client.ObjectList err error - gauge asyncfloat64.Gauge + gauge metric.Float64ObservableGauge }{ { name: "failed to create wrapper", @@ -79,7 +77,7 @@ func TestMetrics_ObserveDeploymentDuration(t *testing.T) { err := lifecyclev1alpha3.AddToScheme(scheme.Scheme) require.Nil(t, err) client := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() - err = ObserveDeploymentDuration(context.TODO(), client, tt.list, gauge) + err = ObserveDeploymentDuration(context.TODO(), client, tt.list, gauge, noop.Observer{}) require.ErrorIs(t, err, tt.err) }) @@ -153,9 +151,9 @@ func TestMetrics_ObserveActiveInstances(t *testing.T) { err := lifecyclev1alpha3.AddToScheme(scheme.Scheme) require.Nil(t, err) client := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() - gauge, err := noop.NewNoopMeter().AsyncInt64().Gauge("mine") + gauge := noop.Int64ObservableGauge{} require.Nil(t, err) - err = ObserveActiveInstances(context.TODO(), client, tt.list, gauge) + err = ObserveActiveInstances(context.TODO(), client, tt.list, gauge, noop.Observer{}) require.ErrorIs(t, err, tt.err) }) @@ -365,15 +363,14 @@ func TestMetrics_ObserveDeploymentInterval(t *testing.T) { }, } - gauge, err := noop.NewNoopMeter().AsyncFloat64().Gauge("mine") - require.Nil(t, err) + gauge := noop.Float64ObservableGauge{} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := lifecyclev1alpha3.AddToScheme(scheme.Scheme) require.Nil(t, err) fakeClient := fake.NewClientBuilder().WithLists(tt.clientObjects).Build() - err = ObserveDeploymentInterval(context.TODO(), fakeClient, tt.list, gauge) + err = ObserveDeploymentInterval(context.TODO(), fakeClient, tt.list, gauge, noop.Observer{}) require.ErrorIs(t, err, tt.err) }) diff --git a/operator/controllers/common/otel_utils.go b/operator/controllers/common/otel_utils.go index fcd5b483dc..0d33e31c6d 100644 --- a/operator/controllers/common/otel_utils.go +++ b/operator/controllers/common/otel_utils.go @@ -9,14 +9,11 @@ import ( lifecyclev1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/unit" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/trace" @@ -158,141 +155,141 @@ func newResource() *resource.Resource { return r } -func SetUpKeptnMeters(meter metric.Meter, mgr client.Client) { - deploymentActiveGauge, err := meter.AsyncInt64().Gauge("keptn.deployment.active", instrument.WithDescription("a gauge keeping track of the currently active Keptn Deployments")) +func SetUpKeptnMeters(meter interfaces.IMeter, mgr client.Client) { + deploymentActiveGauge, err := meter.Int64ObservableGauge("keptn.deployment.active", metric.WithDescription("a gauge keeping track of the currently active Keptn Deployments")) if err != nil { logger.Error(err, "unable to initialize active deployments OTel gauge") } - taskActiveGauge, err := meter.AsyncInt64().Gauge("keptn.task.active", instrument.WithDescription("a simple counter of active Keptn Tasks")) + taskActiveGauge, err := meter.Int64ObservableGauge("keptn.task.active", metric.WithDescription("a simple counter of active Keptn Tasks")) if err != nil { logger.Error(err, "unable to initialize active tasks OTel gauge") } - appActiveGauge, err := meter.AsyncInt64().Gauge("keptn.app.active", instrument.WithDescription("a simple counter of active Keptn Apps")) + appActiveGauge, err := meter.Int64ObservableGauge("keptn.app.active", metric.WithDescription("a simple counter of active Keptn Apps")) if err != nil { logger.Error(err, "unable to initialize active apps OTel gauge") } - evaluationActiveGauge, err := meter.AsyncInt64().Gauge("keptn.evaluation.active", instrument.WithDescription("a simple counter of active Keptn Evaluations")) + evaluationActiveGauge, err := meter.Int64ObservableGauge("keptn.evaluation.active", metric.WithDescription("a simple counter of active Keptn Evaluations")) if err != nil { logger.Error(err, "unable to initialize active evaluations OTel gauge") } - appDeploymentIntervalGauge, err := meter.AsyncFloat64().Gauge("keptn.app.deploymentinterval", instrument.WithDescription("a gauge of the interval between app deployments")) + appDeploymentIntervalGauge, err := meter.Float64ObservableGauge("keptn.app.deploymentinterval", metric.WithDescription("a gauge of the interval between app deployments")) if err != nil { logger.Error(err, "unable to initialize app deployment interval OTel gauge") } - appDeploymentDurationGauge, err := meter.AsyncFloat64().Gauge("keptn.app.deploymentduration", instrument.WithDescription("a gauge of the duration of app deployments")) + appDeploymentDurationGauge, err := meter.Float64ObservableGauge("keptn.app.deploymentduration", metric.WithDescription("a gauge of the duration of app deployments")) if err != nil { logger.Error(err, "unable to initialize app deployment duration OTel gauge") } - workloadDeploymentIntervalGauge, err := meter.AsyncFloat64().Gauge("keptn.deployment.deploymentinterval", instrument.WithDescription("a gauge of the interval between workload deployments")) + workloadDeploymentIntervalGauge, err := meter.Float64ObservableGauge("keptn.deployment.deploymentinterval", metric.WithDescription("a gauge of the interval between workload deployments")) if err != nil { logger.Error(err, "unable to initialize workload deployment interval OTel gauge") } - workloadDeploymentDurationGauge, err := meter.AsyncFloat64().Gauge("keptn.deployment.deploymentduration", instrument.WithDescription("a gauge of the duration of workload deployments")) + workloadDeploymentDurationGauge, err := meter.Float64ObservableGauge("keptn.deployment.deploymentduration", metric.WithDescription("a gauge of the duration of workload deployments")) if err != nil { logger.Error(err, "unable to initialize workload deployment duration OTel gauge") } - err = meter.RegisterCallback( - []instrument.Asynchronous{ - deploymentActiveGauge, - taskActiveGauge, - appActiveGauge, - evaluationActiveGauge, - appDeploymentIntervalGauge, - appDeploymentDurationGauge, - workloadDeploymentIntervalGauge, - workloadDeploymentDurationGauge, + _, err = meter.RegisterCallback( + func(ctx context.Context, o metric.Observer) error { + observeActiveInstances(ctx, mgr, deploymentActiveGauge, appActiveGauge, taskActiveGauge, evaluationActiveGauge, o) + observeDeploymentInterval(ctx, mgr, appDeploymentIntervalGauge, workloadDeploymentIntervalGauge, o) + observeDuration(ctx, mgr, appDeploymentDurationGauge, workloadDeploymentDurationGauge, o) + return nil }, - func(ctx context.Context) { - observeActiveInstances(ctx, mgr, deploymentActiveGauge, appActiveGauge, taskActiveGauge, evaluationActiveGauge) - observeDeploymentInterval(ctx, mgr, appDeploymentIntervalGauge, workloadDeploymentIntervalGauge) - observeDuration(ctx, mgr, appDeploymentDurationGauge, workloadDeploymentDurationGauge) - }) + deploymentActiveGauge, + taskActiveGauge, + appActiveGauge, + evaluationActiveGauge, + appDeploymentIntervalGauge, + appDeploymentDurationGauge, + workloadDeploymentIntervalGauge, + workloadDeploymentDurationGauge, + ) if err != nil { fmt.Println("Failed to register callback") panic(err) } } -func observeDuration(ctx context.Context, mgr client.Client, appDeploymentDurationGauge asyncfloat64.Gauge, workloadDeploymentDurationGauge asyncfloat64.Gauge) { +func observeDuration(ctx context.Context, mgr client.Client, appDeploymentDurationGauge metric.Float64ObservableGauge, workloadDeploymentDurationGauge metric.Float64ObservableGauge, observer metric.Observer) { - err := ObserveDeploymentDuration(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentDurationGauge) + err := ObserveDeploymentDuration(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment durations") } - err = ObserveDeploymentDuration(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, workloadDeploymentDurationGauge) + err = ObserveDeploymentDuration(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, workloadDeploymentDurationGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment durations") } } -func observeDeploymentInterval(ctx context.Context, mgr client.Client, appDeploymentIntervalGauge asyncfloat64.Gauge, workloadDeploymentIntervalGauge asyncfloat64.Gauge) { - err := ObserveDeploymentInterval(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentIntervalGauge) +func observeDeploymentInterval(ctx context.Context, mgr client.Client, appDeploymentIntervalGauge metric.Float64ObservableGauge, workloadDeploymentIntervalGauge metric.Float64ObservableGauge, observer metric.Observer) { + err := ObserveDeploymentInterval(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather app deployment intervals") } - err = ObserveDeploymentInterval(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, workloadDeploymentIntervalGauge) + err = ObserveDeploymentInterval(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, workloadDeploymentIntervalGauge, observer) if err != nil { logger.Error(err, "unable to gather workload deployment intervals") } } -func observeActiveInstances(ctx context.Context, mgr client.Client, deploymentActiveGauge asyncint64.Gauge, appActiveGauge asyncint64.Gauge, taskActiveGauge asyncint64.Gauge, evaluationActiveGauge asyncint64.Gauge) { +func observeActiveInstances(ctx context.Context, mgr client.Client, deploymentActiveGauge metric.Int64ObservableGauge, appActiveGauge metric.Int64ObservableGauge, taskActiveGauge metric.Int64ObservableGauge, evaluationActiveGauge metric.Int64ObservableGauge, observer metric.Observer) { - err := ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, deploymentActiveGauge) + err := ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnWorkloadInstanceList{}, deploymentActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active deployments") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appActiveGauge) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnAppVersionList{}, appActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active apps") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnTaskList{}, taskActiveGauge) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnTaskList{}, taskActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active tasks") } - err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnEvaluationList{}, evaluationActiveGauge) + err = ObserveActiveInstances(ctx, mgr, &lifecyclev1alpha3.KeptnEvaluationList{}, evaluationActiveGauge, observer) if err != nil { logger.Error(err, "unable to gather active evaluations") } } -func SetUpKeptnTaskMeters(meter metric.Meter) common.KeptnMeters { - deploymentCount, err := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) +func SetUpKeptnTaskMeters(meter interfaces.IMeter) common.KeptnMeters { + deploymentCount, err := meter.Int64Counter("keptn.deployment.count", metric.WithDescription("a simple counter for Keptn Deployments")) if err != nil { logger.Error(err, "unable to initialize deployment count OTel counter") } - deploymentDuration, err := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit(unit.Unit("s"))) + deploymentDuration, err := meter.Float64Histogram("keptn.deployment.duration", metric.WithDescription("a histogram of duration for Keptn Deployments"), metric.WithUnit("s")) if err != nil { logger.Error(err, "unable to initialize deployment duration OTel histogram") } - taskCount, err := meter.SyncInt64().Counter("keptn.task.count", instrument.WithDescription("a simple counter for Keptn Tasks")) + taskCount, err := meter.Int64Counter("keptn.task.count", metric.WithDescription("a simple counter for Keptn Tasks")) if err != nil { logger.Error(err, "unable to initialize task OTel counter") } - taskDuration, err := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn Tasks"), instrument.WithUnit(unit.Unit("s"))) + taskDuration, err := meter.Float64Histogram("keptn.task.duration", metric.WithDescription("a histogram of duration for Keptn Tasks"), metric.WithUnit("s")) if err != nil { logger.Error(err, "unable to initialize task duration OTel histogram") } - appCount, err := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) + appCount, err := meter.Int64Counter("keptn.app.count", metric.WithDescription("a simple counter for Keptn Apps")) if err != nil { logger.Error(err, "unable to initialize app OTel counter") } - appDuration, err := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit(unit.Unit("s"))) + appDuration, err := meter.Float64Histogram("keptn.app.duration", metric.WithDescription("a histogram of duration for Keptn Apps"), metric.WithUnit("s")) if err != nil { logger.Error(err, "unable to initialize app duration OTel histogram") } - evaluationCount, err := meter.SyncInt64().Counter("keptn.evaluation.count", instrument.WithDescription("a simple counter for Keptn Evaluations")) + evaluationCount, err := meter.Int64Counter("keptn.evaluation.count", metric.WithDescription("a simple counter for Keptn Evaluations")) if err != nil { logger.Error(err, "unable to initialize evaluation OTel counter") } - evaluationDuration, err := meter.SyncFloat64().Histogram("keptn.evaluation.duration", instrument.WithDescription("a histogram of duration for Keptn Evaluations"), instrument.WithUnit(unit.Unit("s"))) + evaluationDuration, err := meter.Float64Histogram("keptn.evaluation.duration", metric.WithDescription("a histogram of duration for Keptn Evaluations"), metric.WithUnit("s")) if err != nil { logger.Error(err, "unable to initialize evaluation duration OTel histogram") } diff --git a/operator/controllers/common/otel_utils_test.go b/operator/controllers/common/otel_utils_test.go index 49a68296bb..aee0b318ad 100644 --- a/operator/controllers/common/otel_utils_test.go +++ b/operator/controllers/common/otel_utils_test.go @@ -1,21 +1,15 @@ package common import ( - "context" "net" "testing" + "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces" "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces/fake" - fakeasync "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces/fake/async" - fakesync "github.com/keptn/lifecycle-toolkit/operator/controllers/lifecycle/interfaces/fake/sync" "github.com/pkg/errors" "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" + "go.opentelemetry.io/otel/metric/noop" "google.golang.org/grpc" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -85,31 +79,20 @@ func TestGetOTelTracerProviderOptions(t *testing.T) { } func TestSetUpKeptnMeters(t *testing.T) { - fakeAsyncIntTracerProvider := &fakeasync.ITracerProviderAsyncInt64Mock{ - GaugeFunc: func(name string, opts ...instrument.Option) (asyncint64.Gauge, error) { + fakeMeter := &fake.IMeterMock{ + Int64ObservableGaugeFunc: func(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) { return nil, errors.New("some error") }, - } - fakeAsyncFloatTracerProvider := &fakeasync.ITracerProviderAsyncFloat64Mock{ - GaugeFunc: func(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) { + Float64ObservableGaugeFunc: func(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) { return nil, errors.New("some error") }, - } - - fakeMeter := &fake.IMeterMock{ - AsyncInt64Func: func() asyncint64.InstrumentProvider { - return fakeAsyncIntTracerProvider - }, - AsyncFloat64Func: func() asyncfloat64.InstrumentProvider { - return fakeAsyncFloatTracerProvider - }, - RegisterCallbackFunc: func(insts []instrument.Asynchronous, function func(context.Context)) error { - return nil + RegisterCallbackFunc: func(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) { + return nil, nil }, } type args struct { - meter metric.Meter + meter interfaces.IMeter mgr client.Client } tests := []struct { @@ -120,7 +103,7 @@ func TestSetUpKeptnMeters(t *testing.T) { { name: "Basic case", args: args{ - meter: metric.NewNoopMeter(), + meter: noop.NewMeterProvider().Meter(("test")), mgr: nil, }, wantRegisterCalls: 0, @@ -143,17 +126,6 @@ func TestSetUpKeptnMeters(t *testing.T) { } func TestSetUpKeptnMetersError(t *testing.T) { - fakeAsyncIntTracerProvider := &fakeasync.ITracerProviderAsyncInt64Mock{ - GaugeFunc: func(name string, opts ...instrument.Option) (asyncint64.Gauge, error) { - return nil, errors.New("some error") - }, - } - fakeAsyncFloatTracerProvider := &fakeasync.ITracerProviderAsyncFloat64Mock{ - GaugeFunc: func(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) { - return nil, errors.New("some error") - }, - } - defer func() { if r := recover(); r == nil { t.Errorf("The code did not panic") @@ -161,14 +133,14 @@ func TestSetUpKeptnMetersError(t *testing.T) { }() errorFakeMeter := &fake.IMeterMock{ - AsyncInt64Func: func() asyncint64.InstrumentProvider { - return fakeAsyncIntTracerProvider + Int64ObservableGaugeFunc: func(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) { + return nil, errors.New("some error") }, - AsyncFloat64Func: func() asyncfloat64.InstrumentProvider { - return fakeAsyncFloatTracerProvider + Float64ObservableGaugeFunc: func(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) { + return nil, errors.New("some error") }, - RegisterCallbackFunc: func(insts []instrument.Asynchronous, function func(context.Context)) error { - return errors.New("some error") + RegisterCallbackFunc: func(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) { + return nil, errors.New("some error") }, } @@ -176,9 +148,7 @@ func TestSetUpKeptnMetersError(t *testing.T) { } func TestSetUpKeptnTaskMeters(t *testing.T) { - noopMeter := metric.NewNoopMeter() - - got := SetUpKeptnTaskMeters(noopMeter) + got := SetUpKeptnTaskMeters(noop.NewMeterProvider().Meter(("test"))) require.NotNil(t, got.TaskCount) require.NotNil(t, got.TaskDuration) @@ -191,32 +161,21 @@ func TestSetUpKeptnTaskMeters(t *testing.T) { } func TestSetUpKeptnTaskMeters_ErrorCase(t *testing.T) { - fakeSyncIntTracerProvider := &fakesync.ITracerProviderSyncInt64Mock{ - CounterFunc: func(name string, opts ...instrument.Option) (syncint64.Counter, error) { + errorFakeMeter := &fake.IMeterMock{ + Int64CounterFunc: func(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) { return nil, errors.New("some error") }, - HistogramFunc: func(name string, opts ...instrument.Option) (syncint64.Histogram, error) { + Int64HistogramFunc: func(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { return nil, errors.New("some error") }, - } - fakeSyncFloatTracerProvider := &fakesync.ITracerProviderSyncFloat64Mock{ - CounterFunc: func(name string, opts ...instrument.Option) (syncfloat64.Counter, error) { + Float64CounterFunc: func(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) { return nil, errors.New("some error") }, - HistogramFunc: func(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) { + Float64HistogramFunc: func(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) { return nil, errors.New("some error") }, - } - - errorFakeMeter := &fake.IMeterMock{ - SyncInt64Func: func() syncint64.InstrumentProvider { - return fakeSyncIntTracerProvider - }, - SyncFloat64Func: func() syncfloat64.InstrumentProvider { - return fakeSyncFloatTracerProvider - }, - RegisterCallbackFunc: func(insts []instrument.Asynchronous, function func(context.Context)) error { - return errors.New("some error") + RegisterCallbackFunc: func(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) { + return nil, errors.New("some error") }, } diff --git a/operator/controllers/common/test_utils.go b/operator/controllers/common/test_utils.go index 1ef07717be..6ec5dfd62c 100644 --- a/operator/controllers/common/test_utils.go +++ b/operator/controllers/common/test_utils.go @@ -6,9 +6,8 @@ import ( lfcv1alpha3 "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3" apicommon "github.com/keptn/lifecycle-toolkit/operator/apis/lifecycle/v1alpha3/common" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/unit" - "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/metric" + sdkmetric "go.opentelemetry.io/otel/sdk/metric" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -66,12 +65,12 @@ func AddAppVersion(c client.Client, namespace string, appName string, version st } func InitAppMeters() apicommon.KeptnMeters { - provider := metric.NewMeterProvider() + provider := sdkmetric.NewMeterProvider() meter := provider.Meter("keptn/task") - appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) - appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit("s")) - deploymentCount, _ := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) - deploymentDuration, _ := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit(unit.Unit("s"))) + appCount, _ := meter.Int64Counter("keptn.app.count", metric.WithDescription("a simple counter for Keptn Apps")) + appDuration, _ := meter.Float64Histogram("keptn.app.duration", metric.WithDescription("a histogram of duration for Keptn Apps"), metric.WithUnit("s")) + deploymentCount, _ := meter.Int64Counter("keptn.deployment.count", metric.WithDescription("a simple counter for Keptn Deployments")) + deploymentDuration, _ := meter.Float64Histogram("keptn.deployment.duration", metric.WithDescription("a histogram of duration for Keptn Deployments"), metric.WithUnit("s")) meters := apicommon.KeptnMeters{ AppCount: appCount, diff --git a/operator/controllers/lifecycle/interfaces/fake/activemetricsobject_mock.go b/operator/controllers/lifecycle/interfaces/fake/activemetricsobject_mock.go index 13e60982a7..789e44d8c7 100644 --- a/operator/controllers/lifecycle/interfaces/fake/activemetricsobject_mock.go +++ b/operator/controllers/lifecycle/interfaces/fake/activemetricsobject_mock.go @@ -4,16 +4,15 @@ package fake import ( - "sync" - "go.opentelemetry.io/otel/attribute" + "sync" ) -// ActiveMetricsObjectMock is a mock implementation of common.ActiveMetricsObject. +// ActiveMetricsObjectMock is a mock implementation of interfaces.ActiveMetricsObject. // // func TestSomethingThatUsesActiveMetricsObject(t *testing.T) { // -// // make and configure a mocked common.ActiveMetricsObject +// // make and configure a mocked interfaces.ActiveMetricsObject // mockedActiveMetricsObject := &ActiveMetricsObjectMock{ // GetActiveMetricsAttributesFunc: func() []attribute.KeyValue { // panic("mock out the GetActiveMetricsAttributes method") @@ -23,7 +22,7 @@ import ( // }, // } // -// // use mockedActiveMetricsObject in code that requires common.ActiveMetricsObject +// // use mockedActiveMetricsObject in code that requires interfaces.ActiveMetricsObject // // and then make assertions. // // } diff --git a/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_float_mock.go b/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_float_mock.go deleted file mode 100644 index c9b589c760..0000000000 --- a/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_float_mock.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package fake - -import ( - "sync" - - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" -) - -// ITracerProviderAsyncFloat64Mock is a mock implementation of interfaces.ITracerProviderAsyncFloat64. -// -// func TestSomethingThatUsesITracerProviderAsyncFloat64(t *testing.T) { -// -// // make and configure a mocked interfaces.ITracerProviderAsyncFloat64 -// mockedITracerProviderAsyncFloat64 := &ITracerProviderAsyncFloat64Mock{ -// CounterFunc: func(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) { -// panic("mock out the Counter method") -// }, -// GaugeFunc: func(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) { -// panic("mock out the Gauge method") -// }, -// UpDownCounterFunc: func(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) { -// panic("mock out the UpDownCounter method") -// }, -// } -// -// // use mockedITracerProviderAsyncFloat64 in code that requires interfaces.ITracerProviderAsyncFloat64 -// // and then make assertions. -// -// } -type ITracerProviderAsyncFloat64Mock struct { - // CounterFunc mocks the Counter method. - CounterFunc func(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) - - // GaugeFunc mocks the Gauge method. - GaugeFunc func(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) - - // UpDownCounterFunc mocks the UpDownCounter method. - UpDownCounterFunc func(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) - - // calls tracks calls to the methods. - calls struct { - // Counter holds details about calls to the Counter method. - Counter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // Gauge holds details about calls to the Gauge method. - Gauge []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // UpDownCounter holds details about calls to the UpDownCounter method. - UpDownCounter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - } - lockCounter sync.RWMutex - lockGauge sync.RWMutex - lockUpDownCounter sync.RWMutex -} - -// Counter calls CounterFunc. -func (mock *ITracerProviderAsyncFloat64Mock) Counter(name string, opts ...instrument.Option) (asyncfloat64.Counter, error) { - if mock.CounterFunc == nil { - panic("ITracerProviderAsyncFloat64Mock.CounterFunc: method is nil but ITracerProviderAsyncFloat64.Counter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockCounter.Lock() - mock.calls.Counter = append(mock.calls.Counter, callInfo) - mock.lockCounter.Unlock() - return mock.CounterFunc(name, opts...) -} - -// CounterCalls gets all the calls that were made to Counter. -// Check the length with: -// -// len(mockedITracerProviderAsyncFloat64.CounterCalls()) -func (mock *ITracerProviderAsyncFloat64Mock) CounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockCounter.RLock() - calls = mock.calls.Counter - mock.lockCounter.RUnlock() - return calls -} - -// Gauge calls GaugeFunc. -func (mock *ITracerProviderAsyncFloat64Mock) Gauge(name string, opts ...instrument.Option) (asyncfloat64.Gauge, error) { - if mock.GaugeFunc == nil { - panic("ITracerProviderAsyncFloat64Mock.GaugeFunc: method is nil but ITracerProviderAsyncFloat64.Gauge was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockGauge.Lock() - mock.calls.Gauge = append(mock.calls.Gauge, callInfo) - mock.lockGauge.Unlock() - return mock.GaugeFunc(name, opts...) -} - -// GaugeCalls gets all the calls that were made to Gauge. -// Check the length with: -// -// len(mockedITracerProviderAsyncFloat64.GaugeCalls()) -func (mock *ITracerProviderAsyncFloat64Mock) GaugeCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockGauge.RLock() - calls = mock.calls.Gauge - mock.lockGauge.RUnlock() - return calls -} - -// UpDownCounter calls UpDownCounterFunc. -func (mock *ITracerProviderAsyncFloat64Mock) UpDownCounter(name string, opts ...instrument.Option) (asyncfloat64.UpDownCounter, error) { - if mock.UpDownCounterFunc == nil { - panic("ITracerProviderAsyncFloat64Mock.UpDownCounterFunc: method is nil but ITracerProviderAsyncFloat64.UpDownCounter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockUpDownCounter.Lock() - mock.calls.UpDownCounter = append(mock.calls.UpDownCounter, callInfo) - mock.lockUpDownCounter.Unlock() - return mock.UpDownCounterFunc(name, opts...) -} - -// UpDownCounterCalls gets all the calls that were made to UpDownCounter. -// Check the length with: -// -// len(mockedITracerProviderAsyncFloat64.UpDownCounterCalls()) -func (mock *ITracerProviderAsyncFloat64Mock) UpDownCounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockUpDownCounter.RLock() - calls = mock.calls.UpDownCounter - mock.lockUpDownCounter.RUnlock() - return calls -} diff --git a/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_int_mock.go b/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_int_mock.go deleted file mode 100644 index 18c03e7259..0000000000 --- a/operator/controllers/lifecycle/interfaces/fake/async/tracer_provider_int_mock.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package fake - -import ( - "sync" - - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" -) - -// ITracerProviderAsyncInt64Mock is a mock implementation of interfaces.ITracerProviderAsyncInt64. -// -// func TestSomethingThatUsesITracerProviderAsyncInt64(t *testing.T) { -// -// // make and configure a mocked interfaces.ITracerProviderAsyncInt64 -// mockedITracerProviderAsyncInt64 := &ITracerProviderAsyncInt64Mock{ -// CounterFunc: func(name string, opts ...instrument.Option) (asyncint64.Counter, error) { -// panic("mock out the Counter method") -// }, -// GaugeFunc: func(name string, opts ...instrument.Option) (asyncint64.Gauge, error) { -// panic("mock out the Gauge method") -// }, -// UpDownCounterFunc: func(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) { -// panic("mock out the UpDownCounter method") -// }, -// } -// -// // use mockedITracerProviderAsyncInt64 in code that requires interfaces.ITracerProviderAsyncInt64 -// // and then make assertions. -// -// } -type ITracerProviderAsyncInt64Mock struct { - // CounterFunc mocks the Counter method. - CounterFunc func(name string, opts ...instrument.Option) (asyncint64.Counter, error) - - // GaugeFunc mocks the Gauge method. - GaugeFunc func(name string, opts ...instrument.Option) (asyncint64.Gauge, error) - - // UpDownCounterFunc mocks the UpDownCounter method. - UpDownCounterFunc func(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) - - // calls tracks calls to the methods. - calls struct { - // Counter holds details about calls to the Counter method. - Counter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // Gauge holds details about calls to the Gauge method. - Gauge []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // UpDownCounter holds details about calls to the UpDownCounter method. - UpDownCounter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - } - lockCounter sync.RWMutex - lockGauge sync.RWMutex - lockUpDownCounter sync.RWMutex -} - -// Counter calls CounterFunc. -func (mock *ITracerProviderAsyncInt64Mock) Counter(name string, opts ...instrument.Option) (asyncint64.Counter, error) { - if mock.CounterFunc == nil { - panic("ITracerProviderAsyncInt64Mock.CounterFunc: method is nil but ITracerProviderAsyncInt64.Counter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockCounter.Lock() - mock.calls.Counter = append(mock.calls.Counter, callInfo) - mock.lockCounter.Unlock() - return mock.CounterFunc(name, opts...) -} - -// CounterCalls gets all the calls that were made to Counter. -// Check the length with: -// -// len(mockedITracerProviderAsyncInt64.CounterCalls()) -func (mock *ITracerProviderAsyncInt64Mock) CounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockCounter.RLock() - calls = mock.calls.Counter - mock.lockCounter.RUnlock() - return calls -} - -// Gauge calls GaugeFunc. -func (mock *ITracerProviderAsyncInt64Mock) Gauge(name string, opts ...instrument.Option) (asyncint64.Gauge, error) { - if mock.GaugeFunc == nil { - panic("ITracerProviderAsyncInt64Mock.GaugeFunc: method is nil but ITracerProviderAsyncInt64.Gauge was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockGauge.Lock() - mock.calls.Gauge = append(mock.calls.Gauge, callInfo) - mock.lockGauge.Unlock() - return mock.GaugeFunc(name, opts...) -} - -// GaugeCalls gets all the calls that were made to Gauge. -// Check the length with: -// -// len(mockedITracerProviderAsyncInt64.GaugeCalls()) -func (mock *ITracerProviderAsyncInt64Mock) GaugeCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockGauge.RLock() - calls = mock.calls.Gauge - mock.lockGauge.RUnlock() - return calls -} - -// UpDownCounter calls UpDownCounterFunc. -func (mock *ITracerProviderAsyncInt64Mock) UpDownCounter(name string, opts ...instrument.Option) (asyncint64.UpDownCounter, error) { - if mock.UpDownCounterFunc == nil { - panic("ITracerProviderAsyncInt64Mock.UpDownCounterFunc: method is nil but ITracerProviderAsyncInt64.UpDownCounter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockUpDownCounter.Lock() - mock.calls.UpDownCounter = append(mock.calls.UpDownCounter, callInfo) - mock.lockUpDownCounter.Unlock() - return mock.UpDownCounterFunc(name, opts...) -} - -// UpDownCounterCalls gets all the calls that were made to UpDownCounter. -// Check the length with: -// -// len(mockedITracerProviderAsyncInt64.UpDownCounterCalls()) -func (mock *ITracerProviderAsyncInt64Mock) UpDownCounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockUpDownCounter.RLock() - calls = mock.calls.UpDownCounter - mock.lockUpDownCounter.RUnlock() - return calls -} diff --git a/operator/controllers/lifecycle/interfaces/fake/meter_mock.go b/operator/controllers/lifecycle/interfaces/fake/meter_mock.go index 9569b04e66..939eb33a1d 100644 --- a/operator/controllers/lifecycle/interfaces/fake/meter_mock.go +++ b/operator/controllers/lifecycle/interfaces/fake/meter_mock.go @@ -4,14 +4,8 @@ package fake import ( - "context" + "go.opentelemetry.io/otel/metric" "sync" - - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) // IMeterMock is a mock implementation of interfaces.IMeter. @@ -20,20 +14,26 @@ import ( // // // make and configure a mocked interfaces.IMeter // mockedIMeter := &IMeterMock{ -// AsyncFloat64Func: func() asyncfloat64.InstrumentProvider { -// panic("mock out the AsyncFloat64 method") +// Float64CounterFunc: func(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) { +// panic("mock out the Float64Counter method") // }, -// AsyncInt64Func: func() asyncint64.InstrumentProvider { -// panic("mock out the AsyncInt64 method") +// Float64HistogramFunc: func(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) { +// panic("mock out the Float64Histogram method") // }, -// RegisterCallbackFunc: func(insts []instrument.Asynchronous, function func(context.Context)) error { -// panic("mock out the RegisterCallback method") +// Float64ObservableGaugeFunc: func(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) { +// panic("mock out the Float64ObservableGauge method") +// }, +// Int64CounterFunc: func(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) { +// panic("mock out the Int64Counter method") // }, -// SyncFloat64Func: func() syncfloat64.InstrumentProvider { -// panic("mock out the SyncFloat64 method") +// Int64HistogramFunc: func(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { +// panic("mock out the Int64Histogram method") // }, -// SyncInt64Func: func() syncint64.InstrumentProvider { -// panic("mock out the SyncInt64 method") +// Int64ObservableGaugeFunc: func(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) { +// panic("mock out the Int64ObservableGauge method") +// }, +// RegisterCallbackFunc: func(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) { +// panic("mock out the RegisterCallback method") // }, // } // @@ -42,190 +42,336 @@ import ( // // } type IMeterMock struct { - // AsyncFloat64Func mocks the AsyncFloat64 method. - AsyncFloat64Func func() asyncfloat64.InstrumentProvider + // Float64CounterFunc mocks the Float64Counter method. + Float64CounterFunc func(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) - // AsyncInt64Func mocks the AsyncInt64 method. - AsyncInt64Func func() asyncint64.InstrumentProvider + // Float64HistogramFunc mocks the Float64Histogram method. + Float64HistogramFunc func(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) - // RegisterCallbackFunc mocks the RegisterCallback method. - RegisterCallbackFunc func(insts []instrument.Asynchronous, function func(context.Context)) error + // Float64ObservableGaugeFunc mocks the Float64ObservableGauge method. + Float64ObservableGaugeFunc func(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) + + // Int64CounterFunc mocks the Int64Counter method. + Int64CounterFunc func(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) - // SyncFloat64Func mocks the SyncFloat64 method. - SyncFloat64Func func() syncfloat64.InstrumentProvider + // Int64HistogramFunc mocks the Int64Histogram method. + Int64HistogramFunc func(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) - // SyncInt64Func mocks the SyncInt64 method. - SyncInt64Func func() syncint64.InstrumentProvider + // Int64ObservableGaugeFunc mocks the Int64ObservableGauge method. + Int64ObservableGaugeFunc func(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) + + // RegisterCallbackFunc mocks the RegisterCallback method. + RegisterCallbackFunc func(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) // calls tracks calls to the methods. calls struct { - // AsyncFloat64 holds details about calls to the AsyncFloat64 method. - AsyncFloat64 []struct { + // Float64Counter holds details about calls to the Float64Counter method. + Float64Counter []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Float64CounterOption } - // AsyncInt64 holds details about calls to the AsyncInt64 method. - AsyncInt64 []struct { + // Float64Histogram holds details about calls to the Float64Histogram method. + Float64Histogram []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Float64HistogramOption } - // RegisterCallback holds details about calls to the RegisterCallback method. - RegisterCallback []struct { - // Insts is the insts argument value. - Insts []instrument.Asynchronous - // Function is the function argument value. - Function func(context.Context) + // Float64ObservableGauge holds details about calls to the Float64ObservableGauge method. + Float64ObservableGauge []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Float64ObservableGaugeOption + } + // Int64Counter holds details about calls to the Int64Counter method. + Int64Counter []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Int64CounterOption + } + // Int64Histogram holds details about calls to the Int64Histogram method. + Int64Histogram []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Int64HistogramOption } - // SyncFloat64 holds details about calls to the SyncFloat64 method. - SyncFloat64 []struct { + // Int64ObservableGauge holds details about calls to the Int64ObservableGauge method. + Int64ObservableGauge []struct { + // Name is the name argument value. + Name string + // Options is the options argument value. + Options []metric.Int64ObservableGaugeOption } - // SyncInt64 holds details about calls to the SyncInt64 method. - SyncInt64 []struct { + // RegisterCallback holds details about calls to the RegisterCallback method. + RegisterCallback []struct { + // F is the f argument value. + F metric.Callback + // Instruments is the instruments argument value. + Instruments []metric.Observable } } - lockAsyncFloat64 sync.RWMutex - lockAsyncInt64 sync.RWMutex - lockRegisterCallback sync.RWMutex - lockSyncFloat64 sync.RWMutex - lockSyncInt64 sync.RWMutex + lockFloat64Counter sync.RWMutex + lockFloat64Histogram sync.RWMutex + lockFloat64ObservableGauge sync.RWMutex + lockInt64Counter sync.RWMutex + lockInt64Histogram sync.RWMutex + lockInt64ObservableGauge sync.RWMutex + lockRegisterCallback sync.RWMutex } -// AsyncFloat64 calls AsyncFloat64Func. -func (mock *IMeterMock) AsyncFloat64() asyncfloat64.InstrumentProvider { - if mock.AsyncFloat64Func == nil { - panic("IMeterMock.AsyncFloat64Func: method is nil but IMeter.AsyncFloat64 was just called") +// Float64Counter calls Float64CounterFunc. +func (mock *IMeterMock) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) { + if mock.Float64CounterFunc == nil { + panic("IMeterMock.Float64CounterFunc: method is nil but IMeter.Float64Counter was just called") } callInfo := struct { - }{} - mock.lockAsyncFloat64.Lock() - mock.calls.AsyncFloat64 = append(mock.calls.AsyncFloat64, callInfo) - mock.lockAsyncFloat64.Unlock() - return mock.AsyncFloat64Func() + Name string + Options []metric.Float64CounterOption + }{ + Name: name, + Options: options, + } + mock.lockFloat64Counter.Lock() + mock.calls.Float64Counter = append(mock.calls.Float64Counter, callInfo) + mock.lockFloat64Counter.Unlock() + return mock.Float64CounterFunc(name, options...) } -// AsyncFloat64Calls gets all the calls that were made to AsyncFloat64. +// Float64CounterCalls gets all the calls that were made to Float64Counter. // Check the length with: // -// len(mockedIMeter.AsyncFloat64Calls()) -func (mock *IMeterMock) AsyncFloat64Calls() []struct { +// len(mockedIMeter.Float64CounterCalls()) +func (mock *IMeterMock) Float64CounterCalls() []struct { + Name string + Options []metric.Float64CounterOption } { var calls []struct { + Name string + Options []metric.Float64CounterOption } - mock.lockAsyncFloat64.RLock() - calls = mock.calls.AsyncFloat64 - mock.lockAsyncFloat64.RUnlock() + mock.lockFloat64Counter.RLock() + calls = mock.calls.Float64Counter + mock.lockFloat64Counter.RUnlock() return calls } -// AsyncInt64 calls AsyncInt64Func. -func (mock *IMeterMock) AsyncInt64() asyncint64.InstrumentProvider { - if mock.AsyncInt64Func == nil { - panic("IMeterMock.AsyncInt64Func: method is nil but IMeter.AsyncInt64 was just called") +// Float64Histogram calls Float64HistogramFunc. +func (mock *IMeterMock) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) { + if mock.Float64HistogramFunc == nil { + panic("IMeterMock.Float64HistogramFunc: method is nil but IMeter.Float64Histogram was just called") } callInfo := struct { - }{} - mock.lockAsyncInt64.Lock() - mock.calls.AsyncInt64 = append(mock.calls.AsyncInt64, callInfo) - mock.lockAsyncInt64.Unlock() - return mock.AsyncInt64Func() + Name string + Options []metric.Float64HistogramOption + }{ + Name: name, + Options: options, + } + mock.lockFloat64Histogram.Lock() + mock.calls.Float64Histogram = append(mock.calls.Float64Histogram, callInfo) + mock.lockFloat64Histogram.Unlock() + return mock.Float64HistogramFunc(name, options...) } -// AsyncInt64Calls gets all the calls that were made to AsyncInt64. +// Float64HistogramCalls gets all the calls that were made to Float64Histogram. // Check the length with: // -// len(mockedIMeter.AsyncInt64Calls()) -func (mock *IMeterMock) AsyncInt64Calls() []struct { +// len(mockedIMeter.Float64HistogramCalls()) +func (mock *IMeterMock) Float64HistogramCalls() []struct { + Name string + Options []metric.Float64HistogramOption } { var calls []struct { + Name string + Options []metric.Float64HistogramOption } - mock.lockAsyncInt64.RLock() - calls = mock.calls.AsyncInt64 - mock.lockAsyncInt64.RUnlock() + mock.lockFloat64Histogram.RLock() + calls = mock.calls.Float64Histogram + mock.lockFloat64Histogram.RUnlock() return calls } -// RegisterCallback calls RegisterCallbackFunc. -func (mock *IMeterMock) RegisterCallback(insts []instrument.Asynchronous, function func(context.Context)) error { - if mock.RegisterCallbackFunc == nil { - panic("IMeterMock.RegisterCallbackFunc: method is nil but IMeter.RegisterCallback was just called") +// Float64ObservableGauge calls Float64ObservableGaugeFunc. +func (mock *IMeterMock) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) { + if mock.Float64ObservableGaugeFunc == nil { + panic("IMeterMock.Float64ObservableGaugeFunc: method is nil but IMeter.Float64ObservableGauge was just called") } callInfo := struct { - Insts []instrument.Asynchronous - Function func(context.Context) + Name string + Options []metric.Float64ObservableGaugeOption }{ - Insts: insts, - Function: function, + Name: name, + Options: options, } - mock.lockRegisterCallback.Lock() - mock.calls.RegisterCallback = append(mock.calls.RegisterCallback, callInfo) - mock.lockRegisterCallback.Unlock() - return mock.RegisterCallbackFunc(insts, function) + mock.lockFloat64ObservableGauge.Lock() + mock.calls.Float64ObservableGauge = append(mock.calls.Float64ObservableGauge, callInfo) + mock.lockFloat64ObservableGauge.Unlock() + return mock.Float64ObservableGaugeFunc(name, options...) } -// RegisterCallbackCalls gets all the calls that were made to RegisterCallback. +// Float64ObservableGaugeCalls gets all the calls that were made to Float64ObservableGauge. // Check the length with: // -// len(mockedIMeter.RegisterCallbackCalls()) -func (mock *IMeterMock) RegisterCallbackCalls() []struct { - Insts []instrument.Asynchronous - Function func(context.Context) +// len(mockedIMeter.Float64ObservableGaugeCalls()) +func (mock *IMeterMock) Float64ObservableGaugeCalls() []struct { + Name string + Options []metric.Float64ObservableGaugeOption } { var calls []struct { - Insts []instrument.Asynchronous - Function func(context.Context) + Name string + Options []metric.Float64ObservableGaugeOption } - mock.lockRegisterCallback.RLock() - calls = mock.calls.RegisterCallback - mock.lockRegisterCallback.RUnlock() + mock.lockFloat64ObservableGauge.RLock() + calls = mock.calls.Float64ObservableGauge + mock.lockFloat64ObservableGauge.RUnlock() return calls } -// SyncFloat64 calls SyncFloat64Func. -func (mock *IMeterMock) SyncFloat64() syncfloat64.InstrumentProvider { - if mock.SyncFloat64Func == nil { - panic("IMeterMock.SyncFloat64Func: method is nil but IMeter.SyncFloat64 was just called") +// Int64Counter calls Int64CounterFunc. +func (mock *IMeterMock) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) { + if mock.Int64CounterFunc == nil { + panic("IMeterMock.Int64CounterFunc: method is nil but IMeter.Int64Counter was just called") } callInfo := struct { - }{} - mock.lockSyncFloat64.Lock() - mock.calls.SyncFloat64 = append(mock.calls.SyncFloat64, callInfo) - mock.lockSyncFloat64.Unlock() - return mock.SyncFloat64Func() + Name string + Options []metric.Int64CounterOption + }{ + Name: name, + Options: options, + } + mock.lockInt64Counter.Lock() + mock.calls.Int64Counter = append(mock.calls.Int64Counter, callInfo) + mock.lockInt64Counter.Unlock() + return mock.Int64CounterFunc(name, options...) } -// SyncFloat64Calls gets all the calls that were made to SyncFloat64. +// Int64CounterCalls gets all the calls that were made to Int64Counter. // Check the length with: // -// len(mockedIMeter.SyncFloat64Calls()) -func (mock *IMeterMock) SyncFloat64Calls() []struct { +// len(mockedIMeter.Int64CounterCalls()) +func (mock *IMeterMock) Int64CounterCalls() []struct { + Name string + Options []metric.Int64CounterOption } { var calls []struct { + Name string + Options []metric.Int64CounterOption } - mock.lockSyncFloat64.RLock() - calls = mock.calls.SyncFloat64 - mock.lockSyncFloat64.RUnlock() + mock.lockInt64Counter.RLock() + calls = mock.calls.Int64Counter + mock.lockInt64Counter.RUnlock() return calls } -// SyncInt64 calls SyncInt64Func. -func (mock *IMeterMock) SyncInt64() syncint64.InstrumentProvider { - if mock.SyncInt64Func == nil { - panic("IMeterMock.SyncInt64Func: method is nil but IMeter.SyncInt64 was just called") +// Int64Histogram calls Int64HistogramFunc. +func (mock *IMeterMock) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) { + if mock.Int64HistogramFunc == nil { + panic("IMeterMock.Int64HistogramFunc: method is nil but IMeter.Int64Histogram was just called") } callInfo := struct { - }{} - mock.lockSyncInt64.Lock() - mock.calls.SyncInt64 = append(mock.calls.SyncInt64, callInfo) - mock.lockSyncInt64.Unlock() - return mock.SyncInt64Func() + Name string + Options []metric.Int64HistogramOption + }{ + Name: name, + Options: options, + } + mock.lockInt64Histogram.Lock() + mock.calls.Int64Histogram = append(mock.calls.Int64Histogram, callInfo) + mock.lockInt64Histogram.Unlock() + return mock.Int64HistogramFunc(name, options...) } -// SyncInt64Calls gets all the calls that were made to SyncInt64. +// Int64HistogramCalls gets all the calls that were made to Int64Histogram. // Check the length with: // -// len(mockedIMeter.SyncInt64Calls()) -func (mock *IMeterMock) SyncInt64Calls() []struct { +// len(mockedIMeter.Int64HistogramCalls()) +func (mock *IMeterMock) Int64HistogramCalls() []struct { + Name string + Options []metric.Int64HistogramOption } { var calls []struct { + Name string + Options []metric.Int64HistogramOption } - mock.lockSyncInt64.RLock() - calls = mock.calls.SyncInt64 - mock.lockSyncInt64.RUnlock() + mock.lockInt64Histogram.RLock() + calls = mock.calls.Int64Histogram + mock.lockInt64Histogram.RUnlock() + return calls +} + +// Int64ObservableGauge calls Int64ObservableGaugeFunc. +func (mock *IMeterMock) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) { + if mock.Int64ObservableGaugeFunc == nil { + panic("IMeterMock.Int64ObservableGaugeFunc: method is nil but IMeter.Int64ObservableGauge was just called") + } + callInfo := struct { + Name string + Options []metric.Int64ObservableGaugeOption + }{ + Name: name, + Options: options, + } + mock.lockInt64ObservableGauge.Lock() + mock.calls.Int64ObservableGauge = append(mock.calls.Int64ObservableGauge, callInfo) + mock.lockInt64ObservableGauge.Unlock() + return mock.Int64ObservableGaugeFunc(name, options...) +} + +// Int64ObservableGaugeCalls gets all the calls that were made to Int64ObservableGauge. +// Check the length with: +// +// len(mockedIMeter.Int64ObservableGaugeCalls()) +func (mock *IMeterMock) Int64ObservableGaugeCalls() []struct { + Name string + Options []metric.Int64ObservableGaugeOption +} { + var calls []struct { + Name string + Options []metric.Int64ObservableGaugeOption + } + mock.lockInt64ObservableGauge.RLock() + calls = mock.calls.Int64ObservableGauge + mock.lockInt64ObservableGauge.RUnlock() + return calls +} + +// RegisterCallback calls RegisterCallbackFunc. +func (mock *IMeterMock) RegisterCallback(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) { + if mock.RegisterCallbackFunc == nil { + panic("IMeterMock.RegisterCallbackFunc: method is nil but IMeter.RegisterCallback was just called") + } + callInfo := struct { + F metric.Callback + Instruments []metric.Observable + }{ + F: f, + Instruments: instruments, + } + mock.lockRegisterCallback.Lock() + mock.calls.RegisterCallback = append(mock.calls.RegisterCallback, callInfo) + mock.lockRegisterCallback.Unlock() + return mock.RegisterCallbackFunc(f, instruments...) +} + +// RegisterCallbackCalls gets all the calls that were made to RegisterCallback. +// Check the length with: +// +// len(mockedIMeter.RegisterCallbackCalls()) +func (mock *IMeterMock) RegisterCallbackCalls() []struct { + F metric.Callback + Instruments []metric.Observable +} { + var calls []struct { + F metric.Callback + Instruments []metric.Observable + } + mock.lockRegisterCallback.RLock() + calls = mock.calls.RegisterCallback + mock.lockRegisterCallback.RUnlock() return calls } diff --git a/operator/controllers/lifecycle/interfaces/fake/spanitem_mock.go b/operator/controllers/lifecycle/interfaces/fake/spanitem_mock.go index 0b61718c96..bbff62ef33 100644 --- a/operator/controllers/lifecycle/interfaces/fake/spanitem_mock.go +++ b/operator/controllers/lifecycle/interfaces/fake/spanitem_mock.go @@ -4,17 +4,16 @@ package fake import ( - "sync" - "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" + "sync" ) -// SpanItemMock is a mock implementation of common.SpanItem. +// SpanItemMock is a mock implementation of interfaces.SpanItem. // // func TestSomethingThatUsesSpanItem(t *testing.T) { // -// // make and configure a mocked common.SpanItem +// // make and configure a mocked interfaces.SpanItem // mockedSpanItem := &SpanItemMock{ // GetSpanKeyFunc: func(phase string) string { // panic("mock out the GetSpanKey method") @@ -30,7 +29,7 @@ import ( // }, // } // -// // use mockedSpanItem in code that requires common.SpanItem +// // use mockedSpanItem in code that requires interfaces.SpanItem // // and then make assertions. // // } diff --git a/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_float_mock.go b/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_float_mock.go deleted file mode 100644 index c3ecb2c0ea..0000000000 --- a/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_float_mock.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package fake - -import ( - "sync" - - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" -) - -// ITracerProviderSyncFloat64Mock is a mock implementation of interfaces.ITracerProviderSyncFloat64. -// -// func TestSomethingThatUsesITracerProviderSyncFloat64(t *testing.T) { -// -// // make and configure a mocked interfaces.ITracerProviderSyncFloat64 -// mockedITracerProviderSyncFloat64 := &ITracerProviderSyncFloat64Mock{ -// CounterFunc: func(name string, opts ...instrument.Option) (syncfloat64.Counter, error) { -// panic("mock out the Counter method") -// }, -// HistogramFunc: func(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) { -// panic("mock out the Histogram method") -// }, -// UpDownCounterFunc: func(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) { -// panic("mock out the UpDownCounter method") -// }, -// } -// -// // use mockedITracerProviderSyncFloat64 in code that requires interfaces.ITracerProviderSyncFloat64 -// // and then make assertions. -// -// } -type ITracerProviderSyncFloat64Mock struct { - // CounterFunc mocks the Counter method. - CounterFunc func(name string, opts ...instrument.Option) (syncfloat64.Counter, error) - - // HistogramFunc mocks the Histogram method. - HistogramFunc func(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) - - // UpDownCounterFunc mocks the UpDownCounter method. - UpDownCounterFunc func(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) - - // calls tracks calls to the methods. - calls struct { - // Counter holds details about calls to the Counter method. - Counter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // Histogram holds details about calls to the Histogram method. - Histogram []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // UpDownCounter holds details about calls to the UpDownCounter method. - UpDownCounter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - } - lockCounter sync.RWMutex - lockHistogram sync.RWMutex - lockUpDownCounter sync.RWMutex -} - -// Counter calls CounterFunc. -func (mock *ITracerProviderSyncFloat64Mock) Counter(name string, opts ...instrument.Option) (syncfloat64.Counter, error) { - if mock.CounterFunc == nil { - panic("ITracerProviderSyncFloat64Mock.CounterFunc: method is nil but ITracerProviderSyncFloat64.Counter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockCounter.Lock() - mock.calls.Counter = append(mock.calls.Counter, callInfo) - mock.lockCounter.Unlock() - return mock.CounterFunc(name, opts...) -} - -// CounterCalls gets all the calls that were made to Counter. -// Check the length with: -// -// len(mockedITracerProviderSyncFloat64.CounterCalls()) -func (mock *ITracerProviderSyncFloat64Mock) CounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockCounter.RLock() - calls = mock.calls.Counter - mock.lockCounter.RUnlock() - return calls -} - -// Histogram calls HistogramFunc. -func (mock *ITracerProviderSyncFloat64Mock) Histogram(name string, opts ...instrument.Option) (syncfloat64.Histogram, error) { - if mock.HistogramFunc == nil { - panic("ITracerProviderSyncFloat64Mock.HistogramFunc: method is nil but ITracerProviderSyncFloat64.Histogram was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockHistogram.Lock() - mock.calls.Histogram = append(mock.calls.Histogram, callInfo) - mock.lockHistogram.Unlock() - return mock.HistogramFunc(name, opts...) -} - -// HistogramCalls gets all the calls that were made to Histogram. -// Check the length with: -// -// len(mockedITracerProviderSyncFloat64.HistogramCalls()) -func (mock *ITracerProviderSyncFloat64Mock) HistogramCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockHistogram.RLock() - calls = mock.calls.Histogram - mock.lockHistogram.RUnlock() - return calls -} - -// UpDownCounter calls UpDownCounterFunc. -func (mock *ITracerProviderSyncFloat64Mock) UpDownCounter(name string, opts ...instrument.Option) (syncfloat64.UpDownCounter, error) { - if mock.UpDownCounterFunc == nil { - panic("ITracerProviderSyncFloat64Mock.UpDownCounterFunc: method is nil but ITracerProviderSyncFloat64.UpDownCounter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockUpDownCounter.Lock() - mock.calls.UpDownCounter = append(mock.calls.UpDownCounter, callInfo) - mock.lockUpDownCounter.Unlock() - return mock.UpDownCounterFunc(name, opts...) -} - -// UpDownCounterCalls gets all the calls that were made to UpDownCounter. -// Check the length with: -// -// len(mockedITracerProviderSyncFloat64.UpDownCounterCalls()) -func (mock *ITracerProviderSyncFloat64Mock) UpDownCounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockUpDownCounter.RLock() - calls = mock.calls.UpDownCounter - mock.lockUpDownCounter.RUnlock() - return calls -} diff --git a/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_int_mock.go b/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_int_mock.go deleted file mode 100644 index c24380afa8..0000000000 --- a/operator/controllers/lifecycle/interfaces/fake/sync/tracer_provider_int_mock.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by moq; DO NOT EDIT. -// github.com/matryer/moq - -package fake - -import ( - "sync" - - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/instrument/syncint64" -) - -// ITracerProviderSyncInt64Mock is a mock implementation of interfaces.ITracerProviderSyncInt64. -// -// func TestSomethingThatUsesITracerProviderSyncInt64(t *testing.T) { -// -// // make and configure a mocked interfaces.ITracerProviderSyncInt64 -// mockedITracerProviderSyncInt64 := &ITracerProviderSyncInt64Mock{ -// CounterFunc: func(name string, opts ...instrument.Option) (syncint64.Counter, error) { -// panic("mock out the Counter method") -// }, -// HistogramFunc: func(name string, opts ...instrument.Option) (syncint64.Histogram, error) { -// panic("mock out the Histogram method") -// }, -// UpDownCounterFunc: func(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) { -// panic("mock out the UpDownCounter method") -// }, -// } -// -// // use mockedITracerProviderSyncInt64 in code that requires interfaces.ITracerProviderSyncInt64 -// // and then make assertions. -// -// } -type ITracerProviderSyncInt64Mock struct { - // CounterFunc mocks the Counter method. - CounterFunc func(name string, opts ...instrument.Option) (syncint64.Counter, error) - - // HistogramFunc mocks the Histogram method. - HistogramFunc func(name string, opts ...instrument.Option) (syncint64.Histogram, error) - - // UpDownCounterFunc mocks the UpDownCounter method. - UpDownCounterFunc func(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) - - // calls tracks calls to the methods. - calls struct { - // Counter holds details about calls to the Counter method. - Counter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // Histogram holds details about calls to the Histogram method. - Histogram []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - // UpDownCounter holds details about calls to the UpDownCounter method. - UpDownCounter []struct { - // Name is the name argument value. - Name string - // Opts is the opts argument value. - Opts []instrument.Option - } - } - lockCounter sync.RWMutex - lockHistogram sync.RWMutex - lockUpDownCounter sync.RWMutex -} - -// Counter calls CounterFunc. -func (mock *ITracerProviderSyncInt64Mock) Counter(name string, opts ...instrument.Option) (syncint64.Counter, error) { - if mock.CounterFunc == nil { - panic("ITracerProviderSyncInt64Mock.CounterFunc: method is nil but ITracerProviderSyncInt64.Counter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockCounter.Lock() - mock.calls.Counter = append(mock.calls.Counter, callInfo) - mock.lockCounter.Unlock() - return mock.CounterFunc(name, opts...) -} - -// CounterCalls gets all the calls that were made to Counter. -// Check the length with: -// -// len(mockedITracerProviderSyncInt64.CounterCalls()) -func (mock *ITracerProviderSyncInt64Mock) CounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockCounter.RLock() - calls = mock.calls.Counter - mock.lockCounter.RUnlock() - return calls -} - -// Histogram calls HistogramFunc. -func (mock *ITracerProviderSyncInt64Mock) Histogram(name string, opts ...instrument.Option) (syncint64.Histogram, error) { - if mock.HistogramFunc == nil { - panic("ITracerProviderSyncInt64Mock.HistogramFunc: method is nil but ITracerProviderSyncInt64.Histogram was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockHistogram.Lock() - mock.calls.Histogram = append(mock.calls.Histogram, callInfo) - mock.lockHistogram.Unlock() - return mock.HistogramFunc(name, opts...) -} - -// HistogramCalls gets all the calls that were made to Histogram. -// Check the length with: -// -// len(mockedITracerProviderSyncInt64.HistogramCalls()) -func (mock *ITracerProviderSyncInt64Mock) HistogramCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockHistogram.RLock() - calls = mock.calls.Histogram - mock.lockHistogram.RUnlock() - return calls -} - -// UpDownCounter calls UpDownCounterFunc. -func (mock *ITracerProviderSyncInt64Mock) UpDownCounter(name string, opts ...instrument.Option) (syncint64.UpDownCounter, error) { - if mock.UpDownCounterFunc == nil { - panic("ITracerProviderSyncInt64Mock.UpDownCounterFunc: method is nil but ITracerProviderSyncInt64.UpDownCounter was just called") - } - callInfo := struct { - Name string - Opts []instrument.Option - }{ - Name: name, - Opts: opts, - } - mock.lockUpDownCounter.Lock() - mock.calls.UpDownCounter = append(mock.calls.UpDownCounter, callInfo) - mock.lockUpDownCounter.Unlock() - return mock.UpDownCounterFunc(name, opts...) -} - -// UpDownCounterCalls gets all the calls that were made to UpDownCounter. -// Check the length with: -// -// len(mockedITracerProviderSyncInt64.UpDownCounterCalls()) -func (mock *ITracerProviderSyncInt64Mock) UpDownCounterCalls() []struct { - Name string - Opts []instrument.Option -} { - var calls []struct { - Name string - Opts []instrument.Option - } - mock.lockUpDownCounter.RLock() - calls = mock.calls.UpDownCounter - mock.lockUpDownCounter.RUnlock() - return calls -} diff --git a/operator/controllers/lifecycle/interfaces/meter.go b/operator/controllers/lifecycle/interfaces/meter.go index bca8a83d40..9d136d144d 100644 --- a/operator/controllers/lifecycle/interfaces/meter.go +++ b/operator/controllers/lifecycle/interfaces/meter.go @@ -2,23 +2,15 @@ package interfaces import ( "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/metric/instrument/asyncfloat64" - "go.opentelemetry.io/otel/metric/instrument/asyncint64" - "go.opentelemetry.io/otel/metric/instrument/syncfloat64" - "go.opentelemetry.io/otel/metric/instrument/syncint64" ) //go:generate moq -pkg fake -skip-ensure -out ./fake/meter_mock.go . IMeter -type IMeter = metric.Meter - -//go:generate moq -pkg fake -skip-ensure -out ./fake/async/tracer_provider_int_mock.go . ITracerProviderAsyncInt64 -type ITracerProviderAsyncInt64 = asyncint64.InstrumentProvider - -//go:generate moq -pkg fake -skip-ensure -out ./fake/async/tracer_provider_float_mock.go . ITracerProviderAsyncFloat64 -type ITracerProviderAsyncFloat64 = asyncfloat64.InstrumentProvider - -//go:generate moq -pkg fake -skip-ensure -out ./fake/sync/tracer_provider_int_mock.go . ITracerProviderSyncInt64 -type ITracerProviderSyncInt64 = syncint64.InstrumentProvider - -//go:generate moq -pkg fake -skip-ensure -out ./fake/sync/tracer_provider_float_mock.go . ITracerProviderSyncFloat64 -type ITracerProviderSyncFloat64 = syncfloat64.InstrumentProvider +type IMeter interface { + Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) + Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) + Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) + Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) + RegisterCallback(f metric.Callback, instruments ...metric.Observable) (metric.Registration, error) + Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) + Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) +} diff --git a/operator/controllers/lifecycle/keptnappversion/controller.go b/operator/controllers/lifecycle/keptnappversion/controller.go index 99c5b4476f..6d37e9d752 100644 --- a/operator/controllers/lifecycle/keptnappversion/controller.go +++ b/operator/controllers/lifecycle/keptnappversion/controller.go @@ -28,6 +28,7 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" "k8s.io/apimachinery/pkg/api/errors" @@ -188,7 +189,7 @@ func (r *KeptnAppVersionReconciler) finishKeptnAppVersionReconcile(ctx context.C // metrics: add app duration duration := appVersion.Status.EndTime.Time.Sub(appVersion.Status.StartTime.Time) - r.Meters.AppDuration.Record(ctx, duration.Seconds(), attrs...) + r.Meters.AppDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) spanAppTrace.AddEvent(appVersion.Name + " has finished") spanAppTrace.SetStatus(codes.Ok, "Finished") @@ -215,7 +216,7 @@ func (r *KeptnAppVersionReconciler) setupSpansContexts(ctx context.Context, appV if appVersion.IsEndTimeSet() { r.Log.Info("Increasing app count") attrs := appVersion.GetMetricsAttributes() - r.Meters.AppCount.Add(ctx, 1, attrs...) + r.Meters.AppCount.Add(ctx, 1, metric.WithAttributes(attrs...)) } span.End() } diff --git a/operator/controllers/lifecycle/keptnevaluation/controller.go b/operator/controllers/lifecycle/keptnevaluation/controller.go index 1202211007..7f126e182d 100644 --- a/operator/controllers/lifecycle/keptnevaluation/controller.go +++ b/operator/controllers/lifecycle/keptnevaluation/controller.go @@ -29,6 +29,7 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" "k8s.io/apimachinery/pkg/api/errors" @@ -248,11 +249,11 @@ func (r *KeptnEvaluationReconciler) updateFinishedEvaluationMetrics(ctx context. r.Log.Info("Increasing evaluation count") // metrics: increment evaluation counter - r.Meters.EvaluationCount.Add(ctx, 1, attrs...) + r.Meters.EvaluationCount.Add(ctx, 1, metric.WithAttributes(attrs...)) // metrics: add evaluation duration duration := evaluation.Status.EndTime.Time.Sub(evaluation.Status.StartTime.Time) - r.Meters.EvaluationDuration.Record(ctx, duration.Seconds(), attrs...) + r.Meters.EvaluationDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) return nil } diff --git a/operator/controllers/lifecycle/keptntask/controller.go b/operator/controllers/lifecycle/keptntask/controller.go index cd6ab1d428..9a0482197d 100644 --- a/operator/controllers/lifecycle/keptntask/controller.go +++ b/operator/controllers/lifecycle/keptntask/controller.go @@ -28,6 +28,7 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" batchv1 "k8s.io/api/batch/v1" @@ -127,11 +128,11 @@ func (r *KeptnTaskReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( r.Log.Info("Increasing task count") // metrics: increment task counter - r.Meters.TaskCount.Add(ctx, 1, attrs...) + r.Meters.TaskCount.Add(ctx, 1, metric.WithAttributes(attrs...)) // metrics: add task duration duration := task.Status.EndTime.Time.Sub(task.Status.StartTime.Time) - r.Meters.TaskDuration.Record(ctx, duration.Seconds(), attrs...) + r.Meters.TaskDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) return ctrl.Result{}, nil } diff --git a/operator/controllers/lifecycle/keptnworkloadinstance/controller.go b/operator/controllers/lifecycle/keptnworkloadinstance/controller.go index b9e2141e6c..72dfc0513d 100644 --- a/operator/controllers/lifecycle/keptnworkloadinstance/controller.go +++ b/operator/controllers/lifecycle/keptnworkloadinstance/controller.go @@ -28,6 +28,7 @@ import ( controllererrors "github.com/keptn/lifecycle-toolkit/operator/controllers/errors" "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" "k8s.io/apimachinery/pkg/api/errors" @@ -195,7 +196,7 @@ func (r *KeptnWorkloadInstanceReconciler) finishKeptnWorkloadInstanceReconcile(c // metrics: add deployment duration duration := workloadInstance.Status.EndTime.Time.Sub(workloadInstance.Status.StartTime.Time) - r.Meters.DeploymentDuration.Record(ctx, duration.Seconds(), attrs...) + r.Meters.DeploymentDuration.Record(ctx, duration.Seconds(), metric.WithAttributes(attrs...)) spanWorkloadTrace.AddEvent(workloadInstance.Name + " has finished") spanWorkloadTrace.SetStatus(codes.Ok, "Finished") @@ -236,7 +237,7 @@ func (r *KeptnWorkloadInstanceReconciler) setupSpansContexts(ctx context.Context if workloadInstance.IsEndTimeSet() { r.Log.Info("Increasing deployment count") attrs := workloadInstance.GetMetricsAttributes() - r.Meters.DeploymentCount.Add(ctx, 1, attrs...) + r.Meters.DeploymentCount.Add(ctx, 1, metric.WithAttributes(attrs...)) } span.End() } diff --git a/operator/go.mod b/operator/go.mod index 9345ac695b..f299a51c6d 100644 --- a/operator/go.mod +++ b/operator/go.mod @@ -16,14 +16,14 @@ require ( github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.15.1 github.com/stretchr/testify v1.8.2 - go.opentelemetry.io/otel v1.11.2 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 - go.opentelemetry.io/otel/exporters/prometheus v0.34.0 - go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2 - go.opentelemetry.io/otel/metric v0.34.0 - go.opentelemetry.io/otel/sdk v1.11.2 - go.opentelemetry.io/otel/sdk/metric v0.34.0 - go.opentelemetry.io/otel/trace v1.11.2 + go.opentelemetry.io/otel v1.15.1 + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1 + go.opentelemetry.io/otel/exporters/prometheus v0.38.1 + go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1 + go.opentelemetry.io/otel/metric v0.38.1 + go.opentelemetry.io/otel/sdk v1.15.1 + go.opentelemetry.io/otel/sdk/metric v0.38.1 + go.opentelemetry.io/otel/trace v1.15.1 google.golang.org/grpc v1.54.1 k8s.io/api v0.26.4 k8s.io/apiextensions-apiserver v0.26.4 @@ -47,7 +47,7 @@ require ( require ( github.com/beorn7/perks v1.0.1 // indirect - github.com/cenkalti/backoff/v4 v4.2.0 // indirect + github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect @@ -79,11 +79,10 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect - github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/pflag v1.0.5 // indirect - go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect + go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect diff --git a/operator/go.sum b/operator/go.sum index 9007300185..ab10917469 100644 --- a/operator/go.sum +++ b/operator/go.sum @@ -48,8 +48,8 @@ github.com/benbjohnson/clock v1.3.4/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZx github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= -github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= +github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -256,7 +256,6 @@ github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= @@ -289,26 +288,26 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0= -go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 h1:htgM8vZIF8oPSCxa341e3IZ4yr/sKxgu8KZYllByiVY= -go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2/go.mod h1:rqbht/LlhVBgn5+k3M5QK96K5Xb0DvXpMJ5SFQpY6uw= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 h1:fqR1kli93643au1RKo0Uma3d2aPQKT+WBKfTSBaKbOc= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2/go.mod h1:5Qn6qvgkMsLDX+sYK64rHb1FPhpn0UtxF+ouX1uhyJE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 h1:ERwKPn9Aer7Gxsc0+ZlutlH1bEEAUXAUhqm3Y45ABbk= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2/go.mod h1:jWZUM2MWhWCJ9J9xVbRx7tzK1mXKpAlze4CeulycwVY= -go.opentelemetry.io/otel/exporters/prometheus v0.34.0 h1:L5D+HxdaC/ORB47ribbTBbkXRZs9JzPjq0EoIOMWncM= -go.opentelemetry.io/otel/exporters/prometheus v0.34.0/go.mod h1:6gUoJyfhoWqF0tOLaY0ZmKgkQRcvEQx6p5rVlKHp3s4= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2 h1:BhEVgvuE1NWLLuMLvC6sif791F45KFHi5GhOs1KunZU= -go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2/go.mod h1:bx//lU66dPzNT+Y0hHA12ciKoMOH9iixEwCqC1OeQWQ= -go.opentelemetry.io/otel/metric v0.34.0 h1:MCPoQxcg/26EuuJwpYN1mZTeCYAUGx8ABxfW07YkjP8= -go.opentelemetry.io/otel/metric v0.34.0/go.mod h1:ZFuI4yQGNCupurTXCwkeD/zHBt+C2bR7bw5JqUm/AP8= -go.opentelemetry.io/otel/sdk v1.11.2 h1:GF4JoaEx7iihdMFu30sOyRx52HDHOkl9xQ8SMqNXUiU= -go.opentelemetry.io/otel/sdk v1.11.2/go.mod h1:wZ1WxImwpq+lVRo4vsmSOxdd+xwoUJ6rqyLc3SyX9aU= -go.opentelemetry.io/otel/sdk/metric v0.34.0 h1:7ElxfQpXCFZlRTvVRTkcUvK8Gt5DC8QzmzsLsO2gdzo= -go.opentelemetry.io/otel/sdk/metric v0.34.0/go.mod h1:l4r16BIqiqPy5rd14kkxllPy/fOI4tWo1jkpD9Z3ffQ= -go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0= -go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA= +go.opentelemetry.io/otel v1.15.1 h1:3Iwq3lfRByPaws0f6bU3naAqOR1n5IeDWd9390kWHa8= +go.opentelemetry.io/otel v1.15.1/go.mod h1:mHHGEHVDLal6YrKMmk9LqC4a3sF5g+fHfrttQIB1NTc= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1 h1:XYDQtNzdb2T4uM1pku2m76eSMDJgqhJ+6KzkqgQBALc= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.15.1/go.mod h1:uOTV75+LOzV+ODmL8ahRLWkFA3eQcSC2aAsbxIu4duk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1 h1:tyoeaUh8REKay72DVYsSEBYV18+fGONe+YYPaOxgLoE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.15.1/go.mod h1:HUSnrjQQ19KX9ECjpQxufsF+3ioD3zISPMlauTPZu2g= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1 h1:pIfoG5IAZFzp9EUlJzdSkpUwpaUAAnD+Ru1nBLTACIQ= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.15.1/go.mod h1:poNKBqF5+nR/6ke2oGTDjHfksrsHDOHXAl2g4+9ONsY= +go.opentelemetry.io/otel/exporters/prometheus v0.38.1 h1:GwalIvFIx91qIA8qyAyqYj9lql5Ba2Oxj/jDG6+3UoU= +go.opentelemetry.io/otel/exporters/prometheus v0.38.1/go.mod h1:6K7aBvWHXRUcNYFSj6Hi5hHwzA1jYflG/T8snrX4dYM= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1 h1:2PunuO5SbkN5MhCbuHCd3tC6qrcaj+uDAkX/qBU5BAs= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.1/go.mod h1:q8+Tha+5LThjeSU8BW93uUC5w5/+DnYHMKBMpRCsui0= +go.opentelemetry.io/otel/metric v0.38.1 h1:2MM7m6wPw9B8Qv8iHygoAgkbejed59uUR6ezR5T3X2s= +go.opentelemetry.io/otel/metric v0.38.1/go.mod h1:FwqNHD3I/5iX9pfrRGZIlYICrJv0rHEUl2Ln5vdIVnQ= +go.opentelemetry.io/otel/sdk v1.15.1 h1:5FKR+skgpzvhPQHIEfcwMYjCBr14LWzs3uSqKiQzETI= +go.opentelemetry.io/otel/sdk v1.15.1/go.mod h1:8rVtxQfrbmbHKfqzpQkT5EzZMcbMBwTzNAggbEAM0KA= +go.opentelemetry.io/otel/sdk/metric v0.38.1 h1:EkO5wI4NT/fUaoPMGc0fKV28JaWe7q4vfVpEVasGb+8= +go.opentelemetry.io/otel/sdk/metric v0.38.1/go.mod h1:Rn4kSXFF9ZQZ5lL1pxQjCbK4seiO+U7s0ncmIFJaj34= +go.opentelemetry.io/otel/trace v1.15.1 h1:uXLo6iHJEzDfrNC0L0mNjItIp06SyaBQxu5t3xMlngY= +go.opentelemetry.io/otel/trace v1.15.1/go.mod h1:IWdQG/5N1x7f6YUlmdLeJvH9yxtuJAfc4VW5Agv9r/8= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= @@ -316,7 +315,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= diff --git a/operator/test/component/common/common.go b/operator/test/component/common/common.go index 14e1737e49..6b010ad1f4 100644 --- a/operator/test/component/common/common.go +++ b/operator/test/component/common/common.go @@ -16,9 +16,8 @@ import ( ginkgotypes "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" - "go.opentelemetry.io/otel/metric/instrument" - "go.opentelemetry.io/otel/metric/unit" - "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/metric" + sdkmetric "go.opentelemetry.io/otel/sdk/metric" otelsdk "go.opentelemetry.io/otel/sdk/trace" sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" "go.opentelemetry.io/otel/trace" @@ -36,16 +35,16 @@ import ( ) func InitKeptnMeters() apicommon.KeptnMeters { - provider := metric.NewMeterProvider() + provider := sdkmetric.NewMeterProvider() meter := provider.Meter("keptn/task") - deploymentCount, _ := meter.SyncInt64().Counter("keptn.deployment.count", instrument.WithDescription("a simple counter for Keptn Deployments")) - deploymentDuration, _ := meter.SyncFloat64().Histogram("keptn.deployment.duration", instrument.WithDescription("a histogram of duration for Keptn Deployments"), instrument.WithUnit(unit.Unit("s"))) - taskCount, _ := meter.SyncInt64().Counter("keptn.task.count", instrument.WithDescription("a simple counter for Keptn Tasks")) - taskDuration, _ := meter.SyncFloat64().Histogram("keptn.task.duration", instrument.WithDescription("a histogram of duration for Keptn Tasks"), instrument.WithUnit(unit.Unit("s"))) - appCount, _ := meter.SyncInt64().Counter("keptn.app.count", instrument.WithDescription("a simple counter for Keptn Apps")) - appDuration, _ := meter.SyncFloat64().Histogram("keptn.app.duration", instrument.WithDescription("a histogram of duration for Keptn Apps"), instrument.WithUnit(unit.Unit("s"))) - evaluationCount, _ := meter.SyncInt64().Counter("keptn.evaluation.count", instrument.WithDescription("a simple counter for Keptn Evaluations")) - evaluationDuration, _ := meter.SyncFloat64().Histogram("keptn.evaluation.duration", instrument.WithDescription("a histogram of duration for Keptn Evaluations"), instrument.WithUnit(unit.Unit("s"))) + deploymentCount, _ := meter.Int64Counter("keptn.deployment.count", metric.WithDescription("a simple counter for Keptn Deployments")) + deploymentDuration, _ := meter.Float64Histogram("keptn.deployment.duration", metric.WithDescription("a histogram of duration for Keptn Deployments"), metric.WithUnit("s")) + taskCount, _ := meter.Int64Counter("keptn.task.count", metric.WithDescription("a simple counter for Keptn Tasks")) + taskDuration, _ := meter.Float64Histogram("keptn.task.duration", metric.WithDescription("a histogram of duration for Keptn Tasks"), metric.WithUnit("s")) + appCount, _ := meter.Int64Counter("keptn.app.count", metric.WithDescription("a simple counter for Keptn Apps")) + appDuration, _ := meter.Float64Histogram("keptn.app.duration", metric.WithDescription("a histogram of duration for Keptn Apps"), metric.WithUnit("s")) + evaluationCount, _ := meter.Int64Counter("keptn.evaluation.count", metric.WithDescription("a simple counter for Keptn Evaluations")) + evaluationDuration, _ := meter.Float64Histogram("keptn.evaluation.duration", metric.WithDescription("a histogram of duration for Keptn Evaluations"), metric.WithUnit("s")) meters := apicommon.KeptnMeters{ TaskCount: taskCount,