feat(preprod): Add SizeAnalysisSubscription as a DataSource#108172
feat(preprod): Add SizeAnalysisSubscription as a DataSource#108172
Conversation
|
This PR has a migration; here is the generated SQL for for --
-- Create model SizeAnalysisSubscription
--
CREATE TABLE "sentry_sizeanalysissubscription" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "project_id" bigint NOT NULL);
ALTER TABLE "sentry_sizeanalysissubscription" ADD CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr" FOREIGN KEY ("project_id") REFERENCES "sentry_project" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "sentry_sizeanalysissubscription" VALIDATE CONSTRAINT "sentry_sizeanalysiss_project_id_41e3355e_fk_sentry_pr";
CREATE INDEX CONCURRENTLY "sentry_sizeanalysissubscription_project_id_41e3355e" ON "sentry_sizeanalysissubscription" ("project_id"); |
d557004 to
f240fcf
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
9eee476 to
873899f
Compare
36103e5 to
08778f5
Compare
|
|
||
|
|
||
| @data_source_type_registry.register(DATA_SOURCE_SIZE_ANALYSIS) | ||
| class SizeAnalysisDataSourceHandler(DataSourceTypeHandler["SizeAnalysisSubscription"]): |
There was a problem hiding this comment.
is there not some other models file for subscription / data source handlers that this should live in instead?
wedamija
left a comment
There was a problem hiding this comment.
Could you explain how data is coming in here? Is this doing something similar to metric alerts, where a query is running in snuba on a regular schedule and you're then processing the results?
944f145 to
e5b8172
Compare
@wedamija Sorry! Yeah was not the best description. No, the idea was that |
| class SizeAnalysisSubscription(DefaultFieldsModel): | ||
| __relocation_scope__ = RelocationScope.Excluded | ||
|
|
||
| project = FlexibleForeignKey("sentry.Project") |
There was a problem hiding this comment.
Are you planning to add any more to this model or is it just for the data source relationship?
If it's just for the data source, we could also omit this class if you wanted. Since the relationship is based on the project_id, we could just directly lookup the detectors w/o a data source and reduce the number of rows needed in the DB for these detectors. The only benefit for this relationship is some added caching layers for looking up detectors (it's only a 3min TTL, so probably wouldn't help too much for these detectors).
if you wanted to omit this class / the data source entirely, you could just create the Detector model, select the detectors by type + project_id, and then run process_detectors instead of process_data_packet.
There was a problem hiding this comment.
If we can get away without even better! I'll draft this one and go straight for #108208
Add
SizeAnalysisSubscriptionmodel as a DataSource for size monitors. Since we're pushingsize data from the monolith we know when we need to evaluate detectors and so can avoid
polling - however this means we also need our own subscription type rather than re-using
QuerySubscription.PRs: