Commit b4dcc665 authored by Kerri Miller's avatar Kerri Miller

Define a memory usage histogram for diff caching

Defines a memory usage histogram for eventually tracking the size of
highlighted diffs placed in the redis cache.
parent 3ee4aa9c
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
module Gitlab module Gitlab
module Diff module Diff
class HighlightCache class HighlightCache
include Gitlab::Metrics::Methods
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
EXPIRATION = 1.week EXPIRATION = 1.week
...@@ -11,6 +12,11 @@ module Gitlab ...@@ -11,6 +12,11 @@ module Gitlab
delegate :diffable, to: :@diff_collection delegate :diffable, to: :@diff_collection
delegate :diff_options, to: :@diff_collection delegate :diff_options, to: :@diff_collection
define_histogram :gitlab_redis_diff_caching_memory_usage_bytes do
docstring 'Redis diff caching memory usage by key'
buckets [100, 1000, 10000, 100000, 1000000, 10000000]
end
def initialize(diff_collection) def initialize(diff_collection)
@diff_collection = diff_collection @diff_collection = diff_collection
end end
......
...@@ -154,4 +154,10 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do ...@@ -154,4 +154,10 @@ describe Gitlab::Diff::HighlightCache, :clean_gitlab_redis_cache do
cache.clear cache.clear
end end
end end
describe 'metrics' do
it 'defines :gitlab_redis_diff_caching_memory_usage_bytes histogram' do
expect(described_class).to respond_to(:gitlab_redis_diff_caching_memory_usage_bytes)
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment