Class: RequestLogAnalyzer::FileFormat::Haproxy::Request
- Defined in:
- lib/request_log_analyzer/file_format/haproxy.rb
Overview
Define a custom Request class for the HAProxy file format to speed up timestamp handling. Shamelessly copied from apache.rb
Constant Summary collapse
- MONTHS =
{ 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' }
Instance Attribute Summary
Attributes inherited from Request
#attributes, #file_format, #lines
Instance Method Summary collapse
-
#convert_nillable_duration(value, definition) ⇒ Object
Make sure that -1 is parsed as a nil value.
-
#convert_nillable_string(value, _definition) ⇒ Object
Make sure that the strings ‘-’ or ‘{}’ or ” are parsed as a nil value.
-
#convert_timestamp(value, _definition) ⇒ Object
Do not use DateTime.parse, but parse the timestamp ourselves to return a integer to speed up parsing.
Methods inherited from Request
#<<, #add_line_hash, #add_parsed_line, #completed?, create, #empty?, #every, #first, #first_lineno, #has_line_type?, #initialize, #last_lineno, #timestamp, #validate
Methods included from Request::Converters
#convert_decimal, #convert_duration, #convert_epoch, #convert_eval, #convert_float, #convert_int, #convert_integer, #convert_path, #convert_string, #convert_sym, #convert_symbol, #convert_traffic, #convert_value, #sanitize_parameters
Constructor Details
This class inherits a constructor from RequestLogAnalyzer::Request
Instance Method Details
#convert_nillable_duration(value, definition) ⇒ Object
Make sure that -1 is parsed as a nil value.
223 224 225 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 223 def convert_nillable_duration(value, definition) value == '-1' ? nil : convert_duration(value, definition) end |
#convert_nillable_string(value, _definition) ⇒ Object
Make sure that the strings ‘-’ or ‘{}’ or ” are parsed as a nil value.
218 219 220 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 218 def convert_nillable_string(value, _definition) value =~ /-|\{\}|^$/ ? nil : value end |
#convert_timestamp(value, _definition) ⇒ Object
Do not use DateTime.parse, but parse the timestamp ourselves to return a integer to speed up parsing.
213 214 215 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 213 def (value, _definition) "#{value[7, 4]}#{MONTHS[value[3, 3]]}#{value[0, 2]}#{value[12, 2]}#{value[15, 2]}#{value[18, 2]}".to_i end |