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

Remove illegal characters from tags #517

Merged
merged 5 commits into from
Mar 3, 2020

Conversation

jirikuncar
Copy link
Contributor

@jirikuncar jirikuncar commented Jan 21, 2020

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)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • 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 one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@jirikuncar jirikuncar requested a review from jd January 21, 2020 22:35
@jirikuncar jirikuncar added changelog/Fixed Fixed features results into a bug fix version bump resource/dogstatsd labels Jan 21, 2020
@@ -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())
Copy link
Contributor Author

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 ??

Copy link
Contributor

Choose a reason for hiding this comment

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

_

hush-hush
hush-hush previously approved these changes Jan 23, 2020
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had activity in the last 30 days.
Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity.

@github-actions github-actions bot added the stale Stale - Bot reminder label Feb 23, 2020
@jirikuncar jirikuncar self-assigned this Feb 24, 2020
@jirikuncar jirikuncar marked this pull request as ready for review February 28, 2020 11:10
@jirikuncar jirikuncar requested a review from a team as a code owner February 28, 2020 11:10
@@ -5,6 +5,10 @@
import calendar
import datetime
import json
import re

TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\.]")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

shall we allow space?

@@ -5,6 +5,10 @@
import calendar
import datetime
import json
import re

TAG_INVALID_CHARS_RE = re.compile(r"[^\w\d_\-:/\.]")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
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"]
Copy link
Contributor Author

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

Suggested change
assert tag_list_final == ["tag1__tag2", "tag3__tag4", "tag5_tag6"]
assert tag_list_final == ["tag1_ tag2", "tag3 _tag4", "tag5_tag6"]

@jirikuncar
Copy link
Contributor Author

/azp run DataDog.datadogpy.integration

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zippolyte zippolyte changed the title Test pipe in tag Remove illegal characters from tags Mar 3, 2020
@zippolyte zippolyte merged commit 11fe1d8 into DataDog:master Mar 3, 2020
@jirikuncar jirikuncar deleted the jirikuncar/19-tag-with-pipe branch March 9, 2020 12:02
walerian777 pushed a commit to walerian777/datadogpy that referenced this pull request Dec 12, 2022
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.
walerian777 pushed a commit to walerian777/datadogpy that referenced this pull request Dec 12, 2022
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.
walerian777 pushed a commit to walerian777/datadogpy that referenced this pull request Dec 12, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Fixed Fixed features results into a bug fix version bump resource/dogstatsd stale Stale - Bot reminder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants