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

chore: parse string values for __value filter #7035

Merged
merged 6 commits into from
Feb 6, 2025
Merged

Conversation

srikanthccv
Copy link
Member

@srikanthccv srikanthccv commented Feb 6, 2025

Summary

Certain metrics encode the state as the value, such as pod phase https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/k8sclusterreceiver/documentation.md#k8spodphase, making it difficult to aggregate and filter. For pod phase there is no way to filter by pending pods because there is no label but only a special value. To work around this, we added a special filter called "__value". If we find this in the search items. We assume that the user wants to filter on the value and add value condition. It is not working when the value type is a string. This change checks if the string value can be converted, if so add metric value filter with converted. Otherwise, warn and skip the metric values filter.


Important

AddMetricValueFilter now supports filtering on string values for __value by converting them to float, with tests added.

  • Behavior:
    • AddMetricValueFilter in query_builder.go now supports string values for __value filter by attempting conversion to float.
    • Logs a warning and skips filter if conversion fails.
  • Testing:
    • Added test case in query_builder_test.go to verify filtering with string values that can be converted to numbers.

This description was created by Ellipsis for 96df934. It will automatically update as commits are pushed.

@github-actions github-actions bot added the chore label Feb 6, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to 96df934 in 59 seconds

More details
  • Looked at 70 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. pkg/query-service/app/metrics/v4/query_builder_test.go:511
  • Draft comment:
    Consider adding a negative test case for a __value string that cannot be parsed (non-numeric) so that it verifies the warning log and that the filter is skipped.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 30% vs. threshold = 50%
    The comment points out a valid gap in test coverage - we only test the success case but not error handling. However, I need to consider if this meets the bar for a required code change. The current test verifies core functionality. Error handling tests would be nice-to-have but may not be essential.
    The comment is speculative - we don't know if there actually is warning log and filter skip behavior implemented. Without seeing the implementation code, we can't be sure this test would be testing real behavior.
    While speculative, the suggestion is reasonable - any robust implementation should handle invalid input gracefully. Testing error cases is generally good practice.
    The comment should be deleted as it is speculative and not clearly tied to a required code change. While the suggestion has merit, it doesn't meet the bar for a must-fix comment.
2. pkg/query-service/app/metrics/query_builder.go:69
  • Draft comment:
    Consider including the actual string value in the warn log (e.g. using zap.String("value", v)) for easier debugging.
  • Reason this comment was not posted:
    Confidence changes required: 50% <= threshold 50%
    None
3. pkg/query-service/app/metrics/v4/query_builder_test.go:511
  • Draft comment:
    Consider adding a test case with a non-numeric string to verify that an invalid __value filter is gracefully skipped.
  • Reason this comment was not posted:
    Marked as duplicate.

Workflow ID: wflow_PLeJxv7KwQc33B8K


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

pkg/query-service/app/metrics/query_builder.go Outdated Show resolved Hide resolved
@srikanthccv srikanthccv enabled auto-merge (squash) February 6, 2025 11:39
@srikanthccv srikanthccv merged commit a8e8f31 into main Feb 6, 2025
15 of 16 checks passed
@srikanthccv srikanthccv deleted the string-to-number branch February 6, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants