-
Notifications
You must be signed in to change notification settings - Fork 66
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
Helper function to build metric's name #25
Comments
I'm unsure this helper function is better than Could you provide a use case, where the |
Sprintf pattern is less discoverable and might be error-prone for the new users, however works in the same way. Have 0 will to argue further, so closing. |
You know what, I've a case where helper/builder func works better: codegen :) Instead of combining own helper package for 1 consumer or hacking codegen template, it can be as easy as What do you think? |
Yes, as many people have own build name func. |
Indeed, scanning through the code, I've not found labels sorting, looks like |
Yes, so i'm write own func like this https://github.com/unistack-org/micro-meter-victoriametrics/blob/master/victoriametrics.go#L25 |
I like usage like How I supposed to handle this in VMmetrics? |
write own func that get or create needed metric with labels =) |
link pr #27 |
Yes, this looks like a low-priority issue, which may be addressed in the future for all the fuctions accepting fully qualified metric name with labels. There is no need in adding BuildName function for resolving this issue. I'd propose leaving the BuildName function outside the github.com/VictoriaMetrics/metrics package, since:
|
Ok |
Having to write the helper to build the label values is currently one of the reasons why we did not start to migrate to metrics in all projects. Probably 90% of our metrics are using label values, which would all need to build the metrics name, so a helper is needed in every project. Not a big hassle, but enough to hold us back it seems. But if there is need to use a builder for nearly every project, it could be a useful addition to the metrics package to reduce overhead. So from a usability point of view for the developer I think it would be a welcome addition and could help adoption. Definitely a low prio issue of course. |
In case anyone is still looking for a performant, type-safe builder for VictoriaMetrics, I made this : https://github.com/wazazaby/vimebu. |
Hi, thank you for the lib it's great.
I have a proposition to add a helper function that creates a metric's name by it's name and labels. Current API for Counter(applies to other types too) expects a final name, like
foo{bar="baz",aaa="b"}
.Building such names is not that hard but it's repetitive work without sense (had to copy
buildName
helper 4 or so times between projects).Proposal: add
func BuildName(name string, labels ...string) string
that creates a valid Prometheus compatible name. Especially there is noerror
result, we can just panic if thelabels
variable isn't even (key-value, huh). However, it may return an error, not so hard too.Happy to make a PR for that. Thanks.
The text was updated successfully, but these errors were encountered: