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 support for custom validations in promlint #1311

Conversation

machadovilaca
Copy link
Contributor

No description provided.

Signed-off-by: João Vilaça <jvilaca@redhat.com>
Signed-off-by: João Vilaça <jvilaca@redhat.com>
@machadovilaca machadovilaca force-pushed the add_support_for_custom_promlint_validations branch from e6697f3 to 83b0350 Compare July 13, 2023 23:38
@machadovilaca
Copy link
Contributor Author

/cc @bwplotka @kakkoyun

Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

I like this idea, but wonder if we have to break compatibility here. If we can let's avoid it - once this is sorted will review closer (:

)

// CollectAndLint registers the provided Collector with a newly created pedantic
// Registry. It then calls GatherAndLint with that Registry and with the
// provided metricNames.
func CollectAndLint(c prometheus.Collector, metricNames ...string) ([]promlint.Problem, error) {
func CollectAndLint(c prometheus.Collector, metricNames ...string) ([]validations.Problem, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we avoid this?

client_golang is 1.0 and generally we can't break compatibility.

testutil might be experimental (?) - not sure if we ever mentioned it's compatibility level, but if we can-- let's not break the compatibility here. Let's move Problem back to promlint and work from there (perhaps that might require validations to be promlint package).

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand your concerns, I will update it and see if I can get a clean solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bwplotka updated

Signed-off-by: João Vilaça <jvilaca@redhat.com>
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks! Epic 💪🏽

for i, t := range dto.MetricType_name {
if i == int32(dto.MetricType_UNTYPED) {
continue
for _, fn := range defaultValidations {
Copy link
Member

Choose a reason for hiding this comment

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

Why, why not merging those slices (default and custom) and not repeating the code?

Not a blocker, that's the only nit I would improve, merging anyway.

@bwplotka
Copy link
Member

Thanks! I would also recommend adding useful validators to our repo (:

@bwplotka bwplotka merged commit 60a8513 into prometheus:main Oct 10, 2023
7 checks passed
@machadovilaca machadovilaca deleted the add_support_for_custom_promlint_validations branch October 10, 2023 09:44
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.

None yet

2 participants