Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sentry_sdk/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

_in_metrics = ContextVar("in_metrics", default=False)
_sanitize_key = partial(re.compile(r"[^a-zA-Z0-9_/.-]+").sub, "_")
_sanitize_value = partial(re.compile(r"[^\w\d_:/@\.{}\[\]$-]+", re.UNICODE).sub, "")
_sanitize_value = partial(re.compile(r"[^\w\d\s_:/@\.{}\[\]$-]+", re.UNICODE).sub, "")
_set = set # set is shadowed below

GOOD_TRANSACTION_SOURCES = frozenset(
Expand Down
8 changes: 7 additions & 1 deletion tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ def test_tag_normalization(
metrics.distribution("a", 1.0, tags={"foo-bar": "%$foo"}, timestamp=ts)
metrics.distribution("b", 1.0, tags={"foo$$$bar": "blah{}"}, timestamp=ts)
metrics.distribution("c", 1.0, tags={u"foö-bar": u"snöwmän"}, timestamp=ts)
metrics.distribution("d", 1.0, tags={"route": "GET /foo"}, timestamp=ts)
# fmt: on
Hub.current.flush()

Expand All @@ -820,7 +821,7 @@ def test_tag_normalization(
assert envelope.items[0].headers["type"] == "statsd"
m = parse_metrics(envelope.items[0].payload.get_bytes())

assert len(m) == 3
assert len(m) == 4
assert m[0][4] == {
"foo-bar": "$foo",
"release": "[email protected]",
Expand All @@ -839,6 +840,11 @@ def test_tag_normalization(
"release": "[email protected]",
"environment": "not-fun-env",
}
assert m[3][4] == {
"release": "[email protected]",
"environment": "not-fun-env",
"route": "GET /foo",
}
# fmt: on


Expand Down