Stats: add metrics stats implementation
plain/json: use new metrics stats library
Merge pull request #316 from macbre/metrics-stats

Stats: add metrics stats implementation