Class: TwemproxyExporter::Exporter
- Inherits:
-
Object
- Object
- TwemproxyExporter::Exporter
- Defined in:
- lib/twemproxy_exporter/exporter.rb
Instance Attribute Summary collapse
-
#client_connections ⇒ Object
readonly
Cluster Metrics.
-
#client_eof ⇒ Object
readonly
Returns the value of attribute client_eof.
-
#client_err ⇒ Object
readonly
Returns the value of attribute client_err.
-
#curr_connections ⇒ Object
readonly
Twemproxy Metrics.
-
#forward_error ⇒ Object
readonly
Returns the value of attribute forward_error.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
-
#in_queue ⇒ Object
readonly
Server Metrics.
-
#in_queue_bytes ⇒ Object
readonly
Returns the value of attribute in_queue_bytes.
-
#out_queue ⇒ Object
readonly
Returns the value of attribute out_queue.
-
#out_queue_bytes ⇒ Object
readonly
Returns the value of attribute out_queue_bytes.
-
#proxies ⇒ Object
readonly
Returns the value of attribute proxies.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#request_bytes ⇒ Object
readonly
Returns the value of attribute request_bytes.
-
#requests ⇒ Object
readonly
Returns the value of attribute requests.
-
#response_bytes ⇒ Object
readonly
Returns the value of attribute response_bytes.
-
#responses ⇒ Object
readonly
Returns the value of attribute responses.
-
#server_connections ⇒ Object
readonly
Returns the value of attribute server_connections.
-
#server_ejected_at ⇒ Object
readonly
Returns the value of attribute server_ejected_at.
-
#server_ejects ⇒ Object
readonly
Returns the value of attribute server_ejects.
-
#server_eof ⇒ Object
readonly
Returns the value of attribute server_eof.
-
#server_err ⇒ Object
readonly
Returns the value of attribute server_err.
-
#server_timedout ⇒ Object
readonly
Returns the value of attribute server_timedout.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#total_connections ⇒ Object
readonly
Returns the value of attribute total_connections.
-
#uptime ⇒ Object
readonly
Returns the value of attribute uptime.
Instance Method Summary collapse
-
#initialize(config) ⇒ Exporter
constructor
A new instance of Exporter.
- #run! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(config) ⇒ Exporter
Returns a new instance of Exporter.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# 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 |
Instance Attribute Details
#client_connections ⇒ Object (readonly)
Cluster Metrics
15 16 17 |
# File 'lib/twemproxy_exporter/exporter.rb', line 15 def client_connections @client_connections end |
#client_eof ⇒ Object (readonly)
Returns the value of attribute client_eof.
16 17 18 |
# File 'lib/twemproxy_exporter/exporter.rb', line 16 def client_eof @client_eof end |
#client_err ⇒ Object (readonly)
Returns the value of attribute client_err.
17 18 19 |
# File 'lib/twemproxy_exporter/exporter.rb', line 17 def client_err @client_err end |
#curr_connections ⇒ Object (readonly)
Twemproxy Metrics
10 11 12 |
# File 'lib/twemproxy_exporter/exporter.rb', line 10 def curr_connections @curr_connections end |
#forward_error ⇒ Object (readonly)
Returns the value of attribute forward_error.
18 19 20 |
# File 'lib/twemproxy_exporter/exporter.rb', line 18 def forward_error @forward_error end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
19 20 21 |
# File 'lib/twemproxy_exporter/exporter.rb', line 19 def fragments @fragments end |
#in_queue ⇒ Object (readonly)
Server Metrics
23 24 25 |
# File 'lib/twemproxy_exporter/exporter.rb', line 23 def in_queue @in_queue end |
#in_queue_bytes ⇒ Object (readonly)
Returns the value of attribute in_queue_bytes.
24 25 26 |
# File 'lib/twemproxy_exporter/exporter.rb', line 24 def in_queue_bytes @in_queue_bytes end |
#out_queue ⇒ Object (readonly)
Returns the value of attribute out_queue.
25 26 27 |
# File 'lib/twemproxy_exporter/exporter.rb', line 25 def out_queue @out_queue end |
#out_queue_bytes ⇒ Object (readonly)
Returns the value of attribute out_queue_bytes.
26 27 28 |
# File 'lib/twemproxy_exporter/exporter.rb', line 26 def out_queue_bytes @out_queue_bytes end |
#proxies ⇒ Object (readonly)
Returns the value of attribute proxies.
5 6 7 |
# File 'lib/twemproxy_exporter/exporter.rb', line 5 def proxies @proxies end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
6 7 8 |
# File 'lib/twemproxy_exporter/exporter.rb', line 6 def registry @registry end |
#request_bytes ⇒ Object (readonly)
Returns the value of attribute request_bytes.
27 28 29 |
# File 'lib/twemproxy_exporter/exporter.rb', line 27 def request_bytes @request_bytes end |
#requests ⇒ Object (readonly)
Returns the value of attribute requests.
28 29 30 |
# File 'lib/twemproxy_exporter/exporter.rb', line 28 def requests @requests end |
#response_bytes ⇒ Object (readonly)
Returns the value of attribute response_bytes.
29 30 31 |
# File 'lib/twemproxy_exporter/exporter.rb', line 29 def response_bytes @response_bytes end |
#responses ⇒ Object (readonly)
Returns the value of attribute responses.
30 31 32 |
# File 'lib/twemproxy_exporter/exporter.rb', line 30 def responses @responses end |
#server_connections ⇒ Object (readonly)
Returns the value of attribute server_connections.
31 32 33 |
# File 'lib/twemproxy_exporter/exporter.rb', line 31 def server_connections @server_connections end |
#server_ejected_at ⇒ Object (readonly)
Returns the value of attribute server_ejected_at.
32 33 34 |
# File 'lib/twemproxy_exporter/exporter.rb', line 32 def server_ejected_at @server_ejected_at end |
#server_ejects ⇒ Object (readonly)
Returns the value of attribute server_ejects.
20 21 22 |
# File 'lib/twemproxy_exporter/exporter.rb', line 20 def server_ejects @server_ejects end |
#server_eof ⇒ Object (readonly)
Returns the value of attribute server_eof.
33 34 35 |
# File 'lib/twemproxy_exporter/exporter.rb', line 33 def server_eof @server_eof end |
#server_err ⇒ Object (readonly)
Returns the value of attribute server_err.
34 35 36 |
# File 'lib/twemproxy_exporter/exporter.rb', line 34 def server_err @server_err end |
#server_timedout ⇒ Object (readonly)
Returns the value of attribute server_timedout.
35 36 37 |
# File 'lib/twemproxy_exporter/exporter.rb', line 35 def server_timedout @server_timedout end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/twemproxy_exporter/exporter.rb', line 7 def timeout @timeout end |
#total_connections ⇒ Object (readonly)
Returns the value of attribute total_connections.
11 12 13 |
# File 'lib/twemproxy_exporter/exporter.rb', line 11 def total_connections @total_connections end |
#uptime ⇒ Object (readonly)
Returns the value of attribute uptime.
12 13 14 |
# File 'lib/twemproxy_exporter/exporter.rb', line 12 def uptime @uptime end |
Instance Method Details
#run! ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 |
# 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! ⇒ Object
89 90 91 |
# File 'lib/twemproxy_exporter/exporter.rb', line 89 def stop! @running = false end |