Skip to content
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

Merged
merged 2 commits into from
Sep 13, 2022
Merged

Conversation

philipphofmann
Copy link
Member

@philipphofmann philipphofmann commented Sep 7, 2022

Adds the column app_start_type to transactions. For more context,
see getsentry/sentry#36927.

@github-actions
Copy link

github-actions bot commented Sep 7, 2022

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

@philipphofmann
Copy link
Member Author

philipphofmann commented Sep 7, 2022

@evanh, are any further actions required to make that searchable in Discover?

Copy link
Member

@evanh evanh left a 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:

  1. Open a migration PR and a second PR for the reading/writing changes.
  2. Merge the migration PR
  3. Someone from SnS will manually run the migration
  4. 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"]
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, definitely not.

Copy link
Member Author

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.

@@ -284,6 +284,7 @@ def attempt_map(
]
),
),
("app_start_type", String(Modifiers(nullable=True))),
Copy link
Member

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.

@philipphofmann
Copy link
Member Author

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.

@codecov-commenter
Copy link

codecov-commenter commented Sep 8, 2022

Codecov Report

Base: 93.09% // Head: 93.09% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (3847067) compared to base (3d1084f).
Patch coverage: 100.00% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
snuba/datasets/storages/transactions_common.py 100.00% <ø> (ø)
snuba/migrations/groups.py 95.09% <ø> (ø)
...ons/0017_transactions_add_app_start_type_column.py 100.00% <100.00%> (ø)
snuba/datasets/storages/storage_key.py 96.77% <0.00%> (-3.23%) ⬇️
snuba/attribution/log.py 85.48% <0.00%> (-1.62%) ⬇️
snuba/redis.py 90.00% <0.00%> (ø)
tests/fixtures.py 100.00% <0.00%> (ø)
snuba/web/views.py 72.00% <0.00%> (ø)
tests/test_snql_api.py 100.00% <0.00%> (ø)
snuba/datasets/entities/replays.py 100.00% <0.00%> (ø)
... and 128 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@philipphofmann philipphofmann changed the title feat(transactions): Add app_start_type feat(transactions): Add app_start_type migration Sep 8, 2022
philipphofmann added a commit that referenced this pull request Sep 8, 2022
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.
philipphofmann added a commit that referenced this pull request Sep 8, 2022
@philipphofmann philipphofmann marked this pull request as ready for review September 8, 2022 09:18
@philipphofmann philipphofmann requested a review from a team as a code owner September 8, 2022 09:18
philipphofmann added a commit to getsentry/sentry that referenced this pull request Sep 8, 2022
@philipphofmann philipphofmann self-assigned this Sep 9, 2022
Copy link
Member

@evanh evanh left a 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))),
Copy link
Member

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

Copy link
Member Author

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)),
Copy link
Member

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?

Copy link
Member Author

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.

philipphofmann added a commit that referenced this pull request Sep 13, 2022
@onewland onewland merged commit 2d5817d into master Sep 13, 2022
@onewland onewland deleted the feat/app-start-type branch September 13, 2022 14:34
lynnagara pushed a commit that referenced this pull request Sep 22, 2022
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.
philipphofmann added a commit to getsentry/sentry that referenced this pull request Oct 14, 2022
barkbarkimashark pushed a commit to getsentry/sentry that referenced this pull request Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants