public void emitRecord ( String contextName , String recordName , OutputRecord outRec ) throws IOException { Calendar currentDate = Calendar . getInstance ( ) ; if ( fileName != null ) { if ( currentDate . get ( Calendar . DAY_OF_MONTH ) != lastRecordDate . get ( Calendar . DAY_OF_MONTH ) ) { // rotate to a new context file file = new File ( getFullFileName ( currentDate ) ) ; if ( writer != null ) writer . close ( ) ; writer = new PrintWriter ( new FileWriter ( file , true ) ) ; } } writer . print ( recordDateFormat . format ( currentDate . getTime ( ) ) ) ; writer . print ( " " ) ; writer . print ( contextName ) ; writer . print ( "." ) ; writer . print ( recordName ) ; String separator = ": " ; for ( String tagName : outRec . getTagNames ( ) ) { writer . print ( separator ) ; separator = ", " ; writer . print ( tagName ) ; writer . print ( "=" ) ; writer . print ( outRec . getTag ( tagName ) ) ; } for ( String metricName : outRec . getMetricNames ( ) ) { writer . print ( separator ) ; separator = ", " ; writer . print ( metricName ) ; writer . print ( "=" ) ; writer . print ( outRec . getMetric ( metricName ) ) ; } writer . println ( ) ; lastRecordDate = currentDate ; }
Emits a metrics record to a file .