-
-
Notifications
You must be signed in to change notification settings - Fork 57
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(transactions): Add app_start_type migration #3124
Conversation
This PR has a migration; here is the generated SQL -- start migrations
-- forward migration transactions : 0017_transactions_add_app_start_type_column
Local operations:
ALTER TABLE transactions_local ADD COLUMN IF NOT EXISTS app_start_type LowCardinality(String) AFTER group_ids;
Dist operations:
ALTER TABLE transactions_dist ADD COLUMN IF NOT EXISTS app_start_type LowCardinality(String) AFTER group_ids;
-- end forward migration transactions : 0017_transactions_add_app_start_type_column
-- backward migration transactions : 0017_transactions_add_app_start_type_column
Local operations:
ALTER TABLE transactions_local DROP COLUMN IF EXISTS app_start_type;
Dist operations:
ALTER TABLE transactions_dist DROP COLUMN IF EXISTS app_start_type;
-- end backward migration transactions : 0017_transactions_add_app_start_type_column |
@evanh, are any further actions required to make that searchable in Discover? |
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.
Please separate the migration change from the other changes. Currently migrations in Snuba are run manually, so if this is merged in the current state inserts will start failing because the column doesn't exist on the table. The steps for adding a new column are:
- Open a migration PR and a second PR for the reading/writing changes.
- Merge the migration PR
- Someone from SnS will manually run the migration
- Merge the second PR.
are any further actions required to make that searchable in Discover?
The column also needs to be exposed in Sentry, via https://github.com/getsentry/sentry/blob/master/src/sentry/snuba/events.py
@@ -248,6 +248,8 @@ def _process_contexts_and_user( | |||
if context in contexts: | |||
del contexts[context] | |||
|
|||
processed["app_start_type"] = contexts["app"]["start_type"] |
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 this field guaranteed to always exist?
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.
No, definitely 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.
Ah, I just learned the difference between dict[key]
and dict.get(key)
. I'm new to Python.
snuba/datasets/entities/discover.py
Outdated
@@ -284,6 +284,7 @@ def attempt_map( | |||
] | |||
), | |||
), | |||
("app_start_type", String(Modifiers(nullable=True))), |
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.
I would add/modify an E2E test in test_snql_api.py
or test_snql_sdk_api.py
that ensures this column can be read correctly.
Thanks for the feedback, @evanh. I put everything together in one PR to be able to get feedback at one glance. I'm going to split the PR now. |
9e69fc3
to
14d59e0
Compare
Codecov ReportBase: 93.09% // Head: 93.09% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #3124 +/- ##
========================================
Coverage 93.09% 93.09%
========================================
Files 667 674 +7
Lines 30717 30908 +191
========================================
+ Hits 28595 28775 +180
- Misses 2122 2133 +11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Adds reading and writing to the app_start_type . For more context, see getsentry/sentry#36927. This PR is based on the migration PR #3124.
…getsentry/sentry#36927. This PR is based on the migration PR #3124.
Related to getsentry/snuba#3124 and getsentry/snuba#3127. Fixes GH-36927
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.
Please coordinate with the on-call in #discuss-eng-sns when you are ready to merge this, so that they can run the migration.
@@ -101,6 +101,7 @@ | |||
("transaction_source", String()), | |||
("timestamp", DateTime(Modifiers(readonly=True))), | |||
("group_ids", Array(UInt(64))), | |||
("app_start_type", String(Modifiers(readonly=True))), |
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.
Why do you add readonly=True
modifier to this column? Is this column going to be materialized? If not, I would recommend that you remove readonly=True
modifier
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.
What exactly do you mean by materialized
? I am OK with removing it.
table_name=table_name, | ||
column=Column( | ||
"app_start_type", | ||
String(Modifiers(low_cardinality=True)), |
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 app_start_type field user generated or machine generated? If it is machine generated and would have mostly a few values then having it as low_cardinality is ok. If it is user generated, what is the likelihood of having high cardinality of this value?
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.
The SDKs create these values, and it's not exposed to the user. Currently, we have four different values. The likelihood of this having a high cardinality is very low. Maybe it increases to 10 or 20 at some point, but not more than 100 for sure.
…getsentry/sentry#36927. This PR is based on the migration PR #3124.
Adds reading and writing to the app_start_type . For more context, see getsentry/sentry#36927. This PR is based on the migration PR #3124. PR in Sentry to expose this via Discover. getsentry/sentry#38548.
Related to getsentry/snuba#3124 and getsentry/snuba#3127. Only merge after snuba PRs are merged. Fixes GH-36927
Related to getsentry/snuba#3124 and getsentry/snuba#3127. Only merge after snuba PRs are merged. Fixes GH-36927
Adds the column app_start_type to transactions. For more context,
see getsentry/sentry#36927.