opencensus-go icon indicating copy to clipboard operation
opencensus-go copied to clipboard

proposal: exporter/prometheus: allow adding units to metrics names

Open semistrict opened this issue 7 years ago • 5 comments

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)
}

semistrict avatar Jul 09 '18 14:07 semistrict

We should also provide a recommended out-of-the-box NameFormatter that complies with https://prometheus.io/docs/practices/naming/#metric-names

semistrict avatar Jul 09 '18 17:07 semistrict

Can we track feature requests like this on the specs repo? It has to be implemented in every language.

rakyll avatar Jul 09 '18 21:07 rakyll

The original issue is in the specs repo. This is the Go-specific part.

semistrict avatar Jul 09 '18 23:07 semistrict

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.

rakyll avatar Jul 13 '18 20:07 rakyll

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.

semistrict avatar Jul 16 '18 22:07 semistrict