8000 Make metrics tests non-flaky (#2572) · getsentry/sentry-python@9bb6bdf · GitHub
[go: up one dir, main page]

Skip to content

Commit 9bb6bdf

Browse files
authored
Make metrics tests non-flaky (#2572)
* Made test non-flaky between different python versions
1 parent 0eb3465 commit 9bb6bdf

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

tests/test_metrics.py

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@ def should_summarize_metric(key, tags):
700700
with start_transaction(
701701
op="stuff", name="/foo", source=TRANSACTION_SOURCE_ROUTE
702702
) as transaction:
703-
metrics.timing("foo", value=1.0, tags={"a": "b"}, timestamp=ts)
704-
metrics.timing("foo", value=1.0, tags={"b": "c"}, timestamp=ts)
703+
metrics.timing("foo", value=3.0, tags={"a": "b"}, timestamp=ts)
704+
metrics.timing("foo", value=2.0, tags={"b": "c"}, timestamp=ts)
705705
metrics.timing("bar", value=1.0, tags={"a": "b"}, timestamp=ts)
706706

707707
Hub.current.flush()
@@ -719,34 +719,31 @@ def should_summarize_metric(key, tags):
719719

720720
# Measurement Attachment
721721
t = transaction.items[0].get_transaction_event()["_metrics_summary"]
722-
assert t == {
723-
"d:foo@second": [
724-
{
725-
"tags": {
726-
"a": "b",
727-
"environment": "not-fun-env",
728-
"release": "fun-release@1.0.0",
729-
"transaction": "/foo",
730-
},
731-
"min": 1.0,
732-
"max": 1.0,
733-
"count": 1,
734-
"sum": 1.0,
735-
},
736-
{
737-
"tags": {
738-
"b": "c",
739-
"environment": "not-fun-env",
740-
"release": "fun-release@1.0.0",
741-
"transaction": "/foo",
742-
},
743-
"min": 1.0,
744-
"max": 1.0,
745-
"count": 1,
746-
"sum": 1.0,
747-
},
748-
]
749-
}
722+
assert len(t["d:foo@second"]) == 2
723+
assert {
724+
"tags": {
725+
"a": "b",
726+
"environment": "not-fun-env",
727+
"release": "fun-release@1.0.0",
728+
"transaction": "/foo",
729+
},
730+
"min": 3.0,
731+
"max": 3.0,
732+
"count": 1,
733+
"sum": 3.0,
734+
} in t["d:foo@second"]
735+
assert {
736+
"tags": {
737+
"b": "c",
738+
"environment": "not-fun-env",
739+
"release": "fun-release@1.0.0",
740+
"transaction": "/foo",
741+
},
742+
"min": 2.0,
743+
"max": 2.0,
744+
"count": 1,
745+
"sum": 2.0,
746+
} in t["d:foo@second"]
750747

751748

752749
def test_tag_normalization(sentry_init, capture_envelopes):

0 commit comments

Comments
 (0)
0