Class: RailsRiemannMiddleware::Duration
- Inherits:
-
Object
- Object
- RailsRiemannMiddleware::Duration
- Defined in:
- lib/rails_riemann_middleware/duration.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(event, env, start_time, options = {}) ⇒ Duration
constructor
A new instance of Duration.
- #message ⇒ Object
- #send ⇒ Object
Constructor Details
#initialize(event, env, start_time, options = {}) ⇒ Duration
Returns a new instance of Duration.
8 9 10 11 |
# File 'lib/rails_riemann_middleware/duration.rb', line 8 def initialize(event, env, start_time, ={}) @event, @env, @start_time = event, env, start_time @headers = .fetch(:headers, []) end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
6 7 8 |
# File 'lib/rails_riemann_middleware/duration.rb', line 6 def env @env end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
6 7 8 |
# File 'lib/rails_riemann_middleware/duration.rb', line 6 def event @event end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/rails_riemann_middleware/duration.rb', line 6 def headers @headers end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
6 7 8 |
# File 'lib/rails_riemann_middleware/duration.rb', line 6 def start_time @start_time end |
Instance Method Details
#message ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_riemann_middleware/duration.rb', line 17 def end_time = Time.new duration = (end_time - start_time) msg = { :host => env['HTTP_HOST'], :service => "#{event.app_prefix} request duration".strip, :state => 'info', :metric => duration, :tags => ["duration"], :description => Headers.new(env, headers).to_s } msg end |
#send ⇒ Object
13 14 15 |
# File 'lib/rails_riemann_middleware/duration.rb', line 13 def send event << end |