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

Fixed decoding warning for None tags #3249

Merged
merged 4 commits into from
Mar 7, 2019
Merged

Conversation

Simwar
Copy link
Contributor

@Simwar Simwar commented Mar 6, 2019

What does this PR do?

If an integration tries to send a metric with tag set to None, there will be a warning thrown by this code: https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/datadog_checks/base/checks/base.py#L352-L363
As we cannot decode it.

Now, we simply ignore if a tag is set to None.

Motivation

Customer which had his logs spammed by this warning, because of a label missing in a prometheus payload.

Review checklist (to be filled by reviewers)

  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have changelog/ and integration/ labels attached
  • Feature or bugfix must have tests
  • Git history must be clean
  • If PR adds a configuration option, it must be added to the configuration file.

continue

normalized_tags.append(tag)
if not tag:
Copy link
Contributor

Choose a reason for hiding this comment

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

since we expect None tags, let's explicitly do if tag is None: continue and leave the rest of the code unchanged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tags = [None, 'tag:foo']

normalized_tags = check._normalize_tags_type(tags, None)
assert len(normalized_tags) == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

let's test the contents, not the length

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✅ thanks!

@Simwar Simwar requested a review from masci March 7, 2019 10:34
@codecov
Copy link

codecov bot commented Mar 7, 2019

Codecov Report

Merging #3249 into master will decrease coverage by 9.2%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #3249      +/-   ##
==========================================
- Coverage   85.18%   75.98%   -9.21%     
==========================================
  Files         690       54     -636     
  Lines       36813     3964   -32849     
  Branches     4469      504    -3965     
==========================================
- Hits        31360     3012   -28348     
+ Misses       4204      832    -3372     
+ Partials     1249      120    -1129

@Simwar Simwar merged commit 3c6a360 into master Mar 7, 2019
@gzussa gzussa deleted the none_tag_normalize_warning branch March 13, 2019 21:20
@Simwar
Copy link
Contributor Author

Simwar commented Apr 23, 2019

Added a follow-up PR to have the same fix but for the python2 check base class: #3665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants