From 0688b7eb6489e6ea0bf9f6e724c1baa3b5359a41 Mon Sep 17 00:00:00 2001 From: Michael Vandeberg Date: Wed, 25 Jan 2017 10:16:02 -0500 Subject: [PATCH] Time execution of rpc API call and log long executing calls. #9 --- src/rpc/websocket_api.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/websocket_api.cpp b/src/rpc/websocket_api.cpp index 0ff9304..efbb1d1 100644 --- a/src/rpc/websocket_api.cpp +++ b/src/rpc/websocket_api.cpp @@ -98,7 +98,15 @@ std::string websocket_api_connection::on_message( { try { + auto start = time_point::now(); auto result = _rpc_state.local_call( call.method, call.params ); + auto end = time_point::now(); + + if( end - start > fc::seconds( 1 ) ) + elog( "API call execution time limit exceeded.", ("method",call.method)("params",call.params)("time", end - start) ); + else if( end - start > fc::milliseconds( 750 ) ) + wlog( "API call execution time nearing limit.", ("method",call.method)("params",call.params)("time", end - start) ); + if( call.id ) { auto reply = fc::json::to_string( response( *call.id, result ) );