@ Nullable public static < T > T streamingRPCAndLog ( Logger logger , StreamingRpcCallable < T > callable , String methodName , String description , Object ... args ) { // avoid string format for better performance if debug is off String debugDesc = logger . isDebugEnabled ( ) ? String . format ( description , args ) : null ; try ( Timer . Context ctx = MetricsSystem . timer ( getQualifiedMetricName ( methodName ) ) . time ( ) ) { logger . debug ( "Enter: {}: {}" , methodName , debugDesc ) ; T result = callable . call ( ) ; logger . debug ( "Exit (OK): {}: {}" , methodName , debugDesc ) ; return result ; } catch ( Exception e ) { logger . warn ( "Exit (Error): {}: {}, Error={}" , methodName , String . format ( description , args ) , e ) ; MetricsSystem . counter ( getQualifiedFailureMetricName ( methodName ) ) . inc ( ) ; callable . exceptionCaught ( e ) ; } return null ; }
Handles a streaming RPC callable with logging .