If I got that right you want to know the longest way (that’s the term used in OSM) with highway=* ? I’ve never needed that info. Are you sure that you don’t need the longest distance between two consecutive nodes?
Here is an overpass query to find highways with length > 10000 m
http://overpass-turbo.eu/s/13Hm
Way 521247731 in Spain has > 30 km