Class: Chillout::Subscribers::ActionControllerNotifications::RequestMetric

Inherits:
Object
  • Object
show all
Defined in:
lib/chillout/subscribers/action_controller_notifications.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ RequestMetric

Returns a new instance of RequestMetric.



6
7
8
9
10
# File 'lib/chillout/subscribers/action_controller_notifications.rb', line 6

def initialize(event)
  @end      = event.end
  @duration = event.duration
  @payload  = event.payload.except(:headers)
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



35
36
37
# File 'lib/chillout/subscribers/action_controller_notifications.rb', line 35

def duration
  @duration
end

#endObject (readonly)

Returns the value of attribute end.



35
36
37
# File 'lib/chillout/subscribers/action_controller_notifications.rb', line 35

def end
  @end
end

#payloadObject (readonly)

Returns the value of attribute payload.



35
36
37
# File 'lib/chillout/subscribers/action_controller_notifications.rb', line 35

def payload
  @payload
end

Instance Method Details

#as_measurementsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chillout/subscribers/action_controller_notifications.rb', line 12

def as_measurements()
  format = (payload[:format] || "all").to_s
  format = "all" if format == "*/*"

  [{
     series: "request",
     tags: {
       controller: payload[:controller],
       action:     payload[:action],
       format:     format,
       method:     payload[:method],
       status:     payload[:status],
     },
     timestamp: self.end.iso8601,
     values: {
       finished: 1,
       duration: duration.to_f,
       db:    (payload[:db_runtime]   || 0).to_f,
       view:  (payload[:view_runtime] || 0).to_f,
     },
   }]
end