Fix traceback on publish of unicode metrics.

This bug was introduced by 0910b99 to fix ZEN-14618. Take more to sanitize
metrics. Include unit test.

Fixes ZEN-14650.