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
Prev Previous commit
Next Next commit
Introduced a metric "resp_time_ms" to understand how long the neon-pr…
…oxy make a response (#401)

* Introduced a metric "resp_time_ms" to understand how long the neon-proxy make a response #401
  • Loading branch information
vasiliy-zaznobin authored Dec 21, 2021
commit 09624a6254ae051b0100d270b4810ae966e91b4d
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.get('method', '---'),
resp_time_ms)

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