Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENABLE_OPENTELEMETRY flag #5436

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
15 changes: 15 additions & 0 deletions config/e2e/opentelemetry/patch_operator.yml
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 0 additions & 16 deletions config/e2e/patch_operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
1 change: 1 addition & 0 deletions tests/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) ||
Expand Down
4 changes: 4 additions & 0 deletions tests/utils/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading