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

Make metrics tests non-flaky #2572

Merged
merged 4 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 27 additions & 30 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
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