def end_request(req, collector_addr='<STR_LIT>', prefix='<STR_LIT>'):
req_end = time()<EOL>hreq = hash(req)<EOL>if hreq in requests:<EOL><INDENT>req_time = req_end - requests[hreq]<EOL>req_time *= <NUM_LIT:1000><EOL>del requests[hreq]<EOL>collector = get_context().socket(zmq.PUSH)<EOL>collector.connect(collector_addr)<EOL>collector.send_multipart([prefix, str(req_time)])<EOL>collector.close()<EOL>return req_time<EOL><DEDENT>
registers the end of a request

registers the end of a request, computes elapsed time, sends it to the collector

:param req: request, can be mostly any hash-able object
:param collector_addr: collector address, in zeromq format (string, default tcp://127.0.0.2:2345)
:param prefix: label under which to register the request (string, default my_app)