How to create a service which is not shared with other requests in mezzio-swoole

Does any one have create a service in mezzio-swoole (e.g a database connection service) which is isolated for a request?
I tried to create a custom mysqli class which extends mysqli in order to store some performance related information (e.g, total number of queries for a request, execution time for each query etc).
This information is shared for all the requests.
I read something for Factories as a service but do not know how to implement it.
mezzio-swoole offers amazing performance, but this shared issue makes the di-container useless.