Skip to content

Commit

Permalink
Make metrics tests non-flaky (#2572)
Browse files Browse the repository at this point in the history
* Made test non-flaky between different python versions
  • Loading branch information
antonpirker committed Dec 7, 2023
1 parent 0eb3465 commit 9bb6bdf
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions tests/test_metrics.py
Expand Up @@ -700,8 +700,8 @@ def should_summarize_metric(key, tags):
with start_transaction(
op="stuff", name="/foo", source=TRANSACTION_SOURCE_ROUTE
) as transaction:
metrics.timing("foo", value=1.0, tags={"a": "b"}, timestamp=ts)
metrics.timing("foo", value=1.0, tags={"b": "c"}, timestamp=ts)
metrics.timing("foo", value=3.0, tags={"a": "b"}, timestamp=ts)
metrics.timing("foo", value=2.0, tags={"b": "c"}, timestamp=ts)
metrics.timing("bar", value=1.0, tags={"a": "b"}, timestamp=ts)

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

# Measurement Attachment
t = transaction.items[0].get_transaction_event()["_metrics_summary"]
assert t == {
"d:foo@second": [
{
"tags": {
"a": "b",
"environment": "not-fun-env",
"release": "fun-release@1.0.0",
"transaction": "/foo",
},
"min": 1.0,
"max": 1.0,
"count": 1,
"sum": 1.0,
},
{
"tags": {
"b": "c",
"environment": "not-fun-env",
"release": "fun-release@1.0.0",
"transaction": "/foo",
},
"min": 1.0,
"max": 1.0,
"count": 1,
"sum": 1.0,
},
]
}
assert len(t["d:foo@second"]) == 2
assert {
"tags": {
"a": "b",
"environment": "not-fun-env",
"release": "fun-release@1.0.0",
"transaction": "/foo",
},
"min": 3.0,
"max": 3.0,
"count": 1,
"sum": 3.0,
} in t["d:foo@second"]
assert {
"tags": {
"b": "c",
"environment": "not-fun-env",
"release": "fun-release@1.0.0",
"transaction": "/foo",
},
"min": 2.0,
"max": 2.0,
"count": 1,
"sum": 2.0,
} in t["d:foo@second"]


def test_tag_normalization(sentry_init, capture_envelopes):
Expand Down

0 comments on commit 9bb6bdf

Please sign in to comment.