-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add deletion methods to clear data from TSDB. #5317
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6bbc92b
Add deletion methods to abstract TSDB backend.
tkaemming 77ef560
Add deletion methods to `RedisTSDB`
tkaemming dd92fa0
Factor out `get_active_series` method.
tkaemming 3213231
Add test coverage to `RedisTSDB`.
tkaemming 54fdc15
Add deletion methods to `DummyTSDB`.
tkaemming 1f07b72
Add deletion methods to `InMemoryTSDB`.
tkaemming 7cb738e
Fix bad copy/paste comment.
tkaemming 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -109,6 +109,14 @@ def timestamp(d): | |
| 2: 0, | ||
| } | ||
|
|
||
| self.db.delete([TSDBModel.project], [1, 2], dts[0], dts[-1]) | ||
|
|
||
| results = self.db.get_sums(TSDBModel.project, [1, 2], dts[0], dts[-1]) | ||
| assert results == { | ||
| 1: 0, | ||
| 2: 0, | ||
| } | ||
|
|
||
| def test_count_distinct(self): | ||
| now = datetime.utcnow().replace(tzinfo=pytz.UTC) - timedelta(hours=4) | ||
| dts = [now + timedelta(hours=i) for i in range(4)] | ||
|
|
@@ -211,6 +219,14 @@ def timestamp(d): | |
| assert self.db.get_distinct_counts_union(model, [1, 2], dts[0], dts[-1], rollup=3600) == 3 | ||
| assert self.db.get_distinct_counts_union(model, [2], dts[0], dts[-1], rollup=3600) == 0 | ||
|
|
||
| self.db.delete_distinct_counts([model], [1, 2], dts[0], dts[-1]) | ||
|
|
||
| results = self.db.get_distinct_counts_totals(model, [1, 2], dts[0], dts[-1]) | ||
| assert results == { | ||
| 1: 0, | ||
| 2: 0, | ||
| } | ||
|
|
||
| def test_frequency_tables(self): | ||
| now = datetime.utcnow().replace(tzinfo=pytz.UTC) | ||
| model = TSDBModel.frequent_projects_by_organization | ||
|
|
@@ -386,6 +402,22 @@ def test_frequency_tables(self): | |
| }, | ||
| } | ||
|
|
||
| self.db.delete_frequencies( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could be nice to have a test case where we delete just a sub-time-interval of the data and assert on the stuff that remains? current cases all just gut the dataset entirely unless I'm misreading something |
||
| [model], | ||
| ['organization:1', 'organization:2'], | ||
| now - timedelta(hours=1), | ||
| now, | ||
| ) | ||
|
|
||
| assert self.db.get_most_frequent( | ||
| model, | ||
| ('organization:1', 'organization:2'), | ||
| now, | ||
| ) == { | ||
| 'organization:1': [], | ||
| 'organization:2': [], | ||
| } | ||
|
|
||
| def test_frequency_table_import_export_no_estimators(self): | ||
| client = self.db.cluster.get_local_client_for_key('key') | ||
|
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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 worth trying to think "are we going to end up just deleting all keys in this hash?" and then just delete the whole toplevel hash key instead of each entry one by one, or is that not going to be happening much?