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

Add created_for_pv label to unused_disk_size_bytes metric #95

Merged
merged 3 commits into from
May 21, 2024

Conversation

paulajulve
Copy link
Contributor

Adding this label to make my own life easier for a join I'm working on. I don't think it'll have much of an impact, since this metric already has the disk ID label, and the relationship between PV and disk should be 1 to 1. If I understand correctly, it should not affect current cardinality.

I've tested it out locally, but I don't really know how to add automated tests for the metrics in this file. Open to pointers if you have them, I think it'll be a nice improvement.

@inkel
Copy link
Collaborator

inkel commented Apr 18, 2024

I've tested it out locally, but I don't really know how to add automated tests for the metrics in this file. Open to pointers if you have them, I think it'll be a nice improvement.

This is tricky, I believe. In my point of view, you would be testing that Prometheus works on adding a label on a metric to the value that you're assigning, in other words, you would be testing Prometheus and not unused.

In any case, what would be needed instead is a test that proves that Meta.CreatedForPV returns what we expect, which if I'm not mistaken, is missing.

inkel
inkel previously approved these changes Apr 18, 2024
Copy link
Collaborator

@inkel inkel left a comment

Choose a reason for hiding this comment

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

LGTM but I'd like a few more reviewers to chime in before merging this.

@Pokom
Copy link
Contributor

Pokom commented Apr 18, 2024

This is tricky, I believe. In my point of view, you would be testing that Prometheus works on adding a label on a metric to the value that you're assigning, in other words, you would be testing Prometheus and not unused.

I don't think you're necessarily testing Prometheus. We went down down this path in cloudcost-exporter to ensure the metrics we export have the correct set of labels and values given a set of responses from cloud providers. My philosophy around it is that once people start using the exporter, we have a contract on the metrics and want to ensure we don't have regressions. I'd say it's more of an integration/end to end test? FWIW, I found this pattern from a few prometheus-community maintained exporters:

With that though, the tests can be brittle and we occasionally have flaky tests due to race conditions. I don't think in this case it's worth it to add tests validating the exported metrics align with expectations.

jjo
jjo previously approved these changes Apr 18, 2024
@paulajulve paulajulve force-pushed the paula/add-pv-name-to-disk-size-metric branch from ee0cb33 to d701500 Compare May 3, 2024 11:35
@paulajulve paulajulve dismissed stale reviews from inkel and jjo via a35e73a May 16, 2024 16:49
@paulajulve paulajulve force-pushed the paula/add-pv-name-to-disk-size-metric branch from d701500 to a35e73a Compare May 16, 2024 16:49
@paulajulve
Copy link
Contributor Author

There were a few tests missing for meta.go, so I've added them, even if not exactly within the scope of this PR. And cleaned up a function that wasn't being used, nor could be used across all three providers. My guess is it made sense in the first iteration of this project, but not now that it's mostly expected to work for all three major CSPs.

@paulajulve paulajulve requested review from inkel and jjo May 16, 2024 16:53
@paulajulve
Copy link
Contributor Author

paulajulve commented May 16, 2024

@Pokom agreed, I don't think this case warrants risking having to maintain brittle tests.

@paulajulve paulajulve merged commit 8e72cb9 into main May 21, 2024
3 checks passed
@paulajulve paulajulve deleted the paula/add-pv-name-to-disk-size-metric branch May 21, 2024 09:12
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.

4 participants