private void analyze ( final List < Metric > metrics , final long elapsed , final Date now , final Date date ) { long diff = 0 ; boolean behind = false ; if ( now . before ( date ) ) { behind = true ; diff = date . getTime ( ) - now . getTime ( ) ; } else if ( now . after ( date ) ) { diff = now . getTime ( ) - date . getTime ( ) ; } Elapsed elapsedTime = new Elapsed ( diff , TimeUnit . MILLISECOND ) ; String msg = getMessage ( elapsedTime ) ; if ( diff > TimeUnit . SECOND . convert ( 1 ) ) { if ( behind ) { msg += "behind" ; } else { msg += "ahead" ; } } metrics . add ( new Metric ( "offset" , msg , new BigDecimal ( TimeUnit . MILLISECOND . convert ( diff , TimeUnit . SECOND ) ) , null , null ) ) ; metrics . add ( new Metric ( "time" , "" , new BigDecimal ( TimeUnit . MILLISECOND . convert ( elapsed , TimeUnit . SECOND ) ) , null , null ) ) ; }
Analizes the data and produces the metrics .