feat: support dequeue event to properly match enqueue counterpart #2250
+11
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on current event exposed, we can hook to
"connecttion" -> to know when a new connection is created in the pool
"acquire" -> to know when a connection was acquired from the pool
"release" -> to know when a connection was released back into the pool
"enqueue" -> to know when a query was sent to the pool and went to the queue to be processed later. ( > connectionLimit )
The problem arise when we want to know how the queue is doing. it's either going up and up and up with the enqueue event OR we can assume the queue is 0 when "release" is triggered.
Proposed change; a new "dequeue" event that is triggered every time a query is taken from "_connectionQueue" in the pool. This way metrics can be correctly plugged into mysql2 to know how fast the queue is unstacking.
Code to reproduce before and after the fix
Logs that are shown before proposed changed
logs after the proposed fix :