diff options
Diffstat (limited to 'lib/gitlab/diff/highlight_cache.rb')
-rw-r--r-- | lib/gitlab/diff/highlight_cache.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb index f950d01fdf0..8e9dc3a305f 100644 --- a/lib/gitlab/diff/highlight_cache.rb +++ b/lib/gitlab/diff/highlight_cache.rb @@ -193,6 +193,8 @@ module Gitlab results = redis.hmget(key, file_paths) end + record_hit_ratio(results) + results.map! do |result| Gitlab::Json.parse(gzip_decompress(result), symbolize_names: true) unless result.nil? end @@ -215,6 +217,11 @@ module Gitlab def current_transaction ::Gitlab::Metrics::WebTransaction.current end + + def record_hit_ratio(results) + current_transaction&.increment(:gitlab_redis_diff_caching_requests_total) + current_transaction&.increment(:gitlab_redis_diff_caching_hits_total) if results.any?(&:present?) + end end end end |