Module: Metrics
- Defined in:
- lib/metrics/instrument.rb,
lib/metrics-instrument/version.rb
Defined Under Namespace
Modules: Instrument
Constant Summary collapse
- Timeout =
defined?(::SystemTimer) ? ::SystemTimer : ::Timeout
Class Attribute Summary collapse
-
.default_sample_rate ⇒ Object
Returns the value of attribute default_sample_rate.
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.host ⇒ Object
Returns the value of attribute host.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.mode ⇒ Object
Returns the value of attribute mode.
-
.port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
- .increment(key, delta = 1, sample_rate = default_sample_rate) ⇒ Object
- .measure(key, milli = nil) ⇒ Object
- .server=(conn) ⇒ Object
Class Attribute Details
.default_sample_rate ⇒ Object
Returns the value of attribute default_sample_rate.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def default_sample_rate @default_sample_rate end |
.enabled ⇒ Object
Returns the value of attribute enabled.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def enabled @enabled end |
.host ⇒ Object
Returns the value of attribute host.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def host @host end |
.logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def logger @logger end |
.mode ⇒ Object
Returns the value of attribute mode.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def mode @mode end |
.port ⇒ Object
Returns the value of attribute port.
14 15 16 |
# File 'lib/metrics/instrument.rb', line 14 def port @port end |
Class Method Details
.increment(key, delta = 1, sample_rate = default_sample_rate) ⇒ Object
111 112 113 |
# File 'lib/metrics/instrument.rb', line 111 def self.increment(key, delta = 1, sample_rate = default_sample_rate) write(key, delta, sample_rate) end |
.measure(key, milli = nil) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/metrics/instrument.rb', line 101 def self.measure(key, milli = nil) result = nil ms = milli || Benchmark.ms do result = yield end write(key, ms) result end |
.server=(conn) ⇒ Object
23 24 25 26 |
# File 'lib/metrics/instrument.rb', line 23 def self.server=(conn) self.host, port = conn.split(':') self.port = port.to_i end |