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
49
50
51
|
# File 'lib/inst_statsd/request_stat.rb', line 49
def action
@payload.fetch(:params, {})["action"]
end
|
#common_key ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# 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"
tags[:controller] = controller if controller
tags[:action] = action if action
tags[:status] = status if status
elsif controller && action
self.common_key = "request.#{controller}.#{action}"
end
end
|
#controller ⇒ Object
45
46
47
|
# File 'lib/inst_statsd/request_stat.rb', line 45
def controller
@payload.fetch(:params, {})["controller"]
end
|
#db_runtime ⇒ Object
37
38
39
|
# File 'lib/inst_statsd/request_stat.rb', line 37
def db_runtime
@payload.fetch(:db_runtime, nil)
end
|
#report ⇒ Object
30
31
32
33
34
35
|
# File 'lib/inst_statsd/request_stat.rb', line 30
def report
stats["total"] = total
stats["view"] = view_runtime if view_runtime
stats["db"] = db_runtime if db_runtime
super
end
|
#status ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/inst_statsd/request_stat.rb', line 53
def status
status = @payload.fetch(:status, 0)
return "1XX" if (status >= 100) && (status < 200)
return "2XX" if (status >= 200) && (status < 300)
return "3XX" if (status >= 300) && (status < 400)
return "4XX" if (status >= 400) && (status < 500)
return "5XX" if (status >= 500) && (status < 600)
nil
end
|
#total ⇒ Object
65
66
67
68
69
|
# File 'lib/inst_statsd/request_stat.rb', line 65
def total
return 0 if !@finish || !@start
(@finish - @start) * 1000
end
|
#view_runtime ⇒ Object
41
42
43
|
# File 'lib/inst_statsd/request_stat.rb', line 41
def view_runtime
@payload.fetch(:view_runtime, nil)
end
|