Skip to content

Commit d7fce8d

Browse files
authored
ref(eap): Create a constant for the EAP insert items endpoint path (#103780)
Follow-up to #103566. Fixes [ID-1112](https://linear.app/getsentry/issue/ID-1112/extract-testsentitieseap-itemsinsert-bytes-endpoint-name-out-into-a). No change in logic; creates a constant for the EAP insert items endpoint path ("/tests/entities/eap_items/insert_bytes") in a new utils file `src/sentry/utils/eap.py`.
1 parent 205ae6c commit d7fce8d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src/sentry/eventstream/snuba.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from sentry.options.rollout import in_rollout_group
1919
from sentry.services.eventstore.models import GroupEvent
2020
from sentry.utils import json, metrics, snuba
21+
from sentry.utils.eap import EAP_ITEMS_INSERT_ENDPOINT
2122
from sentry.utils.safe import get_path
2223
from sentry.utils.sdk import set_current_event_project
2324

@@ -498,7 +499,7 @@ def _send_item(self, trace_item: TraceItem) -> None:
498499
try:
499500
resp = snuba._snuba_pool.urlopen(
500501
"POST",
501-
"/tests/entities/eap_items/insert_bytes",
502+
EAP_ITEMS_INSERT_ENDPOINT,
502503
fields={"item_0": trace_item.SerializeToString()},
503504
)
504505

src/sentry/replays/lib/eap/write.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sentry.conf.types.kafka_definition import Topic
1414
from sentry.replays.lib.eap.snuba_transpiler import TRACE_ITEM_TYPE_MAP, TRACE_ITEM_TYPES
1515
from sentry.replays.lib.kafka import EAP_ITEMS_CODEC, eap_producer
16+
from sentry.utils.eap import EAP_ITEMS_INSERT_ENDPOINT
1617
from sentry.utils.kafka_config import get_topic_definition
1718

1819
Value = bool | bytes | str | int | float | Sequence["Value"] | MutableMapping[str, "Value"]
@@ -86,7 +87,7 @@ def write_trace_items_test_suite(trace_items: list[EAPTraceItem]) -> None:
8687
`docker logs -f snuba-snuba-1`
8788
"""
8889
response = requests.post(
89-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
90+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
9091
files={
9192
f"item_{i}": trace_item.SerializeToString() for i, trace_item in enumerate(trace_items)
9293
},

src/sentry/testutils/cases.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
from sentry.users.models.useremail import UserEmail
152152
from sentry.utils import json
153153
from sentry.utils.auth import SsoSession
154+
from sentry.utils.eap import EAP_ITEMS_INSERT_ENDPOINT
154155
from sentry.utils.json import dumps_htmlsafe
155156
from sentry.utils.not_set import NOT_SET, NotSet, default_if_not_set
156157
from sentry.utils.samples import load_data
@@ -1147,7 +1148,7 @@ def store_spans(self, spans, is_eap=False):
11471148
files[f"item_{i}"] = trace_item.SerializeToString()
11481149
assert (
11491150
requests.post(
1150-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
1151+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
11511152
files=files,
11521153
).status_code
11531154
== 200
@@ -1164,7 +1165,7 @@ def store_spans(self, spans, is_eap=False):
11641165
def store_ourlogs(self, ourlogs):
11651166
files = {f"log_{i}": log.SerializeToString() for i, log in enumerate(ourlogs)}
11661167
response = requests.post(
1167-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
1168+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
11681169
files=files,
11691170
)
11701171
assert response.status_code == 200
@@ -1175,7 +1176,7 @@ def store_trace_metrics(self, trace_metrics):
11751176
for i, trace_metric in enumerate(trace_metrics)
11761177
}
11771178
response = requests.post(
1178-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
1179+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
11791180
files=files,
11801181
)
11811182
assert response.status_code == 200
@@ -1186,7 +1187,7 @@ def store_profile_functions(self, profile_functions):
11861187
for i, profile_function in enumerate(profile_functions)
11871188
}
11881189
response = requests.post(
1189-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
1190+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
11901191
files=files,
11911192
)
11921193
assert response.status_code == 200
@@ -2266,7 +2267,7 @@ def store_spans(self, spans, is_eap=False):
22662267
files[f"item_{i}"] = trace_item.SerializeToString()
22672268
assert (
22682269
requests.post(
2269-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
2270+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
22702271
files=files,
22712272
).status_code
22722273
== 200
@@ -3897,7 +3898,7 @@ def store_replays_eap(self, replays):
38973898

38983899
files = {f"replay_{i}": replay.SerializeToString() for i, replay in enumerate(replays)}
38993900
response = requests.post(
3900-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
3901+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
39013902
files=files,
39023903
)
39033904
assert response.status_code == 200
@@ -4044,7 +4045,7 @@ def store_uptime_results(self, uptime_results):
40444045
f"uptime_{i}": result.SerializeToString() for i, result in enumerate(uptime_results)
40454046
}
40464047
response = requests.post(
4047-
settings.SENTRY_SNUBA + "/tests/entities/eap_items/insert_bytes",
4048+
settings.SENTRY_SNUBA + EAP_ITEMS_INSERT_ENDPOINT,
40484049
files=files,
40494050
)
40504051
assert response.status_code == 200

src/sentry/utils/eap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EAP_ITEMS_INSERT_ENDPOINT = "/tests/entities/eap_items/insert_bytes"

0 commit comments

Comments
 (0)