Class: RequestLogAnalyzer::FileFormat::Haproxy::Request
- Inherits:
-
Request
- Object
- Request
- 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
- 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)
-
- (Object) convert_nillable_duration(value, definition)
Make sure that -1 is parsed as a nil value.
-
- (Object) convert_nillable_string(value, definition)
Make sure that the strings '-' or '{}' or '' are parsed as a nil value.
-
- (Object) convert_timestamp(value, definition)
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
- (Object) convert_nillable_duration(value, definition)
Make sure that -1 is parsed as a nil value.
226 227 228 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 226 def convert_nillable_duration(value, definition) value == '-1' ? nil : convert_duration(value, definition) end |
- (Object) convert_nillable_string(value, definition)
Make sure that the strings '-' or '{}' or '' are parsed as a nil value.
221 222 223 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 221 def convert_nillable_string(value, definition) value =~ /-|\{\}|^$/ ? nil : value end |
- (Object) convert_timestamp(value, definition)
Do not use DateTime.parse, but parse the timestamp ourselves to return a integer to speed up parsing.
216 217 218 |
# File 'lib/request_log_analyzer/file_format/haproxy.rb', line 216 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 |