protected Func1 < HttpClientResponse < ByteBuf > , Integer > withBookkeeping ( final int batchSize ) { return response -> { boolean ok = response . getStatus ( ) . code ( ) == 200 ; if ( ok ) { numMetricsSent . increment ( batchSize ) ; } else { LOGGER . info ( "Status code: {} - Lost {} metrics" , response . getStatus ( ) . code ( ) , batchSize ) ; numMetricsDroppedHttpErr . increment ( batchSize ) ; } return batchSize ; } ; }
Utility function to map an Observable&lt ; ByteBuf > to an Observable&lt ; Integer > while also updating our counters for metrics sent and errors .