Skip to content

Commit ba674cd

Browse files
authored
add support for profile.id (#60012)
1 parent 092f0ff commit ba674cd

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/sentry/snuba/metrics/extraction.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
RuleCondition = Union["LogicalRuleCondition", "ComparingRuleCondition", "NotRuleCondition"]
5656

5757
# Maps from Discover's field names to event protocol paths. See Relay's
58-
# ``FieldValueProvider`` for supported fields. All fields need to be prefixed
58+
# ``Getter`` implementation for ``Event`` for supported fields. All fields need to be prefixed
5959
# with "event.".
6060
# List of UI supported search fields is defined in sentry/static/app/utils/fields/index.ts
6161
_SEARCH_TO_PROTOCOL_FIELDS = {
@@ -111,6 +111,7 @@
111111
"transaction.op": "contexts.trace.op",
112112
"http.status_code": "contexts.response.status_code",
113113
"unreal.crash_type": "contexts.unreal.crash_type",
114+
"profile.id": "contexts.profile.profile_id",
114115
# Computed fields
115116
"transaction.duration": "duration",
116117
"release.build": "release.build",

tests/sentry/snuba/test_extraction.py

+24
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from sentry.snuba.dataset import Dataset
77
from sentry.snuba.metrics.extraction import (
88
OnDemandMetricSpec,
9+
SearchQueryConverter,
910
apdex_tag_spec,
1011
cleanup_query,
1112
failure_tag_spec,
@@ -653,3 +654,26 @@ def test_to_standard_metrics_query(dirty, clean):
653654
clean_tokens = parse_search_query(clean)
654655

655656
assert cleaned_up_tokens == clean_tokens
657+
658+
659+
@pytest.mark.parametrize(
660+
"query, expected",
661+
[
662+
(
663+
"has:profile.id",
664+
{
665+
"op": "not",
666+
"inner": {"op": "eq", "name": "event.contexts.profile.profile_id", "value": None},
667+
},
668+
),
669+
(
670+
"profile.id:abc123",
671+
{"op": "eq", "name": "event.contexts.profile.profile_id", "value": "abc123"},
672+
),
673+
],
674+
)
675+
def test_search_query_converter(query, expected):
676+
tokens = parse_search_query(query)
677+
converter = SearchQueryConverter(tokens)
678+
condition = converter.convert()
679+
assert expected == condition

0 commit comments

Comments
 (0)