Moved the metrics message handling into the library.