-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Do not append duplicates when using device_name
parameter.
#2850
Conversation
normalized_tags = self._normalize_tags_type(tags) | ||
|
||
return normalized_tags | ||
return self._normalize_tags_type(out_tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid double list creation, let's just revert to working commit here:
integrations-core/datadog_checks_base/datadog_checks/base/checks/base.py
Lines 321 to 327 in 8bb1983
normalized_tags = self._normalize_tags_type(tags) | |
if device_name: | |
self._log_deprecation("device_name") | |
normalized_tags.append("device:{}".format(device_name)) | |
return normalized_tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fixes CI for #2848
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another solution could be
t = copy.deepcopy(tags)
if device_name:
self._log_deprecation("device_name")
t.append("device:{}".format(device_name))
normalized_tags = self._normalize_tags_type(t)
return normalized_tags```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ofek The point is to also normalize the device tag, so we can't really go back to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this refactoring. I like it however names seems hard to grasp, especially for _normalize_type
which is now a very generic method.
normalized_tags.append(tag) | ||
|
||
return normalized_tags | ||
|
||
def _normalize_type(self, data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rename this to reflect more what it does _encode_to_bytes
or _to_bytes
?
Codecov Report
@@ Coverage Diff @@
## master #2850 +/- ##
==========================================
- Coverage 84.48% 76.99% -7.49%
==========================================
Files 630 50 -580
Lines 36958 3582 -33376
Branches 4416 414 -4002
==========================================
- Hits 31223 2758 -28465
+ Misses 4434 724 -3710
+ Partials 1301 100 -1201 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
What does this PR do?
Avoids appending multiple times the same tag when the (deprecated)
device_name
param is used. This will also fix tests onmaster
.PR is marked as
no-changelog
because the commit that introduced the bug (#2822) hasn't been released yet.Motivation
Avoid sending fatter payloads because of duplicates
Review checklist
no-changelog
label attached