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

Alerting: adapt sum of gauges to use options #584

Merged
merged 5 commits into from
Sep 23, 2024

Conversation

titolins
Copy link
Contributor

@titolins titolins commented Sep 20, 2024

To be able to filter 0 value gauges per tenant, we need to adapt the helper as it was done already before for other metrics.

Trying to follow the name convention, but not sure if we should introduce a new function instead. Despite being simple to adapt, it would require changes

@titolins titolins added the question Further information is requested label Sep 20, 2024
for _, tenantEntry := range d {
if tenantEntry.tenant == "" {
continue
}

result := singleValueWithLabelsMap{}
tenantEntry.metrics.sumOfSingleValuesWithLabels(metric, labelNames, gaugeValue, result.aggregateFn, false)
tenantEntry.metrics.sumOfSingleValuesWithLabels(metric, opts.labelNames, gaugeValue, result.aggregateFn, opts.skipZeroValueMetrics)
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add unit test showing that skipping of zero values works?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added now 👍


// SendSumOfGaugesPerTenantWithLabels provides metrics with the provided label names on a per-tenant basis. This function assumes that `tenant` is the
// first label on the provided metric Desc
func (d MetricFamiliesPerTenant) SendSumOfGaugesPerTenantWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, labelNames ...string) {
Copy link
Member

Choose a reason for hiding this comment

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

To avoid breaking clients, can we keep this function and reimplement it using SendSumOfGaugesPerTenant + WithLabels option? (We can mark it as deprecated if we want to get rid of it)

We can then also revert changes in the unit tests, to prove that function still works as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, no breaking changes then. Added it now and reverted unit tests also 👍

@titolins titolins requested a review from pstibrany September 23, 2024 10:39
Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Thank you. Can you add an enhancement changelog entry?

metrics/tenant_registries.go Outdated Show resolved Hide resolved
titolins and others added 2 commits September 23, 2024 14:21
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
@titolins
Copy link
Contributor Author

Thank you. Can you add an enhancement changelog entry?

Added now. Thanks for the review 🙌

@pstibrany
Copy link
Member

Thank you.

@pstibrany pstibrany merged commit 1f324b4 into main Sep 23, 2024
5 checks passed
@pstibrany pstibrany deleted the titolins/filter-am-zero-value-metrics branch September 23, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants