def METHOD_NAME(event: BaseEvent, level: Optional[EventLevel] = None):
    msg_class_name = f"{type(event).__name__}Msg"
    msg_cls = getattr(types_pb2, msg_class_name)
    # level in EventInfo must be a string, not an EventLevel
    msg_level: str = level.value if level else event.level_tag().value
    assert msg_level is not None
    event_info = {
        "level": msg_level,
        "msg": event.message(),
        "invocation_id": get_invocation_id(),
        "extra": get_global_metadata_vars(),
        "ts": get_json_string_utcnow(),
        "pid": get_pid(),
        "thread": get_thread_name(),
        "code": event.code(),
        "name": type(event).__name__,
    }
    new_event = ParseDict({"info": event_info}, msg_cls())
    new_event.data.CopyFrom(event.pb_msg)
    return new_event