Resolve "Track the number of new Redis connections per transaction"
What does this MR do?
Add a new metric counter, new_redis_connections
, that contains the number of calls to Redis::Client#connect
in the current transaction.
Are there points in the code the reviewer needs to double check?
Not sure. I tested this in kind of a brute-force way:
- Add a debugger in the monkey-patched
connect
method. - With metrics enabled, start the app and load a page.
- The first Redis connection is created by
Rack::Attack
and isn't in a transaction, but still works fine. - The second Redis connection is within a transaction (the page load), and increments the counter.
- If I reload the page, neither debugger is hit.
- If I use a Redis client and do
CLIENT KILL
on my two existing clients, then reload the page, I get 3 and 4 again. - If I disable metrics collection, the debugger never gets hit.
Why was this MR needed?
We may have a Redis connection leak somewhere, so adding metrics will let us track this.
What are the relevant issue numbers?
Closes #18451 (closed).
Screenshots (if relevant)
Hahaha nope, not relevant.
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
API support added -
Tests -
Added for this feature/bug -
All builds are passing
-
-
Conform by the style guides -
Branch has no merge conflicts with master
(if you do - rebase it please) -
Squashed related commits together