public void mergeHistograms ( MetricInfo metricInfo , String meta , Map < Integer , MetricSnapshot > data , Map < String , Integer > metaCounters , Map < String , Map < Integer , Histogram > > histograms ) { Map < Integer , MetricSnapshot > existing = metricInfo . get_metrics ( ) . get ( meta ) ; if ( existing == null ) { metricInfo . put_to_metrics ( meta , data ) ; Map < Integer , Histogram > histogramMap = new HashMap <> ( ) ; for ( Map . Entry < Integer , MetricSnapshot > dataEntry : data . entrySet ( ) ) { Histogram histogram = MetricUtils . metricSnapshot2Histogram ( dataEntry . getValue ( ) ) ; histogramMap . put ( dataEntry . getKey ( ) , histogram ) ; } histograms . put ( meta , histogramMap ) ; } else { for ( Map . Entry < Integer , MetricSnapshot > dataEntry : data . entrySet ( ) ) { Integer win = dataEntry . getKey ( ) ; MetricSnapshot snapshot = dataEntry . getValue ( ) ; MetricSnapshot old = existing . get ( win ) ; if ( old == null ) { existing . put ( win , snapshot ) ; histograms . get ( meta ) . put ( win , MetricUtils . metricSnapshot2Histogram ( snapshot ) ) ; } else { if ( snapshot . get_ts ( ) >= old . get_ts ( ) ) { old . set_ts ( snapshot . get_ts ( ) ) ; Histogram histogram = histograms . get ( meta ) . get ( win ) ; Snapshot updateSnapshot = histogram . getSnapshot ( ) ; if ( updateSnapshot instanceof JAverageSnapshot ) { sumMetricSnapshot ( ( ( JAverageSnapshot ) updateSnapshot ) . getMetricSnapshot ( ) , snapshot ) ; } else { // update points MetricUtils . updateHistogramPoints ( histogram , snapshot . get_points ( ) , snapshot . get_pointSize ( ) ) ; } } } } } updateMetricCounters ( meta , metaCounters ) ; }
histograms are sampled but we just update points