Browse Source

fix(eventstream): Fix inserting transactions to the SnubaEventStream (#34154)

Transactions should not be posted to both "transactions" and "events".
This was a relic from the past when events and transactions shared
a database table but this hasn't been the case for over a year now.

This backend is only used for tests / dev.
Lyn Nagara 2 years ago
parent
commit
3448195ea6
1 changed files with 10 additions and 16 deletions
  1. 10 16
      src/sentry/eventstream/snuba.py

+ 10 - 16
src/sentry/eventstream/snuba.py

@@ -336,24 +336,18 @@ class SnubaEventStream(SnubaProtocolEventStream):
 
 
         data = (self.EVENT_PROTOCOL_VERSION, _type) + extra_data
         data = (self.EVENT_PROTOCOL_VERSION, _type) + extra_data
 
 
-        # TODO remove this once the unified dataset is available.
-        # Inserting into both events and transactions datasets lets us
-        # simulate what is currently happening via kafka when both the events
-        # and transactions consumers are running.
-        datasets = ["events"]
+        dataset = "events"
         if get_path(extra_data, 0, "data", "type") == "transaction":
         if get_path(extra_data, 0, "data", "type") == "transaction":
-            datasets.append("transactions")
+            dataset = "transactions"
         try:
         try:
-            resp = None
-            for dataset in datasets:
-                resp = snuba._snuba_pool.urlopen(
-                    "POST",
-                    f"/tests/{dataset}/eventstream",
-                    body=json.dumps(data),
-                    headers={f"X-Sentry-{k}": v for k, v in headers.items()},
-                )
-                if resp.status != 200:
-                    raise snuba.SnubaError("HTTP %s response from Snuba!" % resp.status)
+            resp = snuba._snuba_pool.urlopen(
+                "POST",
+                f"/tests/{dataset}/eventstream",
+                body=json.dumps(data),
+                headers={f"X-Sentry-{k}": v for k, v in headers.items()},
+            )
+            if resp.status != 200:
+                raise snuba.SnubaError("HTTP %s response from Snuba!" % resp.status)
             return resp
             return resp
         except urllib3.exceptions.HTTPError as err:
         except urllib3.exceptions.HTTPError as err:
             raise snuba.SnubaError(err)
             raise snuba.SnubaError(err)