Class: RequestLogAnalyzer::Tracker::Traffic
- Inherits:
-
NumericValue
- Object
- Base
- NumericValue
- RequestLogAnalyzer::Tracker::Traffic
- Defined in:
- lib/request_log_analyzer/tracker/traffic.rb
Overview
Analyze the average and total traffic of requests
Options
-
:categoryProc that handles request categorization for given fileformat (REQUEST_CATEGORIZER) -
:trafficThe field containing the duration in the request hash. -
:ifProc that has to return !nil for a request to be passed to the tracker. -
:line_typeThe line type that contains the duration field (determined by the category proc). -
:titleTitle do be displayed above the report -
:unlessHandle request if this proc is false for the handled request.
Instance Attribute Summary
Attributes inherited from NumericValue
Attributes inherited from Base
Instance Method Summary collapse
-
#display_value(bytes) ⇒ Object
Formats the traffic number using x B/kB/MB/GB etc notation.
-
#prepare ⇒ Object
Check if duration and catagory option have been received,.
-
#title ⇒ Object
Returns the title of this tracker for reports.
Methods inherited from NumericValue
#bucket_average_value, #bucket_index, #bucket_interval, #bucket_lower_bound, #bucket_upper_bound, #bucket_value, #bucketize, #hits, #hits_overall, #max, #mean, #mean_overall, #median, #min, #percentile, #percentile_index, #percentile_indices, #percentile_interval, #report, #report_table, #sorted_by, #statistics_header, #statistics_row, #stddev, #sum, #sum_overall, #to_yaml_object, #update, #update_statistics, #variance
Methods inherited from Base
#create_lambda, #finalize, #initialize, #report, #setup_should_update_checks!, #should_update?, #to_yaml_object, #update
Constructor Details
This class inherits a constructor from RequestLogAnalyzer::Tracker::Base
Instance Method Details
#display_value(bytes) ⇒ Object
Formats the traffic number using x B/kB/MB/GB etc notation
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/request_log_analyzer/tracker/traffic.rb', line 27 def display_value(bytes) return '-' if bytes.nil? return '0 B' if bytes.zero? case [Math.log10(bytes.abs).floor, 0].max when 0...4 then '%d B' % bytes when 4...7 then '%d kB' % (bytes / 1000) when 7...10 then '%d MB' % (bytes / 1_000_000) when 10...13 then '%d GB' % (bytes / 1_000_000_000) else '%d TB' % (bytes / 1_000_000_000_000) end end |
#prepare ⇒ Object
Check if duration and catagory option have been received,
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/request_log_analyzer/tracker/traffic.rb', line 13 def prepare [:value] = [:traffic] if [:traffic] [:total] = true super @number_of_buckets = [:number_of_buckets] || 1000 @min_bucket_value = [:min_bucket_value] ? [:min_bucket_value].to_f : 1 @max_bucket_value = [:max_bucket_value] ? [:max_bucket_value].to_f : 1_000_000_000_000 # precalculate the bucket size @bucket_size = (Math.log(@max_bucket_value) - Math.log(@min_bucket_value)) / @number_of_buckets.to_f end |
#title ⇒ Object
Returns the title of this tracker for reports
41 42 43 |
# File 'lib/request_log_analyzer/tracker/traffic.rb', line 41 def title [:title] || 'Request traffic' end |