Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sentry/snuba/metrics/extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
RuleCondition = Union["LogicalRuleCondition", "ComparingRuleCondition", "NotRuleCondition"]

# Maps from Discover's field names to event protocol paths. See Relay's
# ``FieldValueProvider`` for supported fields. All fields need to be prefixed
# ``Getter`` implementation for ``Event`` for supported fields. All fields need to be prefixed
# with "event.".
# List of UI supported search fields is defined in sentry/static/app/utils/fields/index.ts
_SEARCH_TO_PROTOCOL_FIELDS = {
Expand Down Expand Up @@ -111,6 +111,7 @@
"transaction.op": "contexts.trace.op",
"http.status_code": "contexts.response.status_code",
"unreal.crash_type": "contexts.unreal.crash_type",
"profile.id": "contexts.profile.profile_id",
# Computed fields
"transaction.duration": "duration",
"release.build": "release.build",
Expand Down
24 changes: 24 additions & 0 deletions tests/sentry/snuba/test_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from sentry.snuba.dataset import Dataset
from sentry.snuba.metrics.extraction import (
OnDemandMetricSpec,
SearchQueryConverter,
apdex_tag_spec,
cleanup_query,
failure_tag_spec,
Expand Down Expand Up @@ -653,3 +654,26 @@ def test_to_standard_metrics_query(dirty, clean):
clean_tokens = parse_search_query(clean)

assert cleaned_up_tokens == clean_tokens


@pytest.mark.parametrize(
"query, expected",
[
(
"has:profile.id",
{
"op": "not",
"inner": {"op": "eq", "name": "event.contexts.profile.profile_id", "value": None},
},
),
(
"profile.id:abc123",
{"op": "eq", "name": "event.contexts.profile.profile_id", "value": "abc123"},
),
],
)
def test_search_query_converter(query, expected):
tokens = parse_search_query(query)
converter = SearchQueryConverter(tokens)
condition = converter.convert()
assert expected == condition