class RequestLogAnalyzer::Tracker::Duration
Analyze the duration of a specific attribute
Options¶ ↑
-
:category
Proc that handles request categorization for given fileformat (REQUEST_CATEGORIZER) -
:duration
The field containing the duration in the request hash. -
:if
Proc that has to return !nil for a request to be passed to the tracker. -
:line_type
The line type that contains the duration field (determined by the category proc). -
:title
Title do be displayed above the report -
:unless
Handle request if this proc is false for the handled request.
The items in the update request hash are set during the creation of the Duration
tracker.
Example output:
Request duration - top 20 by cumulative time | Hits | Sum. | Avg. --------------------------------------------------------------------------------- EmployeeController#show.html [GET] | 4742 | 4922.56s | 1.04s EmployeeController#update.html [POST] | 4647 | 2731.23s | 0.59s EmployeeController#index.html [GET] | 5802 | 1477.32s | 0.25s .............
Public Instance Methods
display_value(time)
click to toggle source
Display a duration
# File lib/request_log_analyzer/tracker/duration.rb 36 def display_value(time) 37 case time 38 when nil then '-' 39 when 0...1 then '%0ims' % (time * 1000) 40 when 1...60 then '%0.02fs' % time 41 when 60...3600 then '%dm%02ds' % [time / 60, (time % 60).round] 42 else '%dh%02dm%02ds' % [time / 3600, (time % 3600) / 60, (time % 60).round] 43 end 44 end
prepare()
click to toggle source
Check if duration and catagory option have been received,
Calls superclass method
# File lib/request_log_analyzer/tracker/duration.rb 23 def prepare 24 options[:value] = options[:duration] if options[:duration] 25 super 26 27 @number_of_buckets = options[:number_of_buckets] || 1000 28 @min_bucket_value = options[:min_bucket_value] ? options[:min_bucket_value].to_f : 0.0001 29 @max_bucket_value = options[:max_bucket_value] ? options[:max_bucket_value].to_f : 1000 30 31 # precalculate the bucket size 32 @bucket_size = (Math.log(@max_bucket_value) - Math.log(@min_bucket_value)) / @number_of_buckets.to_f 33 end
title()
click to toggle source
Returns the title of this tracker for reports
# File lib/request_log_analyzer/tracker/duration.rb 47 def title 48 options[:title] || 'Request duration' 49 end