diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a8a0267601..8b049fce527 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,9 +86,9 @@ New deprecation(s): ### Other - **General**: Improve readability of utility function getParameterFromConfigV2 ([#5037](https://github.com/kedacore/keda/issues/5037)) +- **General**: Introduce ENABLE_OPENTELEMETRY in deploying/testing process ([#5375](https://github.com/kedacore/keda/issues/5375)) - **General**: Migrate away from unmaintained golang/mock and use uber/gomock ([#5440](https://github.com/kedacore/keda/issues/5440)) - **General**: Minor refactor to reduce copy/paste code in ScaledObject webhook ([#5397](https://github.com/kedacore/keda/issues/5397)) -- **General**: TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX)) ## v2.13.0 diff --git a/Makefile b/Makefile index 2bc37a494ad..cad48a0b6cf 100644 --- a/Makefile +++ b/Makefile @@ -288,6 +288,10 @@ deploy: install ## Deploy controller to the K8s cluster specified in ~/.kube/con cd config/service_account && \ $(KUSTOMIZE) edit add annotation --force cloud.google.com/workload-identity-provider:${GCP_WI_PROVIDER} cloud.google.com/service-account-email:${TF_GCP_SA_EMAIL} cloud.google.com/gcloud-run-as-user:${NON_ROOT_USER_ID} cloud.google.com/injection-mode:direct; \ fi + if [ "$(ENABLE_OPENTELEMETRY)" = true ]; then \ + cd config/e2e && \ + $(KUSTOMIZE) edit add patch --path opentelemetry/patch_operator.yml --group apps --kind Deployment --name keda-operator --version v1; \ + fi cd config/webhooks && \ $(KUSTOMIZE) edit set image ghcr.io/kedacore/keda-admission-webhooks=${IMAGE_WEBHOOKS} diff --git a/config/e2e/opentelemetry/patch_operator.yml b/config/e2e/opentelemetry/patch_operator.yml new file mode 100644 index 00000000000..056c91f8d4b --- /dev/null +++ b/config/e2e/opentelemetry/patch_operator.yml @@ -0,0 +1,15 @@ +- op: add + path: /spec/template/spec/containers/0/args/- + value: --enable-opentelemetry-metrics=true + +- op: add + path: /spec/template/spec/containers/0/env/- + value: + name: OTEL_EXPORTER_OTLP_ENDPOINT + value: "http://opentelemetry-collector.open-telemetry-system.svc.cluster.local:4318" + +- op: add + path: /spec/template/spec/containers/0/env/- + value: + name: OTEL_METRIC_EXPORT_INTERVAL + value: "3000" diff --git a/config/e2e/patch_operator.yml b/config/e2e/patch_operator.yml index f3b8c01001d..aa18fb35b4b 100644 --- a/config/e2e/patch_operator.yml +++ b/config/e2e/patch_operator.yml @@ -17,19 +17,3 @@ - op: replace path: /spec/template/spec/containers/0/resources/requests/cpu value: 500m - -- op: add - path: /spec/template/spec/containers/0/args/- - value: --enable-opentelemetry-metrics=true - -- op: add - path: /spec/template/spec/containers/0/env/- - value: - name: OTEL_EXPORTER_OTLP_ENDPOINT - value: "http://opentelemetry-collector.open-telemetry-system.svc.cluster.local:4318" - -- op: add - path: /spec/template/spec/containers/0/env/- - value: - name: OTEL_METRIC_EXPORT_INTERVAL - value: "3000" diff --git a/tests/helper/helper.go b/tests/helper/helper.go index 4cdbebdc88f..f01d493cdd7 100644 --- a/tests/helper/helper.go +++ b/tests/helper/helper.go @@ -81,6 +81,7 @@ var ( AzureRunWorkloadIdentityTests = os.Getenv("AZURE_RUN_WORKLOAD_IDENTITY_TESTS") AwsIdentityTests = os.Getenv("AWS_RUN_IDENTITY_TESTS") GcpIdentityTests = os.Getenv("GCP_RUN_IDENTITY_TESTS") + EnableOpentelemetry = os.Getenv("ENABLE_OPENTELEMETRY") InstallCertManager = AwsIdentityTests == StringTrue || GcpIdentityTests == StringTrue ) diff --git a/tests/sequential/opentelemetry_metrics/opentelemetry_metrics_test.go b/tests/sequential/opentelemetry_metrics/opentelemetry_metrics_test.go index 5ce2c93f7ba..fbea5e3378b 100644 --- a/tests/sequential/opentelemetry_metrics/opentelemetry_metrics_test.go +++ b/tests/sequential/opentelemetry_metrics/opentelemetry_metrics_test.go @@ -428,6 +428,11 @@ func TestOpenTelemetryMetrics(t *testing.T) { // setup t.Log("--- setting up ---") + // If opentelemetry is not enabled, skip the test + if EnableOpentelemetry == "" || EnableOpentelemetry == StringFalse { + t.Skip("skipping opentelemetry test as EnableOpentelemetry is not set to true") + } + // Create kubernetes resources kc := GetKubernetesClient(t) data, templates := getTemplateData() @@ -693,6 +698,7 @@ func testScalerMetricLatency(t *testing.T) { var found bool metrics := val.GetMetric() for _, metric := range metrics { + t.Log("--- latency metric detail info ---", "metric", metric) labels := metric.GetLabel() for _, label := range labels { if (*label.Name == labelScaledObject && *label.Value == scaledObjectName) || diff --git a/tests/utils/setup_test.go b/tests/utils/setup_test.go index 1b2775630f4..14cfcec67d7 100644 --- a/tests/utils/setup_test.go +++ b/tests/utils/setup_test.go @@ -169,6 +169,10 @@ func TesVerifyPodsIdentity(t *testing.T) { } func TestSetupOpentelemetryComponents(t *testing.T) { + if EnableOpentelemetry == "" || EnableOpentelemetry == StringFalse { + t.Skip("skipping installing opentelemetry") + } + otlpTempFileName := "otlp.yml" otlpServiceTempFileName := "otlpServicePatch.yml" defer os.Remove(otlpTempFileName)