Kouhei Sutou 2019-05-09 18:49:36 +0900 (Thu, 09 May 2019) Revision: e5d207ccad4ea83cd2f79dd6fdabae4296a59073 https://github.com/groonga/groonga-query-log/commit/e5d207ccad4ea83cd2f79dd6fdabae4296a59073 Message: Add support for :raw_message in operation Modified files: lib/groonga-query-log/parser.rb lib/groonga-query-log/statistic.rb test/test-parser.rb Modified: lib/groonga-query-log/parser.rb (+9 -6) =================================================================== --- lib/groonga-query-log/parser.rb 2019-05-09 18:48:47 +0900 (2a3365a) +++ lib/groonga-query-log/parser.rb 2019-05-09 18:49:36 +0900 (a3198b4) @@ -119,11 +119,13 @@ module GroongaQueryLog return unless /\A (?<elapsed>\d+) \ - (?<name>[a-zA-Z._-]+) - (?<sub_name_before>\[.+?\])? - (?:\((?<n_records>\d+)\))? - (?<sub_name_after>\[.+?\])? - (?::\ (?<extra>.*))? + (?<raw_message> + (?<name>[a-zA-Z._-]+) + (?<sub_name_before>\[.+?\])? + (?:\((?<n_records>\d+)\))? + (?<sub_name_after>\[.+?\])? + (?::\ (?<extra>.*))? + ) /x =~ rest statistic = @parsing_statistics[context_id] return if statistic.nil? @@ -131,7 +133,8 @@ module GroongaQueryLog statistic.add_operation(:name => full_name, :elapsed => elapsed.to_i, :n_records => n_records.to_i, - :extra => extra) + :extra => extra, + :raw_message => raw_message) when "<" return unless /\A(\d+) rc=(-?\d+)/ =~ rest elapsed = $1 Modified: lib/groonga-query-log/statistic.rb (+1 -0) =================================================================== --- lib/groonga-query-log/statistic.rb 2019-05-09 18:48:47 +0900 (38072b4) +++ lib/groonga-query-log/statistic.rb 2019-05-09 18:49:36 +0900 (b3a826a) @@ -85,6 +85,7 @@ module GroongaQueryLog :n_records => operation[:n_records], :extra => operation[:extra], :slow? => slow_operation?(relative_elapsed_in_seconds), + :raw_message => operation[:raw_message], } yield parsed_operation end Modified: test/test-parser.rb (+20 -9) =================================================================== --- test/test-parser.rb 2019-05-09 18:48:47 +0900 (a21a5b1) +++ test/test-parser.rb 2019-05-09 18:49:36 +0900 (79c92e4) @@ -280,15 +280,21 @@ class ParserTest < Test::Unit::TestCase 2019-05-09 18:44:25.991431|0x7fff5e4a3060|<000000007759904 rc=0 LOG operations = statistics.first.operations.collect do |operation| - operation[:name] + [operation[:name], operation[:raw_message]] end expected = [ - "flush[Lexicon.sources_value]", - "flush[(anonymous:table:dat_key)]", - "flush[(anonymous:column:var_size)]", - "flush[(anonymous:table:hash_key)]", - "flush[(anonymous:column:var_size)]", - "flush[(DB)]", + ["flush[Lexicon.sources_value]", + "flush[Lexicon.sources_value]"], + ["flush[(anonymous:table:dat_key)]", + "flush[(anonymous:table:dat_key)]"], + ["flush[(anonymous:column:var_size)]", + "flush[(anonymous:column:var_size)]"], + ["flush[(anonymous:table:hash_key)]", + "flush[(anonymous:table:hash_key)]"], + ["flush[(anonymous:column:var_size)]", + "flush[(anonymous:column:var_size)]"], + ["flush[(DB)]", + "flush[(DB)]"], ] assert_equal(expected, operations) end @@ -302,10 +308,15 @@ class ParserTest < Test::Unit::TestCase 2017-12-11 09:37:04.517999|0x7fffc430dff0|<000000001061996 rc=-22 LOG operations = statistics.first.operations.collect do |operation| - [operation[:name], operation[:n_records], operation[:extra]] + [ + operation[:name], + operation[:n_records], + operation[:extra], + operation[:raw_message], + ] end expected = [ - ["load", 3, "[1][2][3]"], + ["load", 3, "[1][2][3]", "load(3): [1][2][3]"], ] assert_equal(expected, operations) end -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190509/83980d82/attachment-0001.html>