Fix bySegment metrics de-serialization

Can you add typing in the function calls to prevent a general cast like this?