def parse_by_operator(pairs: str, operators: List[str]) -> Dict[str, str]:
    """
    Parses a comma-separated string of key-value segments where each segment
    can be split by one of multiple possible operators.
    For example:
        pairs_str = "foo:bar,baz=qux"
        operators = [":", "="]
    would return:
        {"foo": "bar", "baz": "qux"}

    :param pairs_str: Comma-separated string of key-value segments
    :param operators: List of possible operators (e.g., [":", "="])
    :return: Dictionary of parsed key-value pairs
    """

    if not pairs:
        return {}

    results: Dict[str, str] = {}
    segments = pairs.split(",")

    for segment in segments:
        segment = segment.strip()
        # If segment is empty, skip
        if not segment:
            continue

        # Find which operator appears first (lowest index) in this segment
        lowest_index = None
        chosen_operator = None

        for op in operators:
            idx = segment.find(op)
            if idx != -1 and (lowest_index is None or idx < lowest_index):
                lowest_index = idx
                chosen_operator = op

        # If none of the operators is found, skip or handle differently
        if chosen_operator is None:
            continue

        # Split once, using the chosen operator
        key, val = segment.split(chosen_operator, 1)
        results[key.strip()] = val.strip()

    return results

    Parses a comma-separated string of key-value segments where each segment
    can be split by one of multiple possible operators.
    For example:
        pairs_str = "foo:bar,baz=qux"
        operators = [":", "="]
    would return:
        {"foo": "bar", "baz": "qux"}

    :param pairs_str: Comma-separated string of key-value segments
    :param operators: List of possible operators (e.g., [":", "="])
    :return: Dictionary of parsed key-value pairs
    
playbooks/robusta_playbooks/prometheus_simulation.py