-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(profiling): add endpoint to generate flamegraph from span group …
…for continuous profiling (#73843) depends on getsentry/vroom#482
- Loading branch information
1 parent
a3a56ba
commit f5e7418
Showing
5 changed files
with
325 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import pytest | ||
from snuba_sdk import And, Column, Condition, Op, Or | ||
|
||
from sentry.profiles.flamegraph import get_chunk_snuba_conditions_from_spans_metadata | ||
|
||
|
||
@pytest.mark.parametrize( | ||
["span_metadata", "expected_condition"], | ||
[ | ||
( | ||
{ | ||
"0000": [ | ||
{"start": "1", "end": "2"}, | ||
{"start": "5", "end": "7"}, | ||
] | ||
}, | ||
[ | ||
And( | ||
[ | ||
Condition(Column("profiler_id"), Op.EQ, "0000"), | ||
Or( | ||
[ | ||
And( | ||
[ | ||
Condition(Column("end_timestamp"), Op.GTE, "1"), | ||
Condition(Column("start_timestamp"), Op.LT, "2"), | ||
] | ||
), | ||
And( | ||
[ | ||
Condition(Column("end_timestamp"), Op.GTE, "5"), | ||
Condition(Column("start_timestamp"), Op.LT, "7"), | ||
] | ||
), | ||
] | ||
), # end Or | ||
] | ||
) | ||
], # end And | ||
), | ||
( | ||
{ | ||
"1111": [ | ||
{"start": "1", "end": "2"}, | ||
] | ||
}, | ||
[ | ||
And( | ||
[ | ||
Condition(Column("profiler_id"), Op.EQ, "1111"), | ||
And( | ||
[ | ||
Condition(Column("end_timestamp"), Op.GTE, "1"), | ||
Condition(Column("start_timestamp"), Op.LT, "2"), | ||
] | ||
), | ||
] | ||
) | ||
], # end And | ||
), | ||
( | ||
{ | ||
"1111": [ | ||
{"start": "1", "end": "2"}, | ||
], | ||
"2222": [ | ||
{"start": "1", "end": "2"}, | ||
], | ||
}, | ||
[ | ||
Or( | ||
[ | ||
And( | ||
[ | ||
Condition(Column("profiler_id"), Op.EQ, "1111"), | ||
And( | ||
[ | ||
Condition(Column("end_timestamp"), Op.GTE, "1"), | ||
Condition(Column("start_timestamp"), Op.LT, "2"), | ||
] | ||
), | ||
] | ||
), | ||
And( | ||
[ | ||
Condition(Column("profiler_id"), Op.EQ, "2222"), | ||
And( | ||
[ | ||
Condition(Column("end_timestamp"), Op.GTE, "1"), | ||
Condition(Column("start_timestamp"), Op.LT, "2"), | ||
] | ||
), | ||
] | ||
), | ||
] | ||
) | ||
], | ||
), | ||
], | ||
) | ||
def test_get_chunk_snuba_conditions_from_spans_metadata(span_metadata, expected_condition): | ||
condition = get_chunk_snuba_conditions_from_spans_metadata(span_metadata) | ||
assert condition == expected_condition |