Class: Vmpooler::Metrics::Statsd
- Inherits:
-
Vmpooler::Metrics
- Object
- Vmpooler::Metrics
- Vmpooler::Metrics::Statsd
- Defined in:
- lib/vmpooler/metrics/statsd.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #gauge(label, value) ⇒ Object
-
#increment(label) ⇒ Object
rubocop:enable Lint/MissingSuper.
-
#initialize(logger, params = {}) ⇒ Statsd
constructor
rubocop:disable Lint/MissingSuper.
- #timing(label, duration) ⇒ Object
Methods inherited from Vmpooler::Metrics
Constructor Details
#initialize(logger, params = {}) ⇒ Statsd
rubocop:disable Lint/MissingSuper
12 13 14 15 16 17 18 19 20 |
# File 'lib/vmpooler/metrics/statsd.rb', line 12 def initialize(logger, params = {}) raise ArgumentError, "Statsd server is required. Config: #{params.inspect}" if params['server'].nil? || params['server'].empty? host = params['server'] @port = params['port'] || 8125 @prefix = params['prefix'] || 'vmpooler' @server = ::Statsd.new(host, @port) @logger = logger end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/vmpooler/metrics/statsd.rb', line 9 def port @port end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/vmpooler/metrics/statsd.rb', line 9 def prefix @prefix end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
9 10 11 |
# File 'lib/vmpooler/metrics/statsd.rb', line 9 def server @server end |
Instance Method Details
#gauge(label, value) ⇒ Object
29 30 31 32 33 |
# File 'lib/vmpooler/metrics/statsd.rb', line 29 def gauge(label, value) server.gauge("#{prefix}.#{label}", value) rescue StandardError => e @logger.log('s', "[!] Failure updating gauge #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}") end |
#increment(label) ⇒ Object
rubocop:enable Lint/MissingSuper
23 24 25 26 27 |
# File 'lib/vmpooler/metrics/statsd.rb', line 23 def increment(label) server.increment("#{prefix}.#{label}") rescue StandardError => e @logger.log('s', "[!] Failure incrementing #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}") end |
#timing(label, duration) ⇒ Object
35 36 37 38 39 |
# File 'lib/vmpooler/metrics/statsd.rb', line 35 def timing(label, duration) server.timing("#{prefix}.#{label}", duration) rescue StandardError => e @logger.log('s', "[!] Failure updating timing #{prefix}.#{label} on statsd server [#{server}:#{port}]: #{e}") end |