Commit 2e8af16f authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'bw_optional_time_logging' into 'develop'

Implemented --log-request-times option which allows to enable request time...

See merge request !480
parents ce89b984 7f1a1137
......@@ -59,7 +59,8 @@ class Conf():
add('--test-disable-sync', type=strtobool, env_var='TEST_DISABLE_SYNC', help='(debug) skip sync and sweep; jump to block streaming', default=False)
add('--test-max-block', type=int, env_var='TEST_MAX_BLOCK', help='(debug) only sync to given block, for running sync test', default=None)
add('--test-profile', type=strtobool, env_var='TEST_PROFILE', help='(debug) profile execution', default=False)
add('--log-virtual-op-calls', type=strtobool, env_var='LOG_VIRTUAL_OP_CALLS', help='(debug) log virtual op calls and responses', default=False)
add('--log-request-times', env_var='LOG_REQUEST_TIMES', help='(debug) allows to generate log containing request processing times', action='store_true')
add('--log-virtual-op-calls', env_var='LOG_VIRTUAL_OP_CALLS', help='(debug) log virtual op calls and responses', default=False)
add('--mock-block-data-path', type=str, nargs='+', env_var='MOCK_BLOCK_DATA_PATH', help='(debug/testing) load additional data from block data file')
add('--mock-vops-data-path', type=str, env_var='MOCK_VOPS_DATA_PATH', help='(debug/testing) load additional data from virtual operations data file')
add('--community-start-block', type=int, env_var='COMMUNITY_START_BLOCK', default=37500000)
......
......@@ -202,8 +202,12 @@ def run_server(conf):
log = logging.getLogger(__name__)
# logger for storing Request processing times
req_res_log = logging.getLogger("Request-Process-Time-Logger")
conf_stdout_custom_file_logger(req_res_log, "./request_process_times.log")
req_res_log = None
if conf.get('log_request_times'):
req_res_log = logging.getLogger("Request-Process-Time-Logger")
conf_stdout_custom_file_logger(req_res_log, "./request_process_times.log")
methods = build_methods()
......@@ -314,17 +318,24 @@ def run_server(conf):
'Access-Control-Allow-Origin': '*'
}
ret = web.json_response(error_response, status=200, headers=headers, dumps=decimal_serialize)
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
if req_res_log is not None:
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
return ret
if response is not None and response.wanted:
headers = {
'Access-Control-Allow-Origin': '*'
}
ret = web.json_response(response.deserialized(), status=200, headers=headers, dumps=decimal_serialize)
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
if req_res_log is not None:
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
return ret
ret = web.Response()
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
if req_res_log is not None:
req_res_log.info("Request: {} processed in {:.4f}s".format(request, perf_counter() - t_start))
return ret
if conf.get('sync_to_s3'):
......
......@@ -61,6 +61,7 @@ start() {
DATABASE_URL="postgresql://${USER}@/${HIVEMIND_DB_NAME}?${OPTIONS}"
hive server \
--log-request-times \
--log-mask-sensitive-data \
--pid-file hive_server.pid \
--http-server-port ${RUNNER_HIVEMIND_SERVER_HTTP_PORT} \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment