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

Feature plans #3

Open
yeya24 opened this issue Jul 22, 2020 · 8 comments
Open

Feature plans #3

yeya24 opened this issue Jul 22, 2020 · 8 comments

Comments

@yeya24
Copy link
Owner

yeya24 commented Jul 22, 2020

Now this linter can work, but it is not good. It only has some very basic features.

What it cannot support:

  1. Metrics opt field is from some identifiers like var, const, or from other packages.
  2. Functions. Like we can use when creating new xxxOpts, but we cannot do it in this tool since that function can only be executed at runtime.
Help: fmt.Sprintf("%s", aaa)
  1. Getting metrics information from prometheus.Desc, it is doable, but we need to parse ch <- prometheus.MustNewConstMetric as well, otherwise we cannot get the correct metric type.

  2. Support outputting the position (filename, column and row) of the bad metric

@yeya24
Copy link
Owner Author

yeya24 commented Jul 22, 2020

But this tool can already be used in linting metrics names. For example, I did a test for Cortex.

promlinter .

cortex_cache_fetched_keys: counter metrics should have "_total" suffix
cortex_cache_hits: counter metrics should have "_total" suffix
cortex_purger_pending_delete_requests_count: non-histogram and non-summary metrics should not have "_count" suffix
cortex_ingester_received_chunks: counter metrics should have "_total" suffix
cortex_ingester_received_files: counter metrics should have "_total" suffix
cortex_ingester_sent_chunks: counter metrics should have "_total" suffix
cortex_ingester_sent_files: counter metrics should have "_total" suffix
memberlist_client_watch_prefix_dropped_notifications: counter metrics should have "_total" suffix
cortex_ruler_managers_total: non-counter metrics should not have "_total" suffix

@yeya24
Copy link
Owner Author

yeya24 commented Jul 22, 2020

Step 3 and 4 is done.

@roidelapluie
Copy link

Is checking that metrics are actually registered supported?

@yeya24
Copy link
Owner Author

yeya24 commented Jul 23, 2020

Is checking that metrics are actually registered supported?

Hello, it is not supported and I haven't think of it. It would be complicated because there are a lot of patterns to register metrics. It would be great if you could share some ideas!

@roidelapluie
Copy link

Is checking that metrics are actually registered supported?

Hello, it is not supported and I haven't think of it. It would be complicated because there are a lot of patterns to register metrics. It would be great if you could share some ideas!

That's also why it is sometimes forgotten :)

@sayboras
Copy link

sayboras commented Aug 7, 2020

Just quickly try this, I would like to highlight some issues i have right now, keen to hear your thought.

parsing Namespace with type *ast.SelectorExpr is not supported
parsing desc of type *ast.SelectorExpr is not supported

@yeya24
Copy link
Owner Author

yeya24 commented Aug 7, 2020

Just quickly try this, I would like to highlight some issues i have right now, keen to hear your thought.

parsing Namespace with type *ast.SelectorExpr is not supported
parsing desc of type *ast.SelectorExpr is not supported

@sayboras Hey, thanks for the feedback. That's a problem for me as well. It is common to use const values from other packages like conf.Namespace when defining metrics.

TBH, I am quite new to golang static linting and I don't know how to get the const or var values from other packages. It would be good if you could help or give some ideas. Thanks!

@yeya24
Copy link
Owner Author

yeya24 commented Aug 7, 2020

But this linter should work well in most cases when defining metrics using string literals. Like the metrics in the testcase https://github.com/yeya24/promlinter/blob/master/testdata/testdata.go

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

No branches or pull requests

3 participants