def convert_to_any_value(value: Any) -> AnyValue:
    """
    Converts a given value to an AnyValue object.
    This function takes a value of various types (str, bool, int, float, bytes,
    list, dict) and converts it into an AnyValue object. If the value is a list
    or a dictionary, it recursively converts the elements or key-value pairs.
    Tuples are converted into lists.
    Args:
        value:
            The value to be converted. It can be of type str, bool, int, float,
            bytes, list, tuple, or dict.
    Returns:
        The converted AnyValue object.
    """
    if isinstance(value, tuple):
        value = list(value)
    any_value = AnyValue()

    if isinstance(value, str):
        any_value.string_value = value
    elif isinstance(value, bool):
        any_value.bool_value = value
    elif isinstance(value, int):
        any_value.int_value = value
    elif isinstance(value, float):
        any_value.double_value = value
    elif isinstance(value, bytes):
        any_value.bytes_value = value
    elif isinstance(value, list):
        array_value = ArrayValue()
        for item in value:
            array_value.values.append(convert_to_any_value(item))
        any_value.array_value.CopyFrom(array_value)
    elif isinstance(value, dict):
        kv_list = KeyValueList()
        for k, v in value.items():
            kv = KeyValue(key=k, value=convert_to_any_value(v))
            kv_list.values.append(kv)
        any_value.kvlist_value.CopyFrom(kv_list)
    else:
        raise ValueError(f"Unsupported value type: {type(value)}")

    return any_value

    Converts a given value to an AnyValue object.
    This function takes a value of various types (str, bool, int, float, bytes,
    list, dict) and converts it into an AnyValue object. If the value is a list
    or a dictionary, it recursively converts the elements or key-value pairs.
    Tuples are converted into lists.
    Args:
        value:
            The value to be converted. It can be of type str, bool, int, float,
            bytes, list, tuple, or dict.
    Returns:
        The converted AnyValue object.
    
src/core/trulens/experimental/otel_tracing/core/exporter/utils.py