lib/dexter/collector.rb in pgdexter-0.4.3 vs lib/dexter/collector.rb in pgdexter-0.5.0
- old
+ new
@@ -6,22 +6,22 @@
@mutex = Mutex.new
@min_time = options[:min_time] * 60000 # convert minutes to ms
@min_calls = options[:min_calls]
end
- def add(query, duration)
+ def add(query, total_time, calls = 1)
fingerprint =
begin
PgQuery.fingerprint(query)
rescue PgQuery::ParseError
# do nothing
end
return unless fingerprint
@top_queries[fingerprint] ||= {calls: 0, total_time: 0}
- @top_queries[fingerprint][:calls] += 1
- @top_queries[fingerprint][:total_time] += duration
+ @top_queries[fingerprint][:calls] += calls
+ @top_queries[fingerprint][:total_time] += total_time
@top_queries[fingerprint][:query] = query
@mutex.synchronize do
@new_queries << fingerprint
end
end