Browse Source

feat(on-demand): free text search support (#58345)

Ogi 1 year ago
parent
commit
04ebf8245f
2 changed files with 4 additions and 0 deletions
  1. 3 0
      src/sentry/snuba/metrics/extraction.py
  2. 1 0
      tests/sentry/snuba/test_extraction.py

+ 3 - 0
src/sentry/snuba/metrics/extraction.py

@@ -938,6 +938,9 @@ def _map_field_name(search_key: str) -> str:
     # Run a schema-aware check for tags. Always use the resolver output,
     # Run a schema-aware check for tags. Always use the resolver output,
     # since it accounts for passing `tags[foo]` as key.
     # since it accounts for passing `tags[foo]` as key.
     resolved = (resolve_column(Dataset.Transactions))(search_key)
     resolved = (resolve_column(Dataset.Transactions))(search_key)
+    if resolved == "transaction_name":
+        transaction_field = _SEARCH_TO_PROTOCOL_FIELDS.get("transaction")
+        return f"event.{transaction_field}"
     if resolved.startswith("tags["):
     if resolved.startswith("tags["):
         return f"event.tags.{resolved[5:-1]}"
         return f"event.tags.{resolved[5:-1]}"
 
 

+ 1 - 0
tests/sentry/snuba/test_extraction.py

@@ -83,6 +83,7 @@ class TestCreatesOndemandMetricSpec:
                 "apdex(10)",
                 "apdex(10)",
                 "",
                 "",
             ),  # apdex with specified threshold is on-demand metric even without query
             ),  # apdex with specified threshold is on-demand metric even without query
+            ("count()", "transaction.duration:>0 my-transaction"),
         ],
         ],
     )
     )
     def test_creates_on_demand_spec(self, aggregate, query):
     def test_creates_on_demand_spec(self, aggregate, query):