Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Introduce a metric "resp_time_ms" to understand how long the neon-pro…
…xy make a response
  • Loading branch information
vasiliy-zaznobin committed Dec 21, 2021
commit fdb2bb0dfe33fdb2957aa7ad1964f1928eb56f6b
9 changes: 6 additions & 3 deletions proxy/plugin/solana_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import threading
import traceback
import unittest
import time

from ..common.utils import build_http_response
from ..http.codes import httpStatusCodes
Expand Down Expand Up @@ -618,7 +619,7 @@ def handle_request(self, request: HttpParser) -> None:
b'Access-Control-Max-Age': b'86400'
})))
return

start_time = time.time()
logger.debug('<<< %s 0x%x %s', threading.get_ident(), id(self.model), request.body.decode('utf8'))
response = None

Expand All @@ -639,8 +640,10 @@ def handle_request(self, request: HttpParser) -> None:
traceback.print_exc()
response = {'jsonrpc': '2.0', 'error': {'code': -32000, 'message': str(err)}}

logger.debug('>>> %s 0x%0x %s %s', threading.get_ident(), id(self.model), json.dumps(response),
request['method'] if 'method' in request else '---')
resp_time_ms = (time.time() - start_time)*1000 # convert this into milliseconds
logger.debug('>>> %s 0x%0x %s %s resp_time_ms= %s', threading.get_ident(), id(self.model), json.dumps(response),
request['method'] if 'method' in request else '---',
resp_time_ms)

self.client.queue(memoryview(build_http_response(
httpStatusCodes.OK, body=json.dumps(response).encode('utf8'),
Expand Down