Class: GroongaQueryLog::Command::Analyzer::CSVReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/groonga-query-log/command/analyzer/reporter/csv.rb

Instance Attribute Summary

Attributes inherited from Reporter

#output, #slow_operation_threshold, #slow_response_threshold

Instance Method Summary collapse

Methods inherited from Reporter

#each, #report, #report_statistics

Constructor Details

#initialize(statistics, options) ⇒ CSVReporter

Returns a new instance of CSVReporter.



25
26
27
28
29
30
# File 'lib/groonga-query-log/command/analyzer/reporter/csv.rb', line 25

def initialize(statistics, options)
  super
  if @options[:report_command_line].nil?
    @report_command_line = false
  end
end

Instance Method Details

#finishObject



59
60
61
# File 'lib/groonga-query-log/command/analyzer/reporter/csv.rb', line 59

def finish
  @csv.close
end

#report_statistic(statistic) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/groonga-query-log/command/analyzer/reporter/csv.rb', line 46

def report_statistic(statistic)
  record = [
    format_time(statistic.start_time),
    format_time(statistic.end_time),
    statistic.elapsed_in_seconds,
    statistic.return_code,
    statistic.slow?,
    statistic.command.command_name,
  ]
  record << statistic.raw_command if @report_command_line
  @csv << record
end

#report_summaryObject



63
64
# File 'lib/groonga-query-log/command/analyzer/reporter/csv.rb', line 63

def report_summary
end

#startObject



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/groonga-query-log/command/analyzer/reporter/csv.rb', line 32

def start
  @csv = CSV.new(@output)
  header = [
    "start_time",
    "end_time",
    "elapsed",
    "return_code",
    "slow",
    "command_name",
  ]
  header << "command_line" if @report_command_line
  @csv << header
end