Commit 3b0f8cc5 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents ed9a8239 433022f1
---
title: Adjust redis cache metrics
merge_request: 30572
author:
type: changed
......@@ -34,6 +34,9 @@ The following metrics are available:
| filesystem_writable | Gauge | 9.4 | Whether or not the filesystem is writable |
| filesystem_read_latency_seconds | Gauge | 9.4 | Read latency of a specific filesystem |
| filesystem_readable | Gauge | 9.4 | Whether or not the filesystem is readable |
| gitlab_cache_misses_total | Counter | 10.2 | Cache read miss |
| gitlab_cache_operation_duration_seconds | Histogram | 10.2 | Cache access time |
| gitlab_cache_operations_total | Counter | 12.2 | Cache operations by controller/action |
| http_requests_total | Counter | 9.4 | Rack request count |
| http_request_duration_seconds | Histogram | 9.4 | HTTP response time from rack middleware |
| pipelines_created_total | Counter | 9.4 | Counter of pipelines created |
......
......@@ -50,7 +50,8 @@ module Gitlab
def observe(key, duration)
return unless current_transaction
metric_cache_operation_duration_seconds.observe(current_transaction.labels.merge({ operation: key }), duration / 1000.0)
metric_cache_operations_total.increment(current_transaction.labels.merge({ operation: key }))
metric_cache_operation_duration_seconds.observe({ operation: key }, duration / 1000.0)
current_transaction.increment(:cache_duration, duration, false)
current_transaction.increment(:cache_count, 1, false)
current_transaction.increment("cache_#{key}_duration".to_sym, duration, false)
......@@ -63,12 +64,20 @@ module Gitlab
Transaction.current
end
def metric_cache_operations_total
@metric_cache_operations_total ||= ::Gitlab::Metrics.counter(
:gitlab_cache_operations_total,
'Cache operations',
Transaction::BASE_LABELS
)
end
def metric_cache_operation_duration_seconds
@metric_cache_operation_duration_seconds ||= ::Gitlab::Metrics.histogram(
:gitlab_cache_operation_duration_seconds,
'Cache access time',
Transaction::BASE_LABELS.merge({ action: nil }),
[0.001, 0.01, 0.1, 1, 10]
{},
[0.00001, 0.0001, 0.001, 0.01, 0.1, 1.0]
)
end
......
......@@ -201,7 +201,15 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
it 'observes cache metric' do
expect(subscriber.send(:metric_cache_operation_duration_seconds))
.to receive(:observe)
.with(transaction.labels.merge(operation: :delete), event.duration / 1000.0)
.with({ operation: :delete }, event.duration / 1000.0)
subscriber.observe(:delete, event.duration)
end
it 'increments the operations total' do
expect(subscriber.send(:metric_cache_operations_total))
.to receive(:increment)
.with(transaction.labels.merge(operation: :delete))
subscriber.observe(:delete, event.duration)
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