|
8 | 8 | from sentry.testutils.helpers import parse_link_header
|
9 | 9 | from tests.snuba.api.endpoints.test_organization_events import OrganizationEventsEndpointTestBase
|
10 | 10 |
|
| 11 | +# Downsampling is deterministic, so unless the algorithm changes we can find a known id that will appear in the |
| 12 | +# preflight and it will always show up |
| 13 | +# If we need to get a new ID just query for event ids after loading 100s of events and use any of the ids that come back |
| 14 | +KNOWN_PREFLIGHT_ID = "ca056dd858a24299" |
| 15 | + |
11 | 16 |
|
12 | 17 | class OrganizationEventsSpanIndexedEndpointTest(OrganizationEventsEndpointTestBase):
|
13 | 18 | is_eap = False
|
@@ -3522,3 +3527,66 @@ def test_filtering_null_numeric_attr(self):
|
3522 | 3527 | },
|
3523 | 3528 | ]
|
3524 | 3529 | assert meta["dataset"] == self.dataset
|
| 3530 | + |
| 3531 | + def test_preflight_request(self): |
| 3532 | + span = self.create_span( |
| 3533 | + {"description": "foo", "sentry_tags": {"status": "success"}}, |
| 3534 | + start_ts=self.ten_mins_ago, |
| 3535 | + ) |
| 3536 | + span["span_id"] = KNOWN_PREFLIGHT_ID |
| 3537 | + span2 = self.create_span( |
| 3538 | + {"description": "zoo", "sentry_tags": {"status": "success"}}, |
| 3539 | + start_ts=self.ten_mins_ago, |
| 3540 | + ) |
| 3541 | + span2["span_id"] = "b" * 16 |
| 3542 | + self.store_spans( |
| 3543 | + [span, span2], |
| 3544 | + is_eap=self.is_eap, |
| 3545 | + ) |
| 3546 | + response = self.do_request( |
| 3547 | + { |
| 3548 | + "field": ["id", "description", "count()"], |
| 3549 | + "query": "", |
| 3550 | + "orderby": "description", |
| 3551 | + "project": self.project.id, |
| 3552 | + "dataset": self.dataset, |
| 3553 | + "statsPeriod": "1h", |
| 3554 | + "sampling": "PREFLIGHT", |
| 3555 | + } |
| 3556 | + ) |
| 3557 | + |
| 3558 | + assert response.status_code == 200, response.content |
| 3559 | + assert len(response.data["data"]) == 1 |
| 3560 | + assert response.data["data"][0]["id"] == KNOWN_PREFLIGHT_ID |
| 3561 | + |
| 3562 | + def test_best_effort_request(self): |
| 3563 | + span = self.create_span( |
| 3564 | + {"description": "foo", "sentry_tags": {"status": "success"}}, |
| 3565 | + start_ts=self.ten_mins_ago, |
| 3566 | + ) |
| 3567 | + span["span_id"] = KNOWN_PREFLIGHT_ID |
| 3568 | + span2 = self.create_span( |
| 3569 | + {"description": "zoo", "sentry_tags": {"status": "success"}}, |
| 3570 | + start_ts=self.ten_mins_ago, |
| 3571 | + ) |
| 3572 | + span2["span_id"] = "b" * 16 |
| 3573 | + self.store_spans( |
| 3574 | + [span, span2], |
| 3575 | + is_eap=self.is_eap, |
| 3576 | + ) |
| 3577 | + response = self.do_request( |
| 3578 | + { |
| 3579 | + "field": ["id", "description", "count()"], |
| 3580 | + "query": "", |
| 3581 | + "orderby": "description", |
| 3582 | + "project": self.project.id, |
| 3583 | + "dataset": self.dataset, |
| 3584 | + "statsPeriod": "1h", |
| 3585 | + "sampling": "BEST_EFFORT", |
| 3586 | + } |
| 3587 | + ) |
| 3588 | + |
| 3589 | + assert response.status_code == 200, response.content |
| 3590 | + assert len(response.data["data"]) == 2 |
| 3591 | + assert response.data["data"][0]["id"] == KNOWN_PREFLIGHT_ID |
| 3592 | + assert response.data["data"][1]["id"] == "b" * 16 |
0 commit comments