Skip to content

Conversation

@JorTurFer
Copy link
Member

@JorTurFer JorTurFer commented Jun 22, 2025

As we don't check otel metrics directly but exported via Prometheus in collector, we are affected by posible changes in how the labels are generated, for example, with the collector v1.128.0, the metrics is:

keda_cloudeventsource_events_emitted_count_total{
cloudEventSource="opentelemetry-metrics-test-ce",
eventsink="http",
job="unknown_service:keda",
namespace="opentelemetry-metrics-test-ns",
otel_scope_name="keda-open-telemetry-metrics",
otel_scope_schema_url="",
otel_scope_version="",
state="emitted"
} 1

And the same metric from the collector v1.127.0 is:

keda_cloudeventsource_events_emitted_count_total{
cloudEventSource="opentelemetry-metrics-test-ce",
eventsink="http",
job="unknown_service:keda",
namespace="opentelemetry-metrics-test-ns",
state="emitted"
} 1

This PR changes the search to get the value by key and not by position to be resilient to changes in the labels because of metric tranformations under the scope of the test

Checklist

  • Commits are signed with Developer Certificate of Origin (DCO - learn more)

@JorTurFer JorTurFer requested a review from a team as a code owner June 22, 2025 19:29
@JorTurFer
Copy link
Member Author

JorTurFer commented Jun 22, 2025

/run-e2e sequential
Update: You can check the progress here

@JorTurFer
Copy link
Member Author

JorTurFer commented Jun 22, 2025

/run-e2e sequential
Update: You can check the progress here

@JorTurFer
Copy link
Member Author

JorTurFer commented Jun 23, 2025

/run-e2e sequential
Update: You can check the progress here

Copy link
Contributor

@dttung2905 dttung2905 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a cleaner way of accessing the Prom label value. The only downside is a slight degrade in performance. For each of the label, we are looping through the whole arr which is O(n) instead of the current way of using index with O(1) time complexity. I personally think it is acceptable to trade performance for readability & maintainability in this case.
If you have a better way, let me know too 😃

@JorTurFer
Copy link
Member Author

I think it is a cleaner way of accessing the Prom label value. The only downside is a slight degrade in performance. For each of the label, we are looping through the whole arr which is O(n) instead of the current way of using index with O(1) time complexity. I personally think it is acceptable to trade performance for readability & maintainability in this case. If you have a better way, let me know too 😃

yeah, I did this change for e2e because it's just a single place to use and actually, the old approach failed on upstream changes, but definitively it'd not be good for production :)

@JorTurFer JorTurFer merged commit a239d24 into kedacore:main Jul 8, 2025
25 checks passed
@JorTurFer JorTurFer deleted the fix-tests branch July 8, 2025 21:06
kmoonwright pushed a commit to kmoonwright/keda that referenced this pull request Jul 9, 2025
)

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

---------

Signed-off-by: Jorge Turrado <[email protected]>
Signed-off-by: kmoonwright <[email protected]>
kmoonwright pushed a commit to kmoonwright/keda that referenced this pull request Jul 9, 2025
)

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

---------

Signed-off-by: Jorge Turrado <[email protected]>
Signed-off-by: kmoonwright <[email protected]>
dpochopsky pushed a commit to dpochopsky/keda that referenced this pull request Sep 12, 2025
)

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

* fix: e2e test checks label value by name and not by index

Signed-off-by: Jorge Turrado <[email protected]>

---------

Signed-off-by: Jorge Turrado <[email protected]>
Signed-off-by: David Pochopsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants