Class: Archimedes
- Inherits:
-
Object
- Object
- Archimedes
- Defined in:
- lib/archimedes.rb,
lib/archimedes/config.rb,
lib/archimedes/version.rb
Defined Under Namespace
Classes: Config
Constant Summary collapse
- VERSION =
'1.0.0'
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
- #count(metric, delta, rate = 1) ⇒ Object
- #decrement(metric, rate = 1) ⇒ Object
- #gauge(metric, value, rate = 1) ⇒ Object
- #increment(metric, rate = 1) ⇒ Object
-
#initialize(config) ⇒ Archimedes
constructor
A new instance of Archimedes.
- #time(metric, rate = 1) ⇒ Object
- #timing(metric, duration = 1) ⇒ Object
Constructor Details
#initialize(config) ⇒ Archimedes
Returns a new instance of Archimedes.
9 10 11 12 13 |
# File 'lib/archimedes.rb', line 9 def initialize(config) @config = config @service = Statsd.new(@config.host, @config.port) @service.namespace = @config.namespace end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
7 8 9 |
# File 'lib/archimedes.rb', line 7 def service @service end |
Instance Method Details
#count(metric, delta, rate = 1) ⇒ Object
23 24 25 |
# File 'lib/archimedes.rb', line 23 def count(metric, delta, rate = 1) service.count(metric, delta, rate) end |
#decrement(metric, rate = 1) ⇒ Object
19 20 21 |
# File 'lib/archimedes.rb', line 19 def decrement(metric, rate = 1) count(metric, -1, rate) end |
#gauge(metric, value, rate = 1) ⇒ Object
27 28 29 |
# File 'lib/archimedes.rb', line 27 def gauge(metric, value, rate = 1) service.gauge(metric, value, rate) end |
#increment(metric, rate = 1) ⇒ Object
15 16 17 |
# File 'lib/archimedes.rb', line 15 def increment(metric, rate = 1) count(metric, 1, rate) end |
#time(metric, rate = 1) ⇒ Object
31 32 33 34 35 |
# File 'lib/archimedes.rb', line 31 def time(metric, rate = 1) service.time(metric, rate) do yield end end |
#timing(metric, duration = 1) ⇒ Object
37 38 39 |
# File 'lib/archimedes.rb', line 37 def timing(metric, duration = 1) service.timing(metric, duration) end |