def normalize_prefix(prefix: str = "") -> str:
    clean_prefix = prefix.rstrip("_").strip()
    if not clean_prefix:
        return ""
    return f"{clean_prefix}_"


def add_prefix_to_metric_name(metric_name: str, prefix: str) -> str:
    prefix = normalize_prefix(prefix)
    return f"{prefix}{metric_name}"
