Map<String, Map<String, List<TagsMetricsPair>>> makeMap(
       Collection<MetricsContext> contexts) throws IOException {
    Map<String, Map<String, List<TagsMetricsPair>>> map = 
      new TreeMap<String, Map<String, List<TagsMetricsPair>>>();

    for (MetricsContext context : contexts) {
      Map<String, List<TagsMetricsPair>> records = 
        new TreeMap<String, List<TagsMetricsPair>>();
      map.put(context.getContextName(), records);
    
      for (Map.Entry<String, Collection<OutputRecord>> r : 
          context.getAllRecords().entrySet()) {
        List<TagsMetricsPair> metricsAndTags = 
          new ArrayList<TagsMetricsPair>();
        records.put(r.getKey(), metricsAndTags);
        for (OutputRecord outputRecord : r.getValue()) {
          TagMap tagMap = outputRecord.getTagsCopy();
          MetricMap metricMap = outputRecord.getMetricsCopy();
          metricsAndTags.add(new TagsMetricsPair(tagMap, metricMap));
        }
      }
    }
    return map;
  }
Map < String , Map < String , List < TagsMetricsPair > > > makeMap ( Collection < MetricsContext > contexts ) throws IOException { Map < String , Map < String , List < TagsMetricsPair > > > map = new TreeMap < String , Map < String , List < TagsMetricsPair > > > ( ) ; for ( MetricsContext context : contexts ) { Map < String , List < TagsMetricsPair > > records = new TreeMap < String , List < TagsMetricsPair > > ( ) ; map . put ( context . getContextName ( ) , records ) ; for ( Map . Entry < String , Collection < OutputRecord > > r : context . getAllRecords ( ) . entrySet ( ) ) { List < TagsMetricsPair > metricsAndTags = new ArrayList < TagsMetricsPair > ( ) ; records . put ( r . getKey ( ) , metricsAndTags ) ; for ( OutputRecord outputRecord : r . getValue ( ) ) { TagMap tagMap = outputRecord . getTagsCopy ( ) ; MetricMap metricMap = outputRecord . getMetricsCopy ( ) ; metricsAndTags . add ( new TagsMetricsPair ( tagMap , metricMap ) ) ; } } } return map ; }
Collects all metric data, and returns a map:
contextName -> recordName -> [ (tag->tagValue), (metric->metricValue) ].
The values are either String or Number.  The final value is implemented
as a list of TagsMetricsPair.