Commit 6ff9f028 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Migrate and reduce the buckets of Gitaly metrics

/cc @bjk-gitlab
/cc @zj
parent 67fcd061
...@@ -6,6 +6,7 @@ require 'grpc/health/v1/health_services_pb' ...@@ -6,6 +6,7 @@ require 'grpc/health/v1/health_services_pb'
module Gitlab module Gitlab
module GitalyClient module GitalyClient
include Gitlab::Metrics::Concern
module MigrationStatus module MigrationStatus
DISABLED = 1 DISABLED = 1
OPT_IN = 2 OPT_IN = 2
...@@ -33,8 +34,6 @@ module Gitlab ...@@ -33,8 +34,6 @@ module Gitlab
CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze
MUTEX = Mutex.new MUTEX = Mutex.new
METRICS_MUTEX = Mutex.new
private_constant :MUTEX, :METRICS_MUTEX
class << self class << self
attr_accessor :query_time attr_accessor :query_time
...@@ -42,28 +41,14 @@ module Gitlab ...@@ -42,28 +41,14 @@ module Gitlab
self.query_time = 0 self.query_time = 0
def self.migrate_histogram define_histogram :gitaly_migrate_call_duration_seconds do
@migrate_histogram ||= docstring "Gitaly migration call execution timings"
METRICS_MUTEX.synchronize do base_labels gitaly_enabled: nil, feature: nil
# If a thread was blocked on the mutex, the value was set already
return @migrate_histogram if @migrate_histogram
Gitlab::Metrics.histogram(:gitaly_migrate_call_duration_seconds,
"Gitaly migration call execution timings",
gitaly_enabled: nil, feature: nil)
end
end end
def self.gitaly_call_histogram define_histogram :gitaly_controller_action_duration_seconds do
@gitaly_call_histogram ||= docstring "Gitaly endpoint histogram by controller and action combination"
METRICS_MUTEX.synchronize do base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil)
# If a thread was blocked on the mutex, the value was set already
return @gitaly_call_histogram if @gitaly_call_histogram
Gitlab::Metrics.histogram(:gitaly_controller_action_duration_seconds,
"Gitaly endpoint histogram by controller and action combination",
Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil))
end
end end
def self.stub(name, storage) def self.stub(name, storage)
...@@ -145,7 +130,7 @@ module Gitlab ...@@ -145,7 +130,7 @@ module Gitlab
# Keep track, seperately, for the performance bar # Keep track, seperately, for the performance bar
self.query_time += duration self.query_time += duration
gitaly_call_histogram.observe( gitaly_controller_action_duration_seconds.observe(
current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s), current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s),
duration) duration)
end end
...@@ -247,7 +232,7 @@ module Gitlab ...@@ -247,7 +232,7 @@ module Gitlab
yield is_enabled yield is_enabled
ensure ensure
total_time = Gitlab::Metrics::System.monotonic_time - start total_time = Gitlab::Metrics::System.monotonic_time - start
migrate_histogram.observe({ gitaly_enabled: is_enabled, feature: feature }, total_time) gitaly_migrate_call_duration_seconds.observe({ gitaly_enabled: is_enabled, feature: feature }, total_time)
feature_stack.shift feature_stack.shift
Thread.current[:gitaly_feature_stack] = nil if feature_stack.empty? Thread.current[:gitaly_feature_stack] = nil if feature_stack.empty?
end end
......
...@@ -2,9 +2,11 @@ module Gitlab ...@@ -2,9 +2,11 @@ module Gitlab
module Metrics module Metrics
module Concern module Concern
class MetricOptions class MetricOptions
SMALL_NETWORK_BUCKETS = [0.005, 0.01, 0.1, 1, 10].freeze
def initialize(options = {}) def initialize(options = {})
@multiprocess_mode = options[:multiprocess_mode] || :all @multiprocess_mode = options[:multiprocess_mode] || :all
@buckets = options[:buckets] || ::Prometheus::Client::Histogram::DEFAULT_BUCKETS @buckets = options[:buckets] || SMALL_NETWORK_BUCKETS
@base_labels = options[:base_labels] || {} @base_labels = options[:base_labels] || {}
@docstring = options[:docstring] @docstring = options[:docstring]
@with_feature = options[:with_feature] @with_feature = options[:with_feature]
......
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