feat(CapMan): Eventstore query tenant_ids#45550
Conversation
…/querybuilder_tenant_ids
| query: QueryDefinition, tenant_ids: dict[str, Any] | None = None | ||
| query: QueryDefinition, | ||
| tenant_ids: dict[str, Any] | None = None, | ||
| referrer: str = "outcomes.timeseries", | ||
| ) -> ResultSet: | ||
| """ | ||
| Runs an outcomes query. By default the referrer is `outcomes.timeseries` and this should not change | ||
| unless there is a very specific reason to do so. Eg. getsentry uses this function for billing | ||
| metrics, so the referrer is different as it's no longer a "product" query. | ||
| """ |
There was a problem hiding this comment.
I can PR this separately but it's a quick change not very relevant to the entire PR. Previously, I added tenant_ids to all outcomes.timeseries and outcomes.totals queries but I was still seeing timeseries queries coming without this data. Turns out this function is used in getsentry for a billing metric, and there should should really be a different referrer for that use case, so I made referrer an optional param with a quick description of why.
JoshFerge
left a comment
There was a problem hiding this comment.
everything looks okay to me except for the one in reprocessing2
src/sentry/tasks/reprocessing2.py
Outdated
| batch_size=settings.SENTRY_REPROCESSING_PAGE_SIZE, | ||
| state=query_state, | ||
| referrer="reprocessing2.reprocess_group", | ||
| tenant_ids={"organization_id": models.Project.objects.get(id=project_id).organization_id}, |
There was a problem hiding this comment.
this one could be problematic as this is an ingest flow. would check with @untitaker on if this is okay to do here.
There was a problem hiding this comment.
reprocessing is not perf sensitive, but if you can, use get_from_cache across the board just because it's low-effort
Overview
tenant_idstenant_idsto Snuba #44788 for more context