-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(aci): Add serialized data source to issue occurrence evidence data #103549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aci): Add serialized data source to issue occurrence evidence data #103549
Conversation
e11375b to
dfebb5f
Compare
| ) | ||
| .select_related("workflow_condition_group") | ||
| .prefetch_related("workflow_condition_group__conditions") | ||
| .prefetch_related("workflow_condition_group__conditions", "data_sources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it okay to prefetch the data sources here as well? Or would it be better to wait and query for this when the occurrence is being generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably better to do the select when we're generating the issue occurrence.
we only create an occurrence / status change on like 0.5% of the evaluations so it's a bit more efficient to make a second select statement.
we also can't guarantee that other product areas will use this method. for example, uptime fetches their detectors separately, then directly calls process_detectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Pushed that change, we now query for the data source when building the evidence data.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #103549 +/- ##
===========================================
+ Coverage 80.09% 80.58% +0.48%
===========================================
Files 9256 9259 +3
Lines 395241 395378 +137
Branches 25207 25207
===========================================
+ Hits 316581 318609 +2028
+ Misses 78231 76340 -1891
Partials 429 429 |
| detector_id: int | ||
| data_packet_source_id: int | ||
| conditions: list[dict[str, Any]] | ||
| data_source_definition: dict[str, Any] | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also wanted to call out that I'm adding a property to this dataclass and I know python will raise an exception when instantiating if it doesn't exist. Is it safe to do this? Want to make sure this won't start failing for old event data when this is merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 it should be okay, but might want to set a default value to None to be safe.
afaik, we only apply this dataclass to the write on an issue occurrence, and when we're fetching for the API we just pass it through the serializer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay added a default value, but I agree I think it would probably be okay without one
| detector_id: int | ||
| data_packet_source_id: int | ||
| conditions: list[dict[str, Any]] | ||
| data_source_definition: dict[str, Any] | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 it should be okay, but might want to set a default value to None to be safe.
afaik, we only apply this dataclass to the write on an issue occurrence, and when we're fetching for the API we just pass it through the serializer.
| try: | ||
| data_source = DataSource.objects.filter( | ||
| detectors=self.detector, source_id=data_packet.source_id | ||
| ).first() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably allow this to have multiple data sources rather than limit to the first one. could we just serialize the list of data sources even though it'll generally only be 1? it might also help with debugging to see if there are multiple sources connected or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay makes sense - I thought that because this sent a source_id that meant that only one datasource should match, but if that's not the case the list makes sense. Updated
tests/sentry/notifications/notification_action/test_metric_alert_registry_handlers.py
Outdated
Show resolved
Hide resolved
saponifi3d
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woohoo! thanks for all those changes.
When viewing the issue details for a metric detector open period, we want to display the query which failed. This adds the serialized data source on the issue occurrence's
evidence_datafor this purpose. I've done this in a generalized way that should work across all detector types.