'Convert from CamelCase to camel_case
And substitute illegal metric characters'

def convert_to_underscore_separated(self, name):

    metric_name = self.FIRST_CAP_RE.sub('\\1_\\2', name)
    metric_name = self.ALL_CAP_RE.sub('\\1_\\2', metric_name).lower()
    metric_name = self.METRIC_REPLACEMENT.sub('_', metric_name)
    return self.DOT_UNDERSCORE_CLEANUP.sub('.', metric_name).strip('_')
