Class: InstStatsd::RequestStat
Instance Attribute Summary
Attributes inherited from BlockStat
#short_stat, #stats, #tags
Instance Method Summary
collapse
Methods inherited from BlockStat
#exclusive_stats, #subtract_exclusives
Constructor Details
#initialize(name, start, finish, id, payload, statsd = InstStatsd::Statsd) ⇒ RequestStat
Returns a new instance of RequestStat.
5
6
7
8
9
10
11
12
13
|
# File 'lib/inst_statsd/request_stat.rb', line 5
def initialize(name, start, finish, id, payload, statsd=InstStatsd::Statsd)
super(nil, statsd)
@name = name
@start = start
@finish = finish
@id = id
@payload = payload
@statsd = statsd
end
|
Instance Method Details
#action ⇒ Object
48
49
50
|
# File 'lib/inst_statsd/request_stat.rb', line 48
def action
@payload.fetch(:params, {})['action']
end
|
#common_key ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/inst_statsd/request_stat.rb', line 15
def common_key
common_key = super
return common_key if common_key
if @statsd.data_dog?
self.common_key = "request"
self.short_stat = "request"
self.tags[:controller] = controller if controller
self.tags[:action] = action if action
self.tags[:status] = status if status
else
self.common_key = "request.#{controller}.#{action}" if controller && action
end
end
|
#controller ⇒ Object
44
45
46
|
# File 'lib/inst_statsd/request_stat.rb', line 44
def controller
@payload.fetch(:params, {})['controller']
end
|
#db_runtime ⇒ Object
36
37
38
|
# File 'lib/inst_statsd/request_stat.rb', line 36
def db_runtime
@payload.fetch(:db_runtime, nil)
end
|
#report ⇒ Object
29
30
31
32
33
34
|
# File 'lib/inst_statsd/request_stat.rb', line 29
def report
stats['total'] = total
stats['view'] = view_runtime if view_runtime
stats['db'] = db_runtime if db_runtime
super
end
|
#status ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/inst_statsd/request_stat.rb', line 52
def status
status = @payload.fetch(:status, 0)
return '1XX' if status >= 100 and status < 200
return '2XX' if status >= 200 and status < 300
return '3XX' if status >= 300 and status < 400
return '4XX' if status >= 400 and status < 500
return '5XX' if status >= 500 and status < 600
nil
end
|
#total ⇒ Object
63
64
65
66
67
68
|
# File 'lib/inst_statsd/request_stat.rb', line 63
def total
if (!@finish || !@start)
return 0
end
(@finish - @start) * 1000
end
|
#view_runtime ⇒ Object
40
41
42
|
# File 'lib/inst_statsd/request_stat.rb', line 40
def view_runtime
@payload.fetch(:view_runtime, nil)
end
|