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

fix(metricprovider): fix handling null values in datadog #3893

Merged

Conversation

y-rabie
Copy link
Contributor

@y-rabie y-rabie commented Oct 13, 2024

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

When Datadog returns a values list with JSON null value, instead of an empty slice, it gets unmarshalled to a float64 value of 0, which is not what should happen (should be treated as if an empty slice). This is because values is a []float64. Switching it to []*float64 fixes this issue.

I've encountered this issue when doing zero/zero division. For example in a/(a+b), where a and b are both zeros, the a/(a+b) formula returns null. I'm sure this could happen in other cases but I'm not aware of them.

For reference, this is what the datadog response would look like:

{
    "data": {
        "attributes": {
            "columns": [
                {
                    "meta": {
                        "unit": null
                    },
                    "name": "a/(a+b)",
                    "type": "number",
                    "values": [
                        null
                    ]
                }
            ]
        },
        "type": "scalar_response"
    }
}

For the numerator and denominator

                {
                    "meta": {
                        "unit": null
                    },
                    "name": "a",
                    "type": "number",
                    "values": [
                        0.0
                    ]
                },
                {
                    "meta": {
                        "unit": null
                    },
                    "name": "b",
                    "type": "number",
                    "values": [
                        0.0
                    ]
                },
                {
                    "meta": {
                        "unit": null
                    },
                    "name": "a+b",
                    "type": "number",
                    "values": [
                        0.0
                    ]
                },

I've built and tested the image. No need for additional unit tests.

Copy link

Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.90%. Comparing base (b0d74e5) to head (f1dfbc7).
Report is 72 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3893      +/-   ##
==========================================
+ Coverage   83.87%   83.90%   +0.03%     
==========================================
  Files         163      163              
  Lines       18564    18564              
==========================================
+ Hits        15571    15577       +6     
+ Misses       2120     2117       -3     
+ Partials      873      870       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Published E2E Test Results

  4 files    4 suites   3h 15m 54s ⏱️
113 tests 103 ✅  7 💤 3 ❌
458 runs  425 ✅ 28 💤 5 ❌

For more details on these failures, see this check.

Results for commit f1dfbc7.

Copy link
Contributor

Published Unit Test Results

2 275 tests   2 275 ✅  2m 59s ⏱️
  128 suites      0 💤
    1 files        0 ❌

Results for commit f1dfbc7.

y-rabie added a commit to y-rabie/argo-rollouts that referenced this pull request Oct 13, 2024
@zachaller zachaller merged commit 785ea17 into argoproj:master Oct 15, 2024
25 checks passed
@y-rabie y-rabie deleted the fix-null-values-handling-dd-metricprovider branch October 15, 2024 10:29
ariadnarouco pushed a commit to adevinta/argo-rollouts that referenced this pull request Oct 16, 2024
Rizwana777 pushed a commit to Rizwana777/argo-rollouts that referenced this pull request Dec 12, 2024
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.

2 participants