From 3582c6aedcee14162217cd103092e6340a1c4741 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 14 Jun 2016 15:49:26 +0100 Subject: [PATCH] Track new Redis connections Increment the counter `new_redis_connections` on each call to `Redis::Client#connect`, if we're in a transaction. --- CHANGELOG | 1 + config/initializers/metrics.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2aed8eb322b..c00d478e43f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -22,6 +22,7 @@ v 8.9.0 (unreleased) - Reduce number of fog gem dependencies - Remove project notification settings associated with deleted projects - Fix 404 page when viewing TODOs that contain milestones or labels in different projects + - Add a metric for the number of new Redis connections created by a transaction - Redesign navigation for project pages - Fix groups API to list only user's accessible projects - Redesign account and email confirmation emails diff --git a/config/initializers/metrics.rb b/config/initializers/metrics.rb index f6509ee43f1..4bc6acdedb9 100644 --- a/config/initializers/metrics.rb +++ b/config/initializers/metrics.rb @@ -138,4 +138,20 @@ if Gitlab::Metrics.enabled? GC::Profiler.enable Gitlab::Metrics::Sampler.new.start + + module TrackNewRedisConnections + def connect(*args) + val = super + + if current_transaction = Gitlab::Metrics::Transaction.current + current_transaction.increment(:new_redis_connections, 1) + end + + val + end + end + + class ::Redis::Client + prepend TrackNewRedisConnections + end end