Extract method queryMetricRecords to remove duplication
Introduce and use constant for the reporting interval
Minimise quering while running in historical mode