-
-
Notifications
You must be signed in to change notification settings - Fork 62
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(profiles): Add a dataset to store profile chunks #5895
Merged
phacops
merged 20 commits into
master
from
pierre/continuous-profiling-dataset-migration
May 15, 2024
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b813c29
feat: Add DateTime64 column type
phacops c08623f
Add tests and validation
phacops 9f5d4e1
Add support for precision and timezone
phacops 41b5051
Fix typing
phacops efb88ce
Fix schema validation
phacops e0f5dd8
feat(profiles): Add a dataset to store profile chunks
phacops 3da03e1
Fix typo in column name
phacops b9b425c
Use microsecond precision
phacops 95dac57
Fix DateTime64 argument name and convert end_timestamp to DateTime in…
phacops dbba7e4
Hash profiler_id in sort key as it's a UUID and we need integers
phacops e4112c9
Use PROFILES storage set since it's going to be on the same cluster
phacops e09551c
Switch sample key to be based on chunk_id
phacops aaccc60
Remove unneeded constant
phacops 0a5af69
Fix wrong storage set for migration group
phacops fb419d4
Revert "Fix wrong storage set for migration group"
phacops 6520246
Revert "Use PROFILES storage set since it's going to be on the same c…
phacops 82964dd
Remove version column
phacops 3849033
Merge branch 'master' into pierre/continuous-profiling-dataset-migration
phacops 5ad30f7
Remove end_timestamp from the sort key
phacops 5f3f490
Merge branch 'master' into pierre/continuous-profiling-dataset-migration
phacops File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
snuba/snuba_migrations/profile_chunks/0001_create_profile_chunks_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
from typing import List, Sequence | ||
|
||
from snuba.clickhouse.columns import UUID, Column, DateTime64, UInt | ||
from snuba.clusters.storage_sets import StorageSetKey | ||
from snuba.migrations import migration, operations, table_engines | ||
from snuba.migrations.columns import MigrationModifiers as Modifiers | ||
from snuba.migrations.operations import OperationTarget, SqlOperation | ||
|
||
storage_set = StorageSetKey.PROFILE_CHUNKS | ||
phacops marked this conversation as resolved.
Show resolved
Hide resolved
|
||
table_prefix = "profile_chunks" | ||
local_table_name = f"{table_prefix}_local" | ||
dist_table_name = f"{table_prefix}_dist" | ||
|
||
columns: List[Column[Modifiers]] = [ | ||
Column("project_id", UInt(64)), | ||
Column("profiler_id", UUID()), | ||
Column("chunk_id", UUID()), | ||
phacops marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Column( | ||
"start_timestamp", | ||
DateTime64( | ||
phacops marked this conversation as resolved.
Show resolved
Hide resolved
|
||
precision=6, | ||
modifiers=Modifiers(codecs=["DoubleDelta"]), | ||
), | ||
), | ||
Column( | ||
"end_timestamp", | ||
DateTime64( | ||
precision=6, | ||
modifiers=Modifiers(codecs=["DoubleDelta"]), | ||
), | ||
), | ||
Column("retention_days", UInt(16)), | ||
Column("partition", UInt(16)), | ||
Column("offset", UInt(64)), | ||
] | ||
|
||
|
||
class Migration(migration.ClickhouseNodeMigration): | ||
blocking = False | ||
|
||
def forwards_ops(self) -> Sequence[SqlOperation]: | ||
return [ | ||
operations.CreateTable( | ||
storage_set=storage_set, | ||
table_name=local_table_name, | ||
columns=columns, | ||
engine=table_engines.ReplacingMergeTree( | ||
order_by="(project_id, profiler_id, start_timestamp, end_timestamp, cityHash64(chunk_id))", | ||
partition_by="(retention_days, toStartOfDay(start_timestamp))", | ||
sample_by="cityHash64(chunk_id)", | ||
settings={"index_granularity": "8192"}, | ||
storage_set=storage_set, | ||
ttl="toDateTime(end_timestamp) + toIntervalDay(retention_days)", | ||
), | ||
target=OperationTarget.LOCAL, | ||
), | ||
operations.CreateTable( | ||
storage_set=storage_set, | ||
table_name=dist_table_name, | ||
columns=columns, | ||
engine=table_engines.Distributed( | ||
local_table_name=local_table_name, | ||
sharding_key="cityHash64(profiler_id)", | ||
), | ||
target=OperationTarget.DISTRIBUTED, | ||
), | ||
] | ||
|
||
def backwards_ops(self) -> Sequence[SqlOperation]: | ||
return [ | ||
operations.DropTable( | ||
storage_set=storage_set, | ||
table_name=dist_table_name, | ||
target=OperationTarget.DISTRIBUTED, | ||
), | ||
operations.DropTable( | ||
storage_set=storage_set, | ||
table_name=local_table_name, | ||
target=OperationTarget.LOCAL, | ||
), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does the ClickHouse cluster already exist in SaaS (US + DE) and S4S? If the table is suppose to live the profiles cluster, has the
storage_set
been added there? If this isn't done yet, we should set the readiness state toReadinessState.LIMITED
for now so that GoCD doesn't try to run these migrations on a cluster that doesn't 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.
The ClickHouse cluster we'd use exists in all environments (
us
,de
,s4s
, all STs).I also have https://github.com/getsentry/ops/pull/10526 to configure it for all environments.
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.
+1
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.
which cluster are you using @phacops ?
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 cluster dedicated to profiling.