diff options
author | Ryan Cobb <rcobb@gitlab.com> | 2019-05-20 17:34:00 +0300 |
---|---|---|
committer | Ryan Cobb <rcobb@gitlab.com> | 2019-05-20 17:34:00 +0300 |
commit | 2334b07726f819c6a9fe94d1380969d0b9eaef85 (patch) | |
tree | 8abf7e0d0813153c91e00c79cb8011cdd133352c /lib/gitlab/metrics/samplers/unicorn_sampler.rb | |
parent | 7115bd811f4bc87c0706fc2b876729878ad8fc5b (diff) |
Revert "Merge branch '56850-add-new-unicorn-metrics' into 'master'"
This reverts merge request !27474
Diffstat (limited to 'lib/gitlab/metrics/samplers/unicorn_sampler.rb')
-rw-r--r-- | lib/gitlab/metrics/samplers/unicorn_sampler.rb | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/lib/gitlab/metrics/samplers/unicorn_sampler.rb b/lib/gitlab/metrics/samplers/unicorn_sampler.rb index 1b6c52ac0bf..bec64e864b3 100644 --- a/lib/gitlab/metrics/samplers/unicorn_sampler.rb +++ b/lib/gitlab/metrics/samplers/unicorn_sampler.rb @@ -8,16 +8,12 @@ module Gitlab super(interval) end - def metrics - @metrics ||= init_metrics + def unicorn_active_connections + @unicorn_active_connections ||= ::Gitlab::Metrics.gauge(:unicorn_active_connections, 'Unicorn active connections', {}, :max) end - def init_metrics - { - unicorn_active_connections: ::Gitlab::Metrics.gauge(:unicorn_active_connections, 'Unicorn active connections', {}, :max), - unicorn_queued_connections: ::Gitlab::Metrics.gauge(:unicorn_queued_connections, 'Unicorn queued connections', {}, :max), - unicorn_workers: ::Gitlab::Metrics.gauge(:unicorn_workers, 'Unicorn workers') - } + def unicorn_queued_connections + @unicorn_queued_connections ||= ::Gitlab::Metrics.gauge(:unicorn_queued_connections, 'Unicorn queued connections', {}, :max) end def enabled? @@ -27,13 +23,14 @@ module Gitlab def sample Raindrops::Linux.tcp_listener_stats(tcp_listeners).each do |addr, stats| - set_unicorn_connection_metrics('tcp', addr, stats) + unicorn_active_connections.set({ socket_type: 'tcp', socket_address: addr }, stats.active) + unicorn_queued_connections.set({ socket_type: 'tcp', socket_address: addr }, stats.queued) end + Raindrops::Linux.unix_listener_stats(unix_listeners).each do |addr, stats| - set_unicorn_connection_metrics('unix', addr, stats) + unicorn_active_connections.set({ socket_type: 'unix', socket_address: addr }, stats.active) + unicorn_queued_connections.set({ socket_type: 'unix', socket_address: addr }, stats.queued) end - - metrics[:unicorn_workers].set({}, unicorn_workers_count) end private @@ -42,13 +39,6 @@ module Gitlab @tcp_listeners ||= Unicorn.listener_names.grep(%r{\A[^/]+:\d+\z}) end - def set_unicorn_connection_metrics(type, addr, stats) - labels = { socket_type: type, socket_address: addr } - - metrics[:unicorn_active_connections].set(labels, stats.active) - metrics[:unicorn_queued_connections].set(labels, stats.queued) - end - def unix_listeners @unix_listeners ||= Unicorn.listener_names - tcp_listeners end @@ -56,10 +46,6 @@ module Gitlab def unicorn_with_listeners? defined?(Unicorn) && Unicorn.listener_names.any? end - - def unicorn_workers_count - Sys::ProcTable.ps.select {|p| p.cmdline.match(/unicorn_rails worker.+ #{Rails.root.to_s}/)}.count - end end end end |