Class: Dexter::PgStatActivityParser

Inherits:
LogParser
  • Object
show all
Defined in:
lib/dexter/pg_stat_activity_parser.rb

Constant Summary

Constants inherited from LogParser

LogParser::DETAIL_LINE, LogParser::LINE_SEPERATOR, LogParser::REGEX

Constants included from Logging

Logging::COLOR_CODES

Instance Method Summary collapse

Methods inherited from LogParser

#initialize

Methods included from Logging

#colorize, #log, #output

Constructor Details

This class inherits a constructor from Dexter::LogParser

Instance Method Details

#performObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dexter/pg_stat_activity_parser.rb', line 3

def perform
  queries = {}

  loop do
    new_queries = {}
    @logfile.stat_activity.each do |row|
      new_queries[row["id"]] = row
    end

    # store queries after they complete
    queries.each do |id, row|
      unless new_queries[id]
        process_entry(row["query"], row["duration_ms"].to_f)
      end
    end

    queries = new_queries

    sleep(1)
  end
end