class TwemproxyExporter::Exporter

Attributes

client_connections[R]

Cluster Metrics

client_eof[R]
client_err[R]
curr_connections[R]

Twemproxy Metrics

forward_error[R]
fragments[R]
in_queue[R]

Server Metrics

in_queue_bytes[R]
out_queue[R]
out_queue_bytes[R]
proxies[R]
registry[R]
request_bytes[R]
requests[R]
response_bytes[R]
responses[R]
server_connections[R]
server_ejected_at[R]
server_ejects[R]
server_eof[R]
server_err[R]
server_timedout[R]
timeout[R]
total_connections[R]
uptime[R]

Public Class Methods

new(config) click to toggle source
# File lib/twemproxy_exporter/exporter.rb, line 37
def initialize(config)
  @running  = false
  @registry = Prometheus::Client.registry
  @timeout  = config['timeout'] || 5.0
  @interval = config['interval'] || 30
  @proxies  = config['proxies'].map do |proxy|
    host, port = proxy.split(':')
    Twemproxy.new(self, host, port || 22222)
  end

  # Twemproxy Metrics
  @curr_connections   = Gauge.new   @registry, :twemproxy_curr_connections,   'Current Connections'
  @total_connections  = Counter.new @registry, :twemproxy_total_connections,  'Total Connections'
  @uptime             = Gauge.new   @registry, :twemproxy_uptime,             'Current Uptime'

  # Cluster Metrics
  @client_connections = Counter.new @registry, :twemproxy_client_connections, 'Client Connections'
  @client_eof         = Counter.new @registry, :twemproxy_client_eof,         'Client EOFs'
  @client_err         = Counter.new @registry, :twemproxy_client_err,         'Client Errors'
  @forward_error      = Counter.new @registry, :twemproxy_forward_error,      'Forwarding Errors'
  @fragments          = Counter.new @registry, :twemproxy_fragments,          'Fragments'
  @server_ejects      = Counter.new @registry, :twemproxy_server_ejects,      'Server Errors'

  # Server Metrics
  @in_queue           = Gauge.new   @registry, :twemproxy_in_queue,           'In Queue Depth'
  @in_queue_bytes     = Gauge.new   @registry, :twemproxy_in_queue_bytes,     'In Queue Bytes'
  @out_queue          = Gauge.new   @registry, :twemproxy_out_queue,          'Out Queue Depth'
  @out_queue_bytes    = Gauge.new   @registry, :twemproxy_out_queue_bytes,    'Out Queue Bytes'
  @request_bytes      = Counter.new @registry, :twemproxy_request_bytes,      'Request Bytes'
  @requests           = Counter.new @registry, :twemproxy_requests,           'Request Count'
  @response_bytes     = Counter.new @registry, :twemproxy_response_bytes,     'Response Bytes'
  @responses          = Counter.new @registry, :twemproxy_responses,          'Response Count'
  @server_connections = Counter.new @registry, :twemproxy_server_connections, 'Server Connections'
  @server_ejected_at  = Gauge.new   @registry, :twemproxy_server_ejected_at,  'Server Ejected At'
  @server_eof         = Counter.new @registry, :twemproxy_server_eof,         'Server EOFs'
  @server_err         = Counter.new @registry, :twemproxy_server_err,         'Server Errors'
  @server_timedout    = Gauge.new   @registry, :twemproxy_server_timedout,    'Server Timed Out'
end

Public Instance Methods

run!() click to toggle source
# File lib/twemproxy_exporter/exporter.rb, line 76
def run!
  @running = true

  while @running
    threads = @proxies.map do |proxy|
      Thread.new {proxy.count}
    end

    threads.each(&:join)
    self.sleep
  end
end
stop!() click to toggle source
# File lib/twemproxy_exporter/exporter.rb, line 89
def stop!
  @running = false
end

Protected Instance Methods

sleep() click to toggle source
# File lib/twemproxy_exporter/exporter.rb, line 94
def sleep
  @interval.times do
    break unless @running
    Kernel.sleep 1
  end
end