proposal: exporter/prometheus: allow adding units to metrics names
See: https://github.com/census-instrumentation/opencensus-specs/issues/127
We should support easily adding units to metric names. Unfortunately, I don't think we can safely change the default outright but we can change all the examples and add documentation. Perhaps we can come up with a way to deprecate the current default and replace it with a better default in line with the deprecation policy.
From the specs issue, I suggested something like:
e := prometheus.NewExporter(..)
e.NameFormatter = func(v *view.View) string {
return fmt.Sprintf("%s_%s", v.Name, v.Unit)
}
We should also provide a recommended out-of-the-box NameFormatter that complies with https://prometheus.io/docs/practices/naming/#metric-names
Can we track feature requests like this on the specs repo? It has to be implemented in every language.
The original issue is in the specs repo. This is the Go-specific part.
https://github.com/census-instrumentation/opencensus-specs/issues/127 is only a proposal to add unit names.
If custom metric names are required, there needs a spec issue to track it. When a spec change is just proposed, it doesn't mean it is accepted. don't open issues on the language repos until a spec is accepted. Other contributors see an issue on this repo and try to contribute a change.
I understand the objection to changing the scope of this to allow complete customization of metric names. I have retitled this to focus on the bug, which is that we currently generate names that are not compatible with the recommended naming conventions in: https://prometheus.io/docs/practices/naming/#metric-names
My suggestion of allowing customization of metric names is only one solution to this problem. I can understand if you think this is too broad a solution. In that case, perhaps a more targeted solution to fix the issue in a backwards-compatible way would be fine. I do think that this is an issue with the Prometheus exporter for Go and so I am reopening.