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

tsdb: Add MustIndex() function to Head #811

Merged
merged 5 commits into from
Jan 2, 2025
Merged

tsdb: Add MustIndex() function to Head #811

merged 5 commits into from
Jan 2, 2025

Conversation

ying-jeanne
Copy link
Contributor

In the context of cost attribution in this PR #10269, I need to retrieve the index to decrement the active series count when a series goes out of the 20-minute active series window. Since the current Index() function does not return an error, we propose introducing a new function, MustIndex(), which will never return an error. Additionally, I will add tests to ensure that both functions return the same results.

Comment on lines 40 to 43
func (h *Head) MustIndex() IndexReader {
return h.indexRange(math.MinInt64, math.MaxInt64)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, we don't have a policy on this yet, but can you create a new file, called head_read_mimir.go and put this method there? This way we'll avoid a bunch of confclicting updates with upstream in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 7a70886

Comment on lines 431 to 433

irMust := h.MustIndex()
require.Equal(t, irMust, ir)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go in a separate test (also as noted above, in a separate file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in 7a70886

@ying-jeanne ying-jeanne requested a review from colega December 31, 2024 10:22
CHANGELOG.md Outdated
@@ -4,6 +4,7 @@

* [CHANGE] Notifier: Increment the prometheus_notifications_errors_total metric by the number of affected alerts rather than by one per batch of affected alerts. #15428
* [ENHANCEMENT] OTLP receiver: Convert also metric metadata. #15416
* [ENHANCEMENT] Introduced MustIndex() as a variant of Index() in tsdb Head that does not return an error. #811
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't update the changelog in mimir-prometheus, please remove this, otherwise it will be just a source of merge conflicts in the future.

@colega
Copy link
Contributor

colega commented Jan 2, 2025

Approved modulo the changelog nit, please address it before merging.

@ying-jeanne ying-jeanne enabled auto-merge January 2, 2025 14:19
@ying-jeanne ying-jeanne merged commit 0c24d16 into main Jan 2, 2025
7 checks passed
@ying-jeanne ying-jeanne deleted the add-must-index branch January 2, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants