-
Notifications
You must be signed in to change notification settings - Fork 305
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
Remove illegal characters from tags #517
Remove illegal characters from tags #517
Conversation
tests/unit/dogstatsd/test_statsd.py
Outdated
@@ -212,6 +212,10 @@ def test_histogram(self): | |||
self.statsd.histogram('histo', 123.4) | |||
assert_equal_telemetry('histo:123.4|h', self.recv()) | |||
|
|||
def test_pipe_in_tags(self): | |||
self.statsd.gauge('gt', 123.4, tags=['pipe|in:tag', 'red']) | |||
assert_equal_telemetry('gt:123.4|g|#pipe?in:tag,red', self.recv()) |
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 should go there instead of ?
?
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.
_
This issue has been automatically marked as stale because it has not had activity in the last 30 days. |
datadog/util/format.py
Outdated
@@ -5,6 +5,10 @@ | |||
import calendar | |||
import datetime | |||
import json | |||
import re | |||
|
|||
TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\.]") |
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.
shall we allow space?
datadog/util/format.py
Outdated
@@ -5,6 +5,10 @@ | |||
import calendar | |||
import datetime | |||
import json | |||
import re | |||
|
|||
TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\.]") |
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.
TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\.]") | |
TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\. ]") |
@@ -141,7 +141,7 @@ def test_hostname_warning_not_present(self): | |||
def test_normalize_tags(self): | |||
tag_list_test = ["tag1, tag2", "tag3 ,tag4", "tag5,tag6"] | |||
tag_list_final = normalize_tags(tag_list_test) | |||
assert tag_list_final == ["tag1_ tag2", "tag3 _tag4", "tag5_tag6"] | |||
assert tag_list_final == ["tag1__tag2", "tag3__tag4", "tag5_tag6"] |
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.
in case we want to keep space https://github.com/DataDog/datadogpy/pull/517/files#r385638649
assert tag_list_final == ["tag1__tag2", "tag3__tag4", "tag5_tag6"] | |
assert tag_list_final == ["tag1_ tag2", "tag3 _tag4", "tag5_tag6"] |
/azp run DataDog.datadogpy.integration |
Azure Pipelines successfully started running 1 pipeline(s). |
According to the documentation https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics metric names contain only ASCII alphanumerics, underscores, and periods, while other characters are converted to underscores. This commit ensures we replace all invalid characters with underscores for both namespaces and metric names. A similar thing has been already done for tags in DataDog#489 and DataDog#517, so I followed the example. It solves DataDog#740.
According to the documentation https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics metric names contain only ASCII alphanumerics, underscores, and periods, while other characters are converted to underscores. This commit ensures we replace all invalid characters with underscores for both namespaces and metric names. A similar thing has been already done for tags in DataDog#489 and DataDog#517, so I followed the example. It solves DataDog#740.
According to the documentation https://docs.datadoghq.com/metrics/custom_metrics/#naming-custom-metrics metric names contain only ASCII alphanumerics, underscores, and periods, while other characters are converted to underscores. This commit ensures we replace all invalid characters with underscores for both namespaces and metric names. A similar thing has been already done for tags in DataDog#489 and DataDog#517, so I followed the example. It solves DataDog#740.
What does this PR do?
Check behavior of pipe character in tags.
Description of the Change
Added a test-case.
Alternate Designs
Possible Drawbacks
Verification Process
Additional Notes
addresses #19
Release Notes
Review checklist (to be filled by reviewers)
changelog/
label attached. If applicable it should have thebackward-incompatible
label attached.do-not-merge/
label attached.kind/
andseverity/
labels attached at least.