Skip to content

Commit e07a128

Browse files
authored
fix(docs): allow empty character in metric tags values (#2775)
* allow empty char in tags values
1 parent f874407 commit e07a128

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sentry_sdk/metrics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555

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

6161
GOOD_TRANSACTION_SOURCES = frozenset(

tests/test_metrics.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ def test_tag_normalization(
811811
metrics.distribution("a", 1.0, tags={"foo-bar": "%$foo"}, timestamp=ts)
812812
metrics.distribution("b", 1.0, tags={"foo$$$bar": "blah{}"}, timestamp=ts)
813813
metrics.distribution("c", 1.0, tags={u"foö-bar": u"snöwmän"}, timestamp=ts)
814+
metrics.distribution("d", 1.0, tags={"route": "GET /foo"}, timestamp=ts)
814815
# fmt: on
815816
Hub.current.flush()
816817

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

823-
assert len(m) == 3
824+
assert len(m) == 4
824825
assert m[0][4] == {
825826
"foo-bar": "$foo",
826827
"release": "[email protected]",
@@ -839,6 +840,11 @@ def test_tag_normalization(
839840
"release": "[email protected]",
840841
"environment": "not-fun-env",
841842
}
843+
assert m[3][4] == {
844+
"release": "[email protected]",
845+
"environment": "not-fun-env",
846+
"route": "GET /foo",
847+
}
842848
# fmt: on
843849

844850

0 commit comments

Comments
 (0)