class RequestLogAnalyzer::FileFormat::Oink::Request
Public Instance Methods
convert_pipe_separated_counts(value, _capture_definition)
click to toggle source
# File lib/request_log_analyzer/file_format/oink.rb 84 def convert_pipe_separated_counts(value, _capture_definition) 85 count_strings = value.split(' | ') 86 count_arrays = count_strings.map do |count_string| 87 if count_string =~ /^(\w+): (\d+)/ 88 [Regexp.last_match[1], Regexp.last_match[2].to_i] 89 end 90 end 91 92 Hash[count_arrays] 93 end
pid_memory()
click to toggle source
Accessor for memory information associated with the specified request PID. If no memory exists for this request’s :pid, the memory tracking is initialized.
# File lib/request_log_analyzer/file_format/oink.rb 54 def pid_memory 55 file_format.pids[self[:pid]] ||= { last_memory_reading: -1, current_memory_reading: -1 } 56 end
update_pids()
click to toggle source
Calculates :memory_diff for each request based on the last completed request that was not a failure.
# File lib/request_log_analyzer/file_format/oink.rb 59 def update_pids 60 # memory isn't recorded with exceptions. need to set #last_memory_reading+ to -1 as 61 # the memory used could have changed. for the next request the memory change will not be recorded. 62 # 63 # NOTE - the failure regex was not matching with a Rails Development log file. 64 if has_line_type?(:failure) && processing = has_line_type?(:processing) 65 pid_memory[:last_memory_reading] = -1 66 elsif mem_line = has_line_type?(:memory_usage) 67 memory_reading = mem_line[:memory] 68 pid_memory[:current_memory_reading] = memory_reading 69 # calcuate the change in memory 70 unless pid_memory[:current_memory_reading] == -1 || pid_memory[:last_memory_reading] == -1 71 # logged as kB, need to convert to bytes for the :traffic Tracker 72 memory_diff = (pid_memory[:current_memory_reading] - pid_memory[:last_memory_reading]) * 1024 73 if memory_diff > 0 74 attributes[:memory_diff] = memory_diff 75 end # if memory_diff > 0 76 end # unless 77 78 pid_memory[:last_memory_reading] = pid_memory[:current_memory_reading] 79 pid_memory[:current_memory_reading] = -1 80 end # if mem_line 81 true 82 end
validate()
click to toggle source
Overrides the validate
method to handle PID updating.
Calls superclass method
RequestLogAnalyzer::Request#validate
# File lib/request_log_analyzer/file_format/oink.rb 47 def validate 48 update_pids 49 super 50 end