-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add multiple features and fix #39
Conversation
- Enable list metrics in vendor packages(--with-vendor) - List labels of metrics(if no labels, output `N/A') - Fix panic on --add-help if metric got no help info
The output example seems like this: TYPE NAME LABELS HELP
COUNTER http_api_signed_total api,method API signature count
COUNTER http_api_dropped_total api,method API request dropped when sinker rule match failed Labels are
And the JSON format like this: [
{
"Name": "http_api_dropped_total",
"Help": "API request dropped when sinker rule match failed",
"Type": "COUNTER",
"Filename": "/path/to/metrics.go",
"Labels": [
"api",
"method"
],
"Line": 105,
"Column": 3
},
{
"Name": "http_api_signed_total",
"Help": "API signature count",
"Type": "COUNTER",
"Filename": "/path/to/metrics.go",
"Labels": [
"api",
"method"
],
"Line": 118,
"Column": 3
}
] The markdown table seems like this: | TYPE | NAME | LABELS | HELP |
| --- | --- | --- | --- |
| COUNTER | `http_api_signed_total` | `api,method` | API signature count |
| COUNTER | `http_api_dropped_total` | `api,method` | API request dropped when sinker rule match failed | |
Thanks for the good work! @coanor Are you able to add some unit tests about the labels feature? |
- Fix duplicated metric name output
I find the PR can't find labels within |
I've add label discovery within Will you give me some hint about why the case failed? |
Print position(file name or path) in italic under markdown table output
It seems like the error case below was missing.
|
I've refactor and fixed the testings within promlinter_test.go, It seems that the issue's order not the key concerning. |
} | ||
|
||
if !opts.helpSet { | ||
currentMetric.Help = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this condition. We cannot set String to nil
I guess.
Line 327 should be enough to check if help is set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentMetric.Help
is type *string
, we just assign nil to mean "There is no help available". If we set a point to empty string(""
, here is line 327's opts.help
, it's default value is ""
), some exists test cases will fail(empty string still a valid help, but not make sense.).
I am ok to refactor the tests but I think it is still good to return ordered (at least order can be determined) issues from |
About the sort, I think we do not need to sort the result issue, because they are sorted already according to the AST traverse(And I removed the trailing For example, the raw issue list is(from testdata/testdata.go)
After sort(based on
Because string import (
T "testing"
"github.com/stretchr/testify/assert"
)
func TestStringOrder(t *T.T) {
assert.True(t, "a.go:123" < "a.go:99") // Pass
} |
Sorry for taking it for so long. I am going to merge it. Great work! Thanks |
--with-vendor
)N/A
(Add label-name list in exported output #37)--add-help
if metric got no help info, and also if no help outputN/A
Close #37/#38/#40.