Use istio for dynamic traffic routing

I want to use istio for doing blue green deployment but i don’t want the traffic percentage to be static. I want it to be variable acccording to some logic i apply For example i want the logic to be http error count in both versions and the one with lower error count would get a higher traffic percentage. Can this be accomplished via some istio feature or has to be done manually?