Class: Gitlab::Cache::Metrics
- Inherits:
-
Object
- Object
- Gitlab::Cache::Metrics
- Defined in:
- lib/gitlab/cache/metrics.rb
Constant Summary collapse
- DEFAULT_BUCKETS =
[0, 1, 5].freeze
Instance Method Summary collapse
-
#increment_cache_hit(labels = {}) ⇒ Object
Increase cache hit counter.
-
#increment_cache_miss(labels = {}) ⇒ Object
Increase cache miss counter.
-
#initialize(cache_metadata) ⇒ Metrics
constructor
A new instance of Metrics.
-
#observe_cache_generation(labels = {}, &block) ⇒ Object
Measure the duration of cacheable action.
Constructor Details
#initialize(cache_metadata) ⇒ Metrics
Returns a new instance of Metrics.
9 10 11 |
# File 'lib/gitlab/cache/metrics.rb', line 9 def initialize() @cache_metadata = end |
Instance Method Details
#increment_cache_hit(labels = {}) ⇒ Object
Increase cache hit counter
15 16 17 |
# File 'lib/gitlab/cache/metrics.rb', line 15 def increment_cache_hit(labels = {}) counter.increment(base_labels.merge(labels, cache_hit: true)) end |
#increment_cache_miss(labels = {}) ⇒ Object
Increase cache miss counter
21 22 23 |
# File 'lib/gitlab/cache/metrics.rb', line 21 def increment_cache_miss(labels = {}) counter.increment(base_labels.merge(labels, cache_hit: false)) end |
#observe_cache_generation(labels = {}, &block) ⇒ Object
Measure the duration of cacheable action
32 33 34 35 36 37 38 39 40 |
# File 'lib/gitlab/cache/metrics.rb', line 32 def observe_cache_generation(labels = {}, &block) real_start = Gitlab::Metrics::System.monotonic_time value = yield histogram.observe(base_labels.merge(labels), Gitlab::Metrics::System.monotonic_time - real_start) value end |