Fix carbon2 serializer not falling through to field separate when carbon2_format field is unset#8201
Conversation
…bon2_format field is unset
| format: Carbon2FormatFieldSeparate, | ||
| expected: fmt.Sprintf("metric=cpu field=usage_idle cpu=cpu0 91.5 %d\n", now.Unix()), | ||
| }, | ||
| { |
There was a problem hiding this comment.
It doesn't make sense to me to duplicate the tests here. Empty doesn't provide different functionality than Separate. It would be simpler to change NewSerializer so that if metricsFormat argument is empty string then it returns a Serializer with metricsformat Carbon2FormatFieldSeparate. Then you could remove Carbon2FormatFieldEmpty altogether. Then you'd only need a single test that NewSerializer("") returns a Serializer with metricsFormat of Carbon2FormatFieldSeparate.
There was a problem hiding this comment.
Ok, sure.
So I've made Carbon2FormatFieldEmpty unexported (i.e. carbon2FormatFieldEmpty) and with this the only place where we need to check for empty string is the constructor as it's impossible to pass format("") even in SetMetricsFormat() because of format being unexported as well.
…bon2_format field is unset (influxdata#8201)
When
carbon2_formatis unspecified or is specified as empty string there's a missingfallthroughwhich makes carbon2 serializer not produce metric names at all (noop case inswitch).This PR addresses that and adds a handful of tests for that case.
Required for all PRs: