lib/remnant/base.rb in remnant-0.3.1 vs lib/remnant/base.rb in remnant-0.3.2
- old
+ new
@@ -29,19 +29,22 @@
extra_remnant_key = Remnant::Discover.results.delete(:extra_remnant_key)
if ::Rails.env.production? || ::Rails.env.staging? || ::Rails.env.demo?
# only log if above sample rate
if @sample_counter > configuration.sample_rate
+ key_prefix = [
+ Remnant.configuration.tag,
+ Remnant.configuration.env,
+ extra_remnant_key
+ ].compact.join('.')
+
Remnant::Discover.results.map do |remnant_key, ms|
- key = [
- Remnant.configuration.tag,
- Remnant.configuration.env,
- extra_remnant_key,
- remnant_key
- ].compact.join('.')
+ Remnant.handler.timing("#{key_prefix}.#{remnant_key}", ms.to_i)
+ end
- Remnant.handler.timing(key, ms.to_i)
+ if Remnant::Database.enabled?
+ Remnant.handler.timing("#{key_prefix}.db", Remnant::Database.queries.total_time.to_i)
end
@sample_counter = 0
else
@sample_counter += 1
@@ -67,10 +70,10 @@
end
end
if Remnant::Database.enabled?
Rails.logger.info ""
- Rails.logger.info("#{color(false, true)}---- Database (%.2fms) -----#{color(true)}" % (Remnant::Database.queries.map(&:time).sum * 1000))
+ Rails.logger.info("#{color(false, true)}---- Database (%.2fms) -----#{color(true)}" % Remnant::Database.queries.total_time)
if Remnant::Database.suppress?
Rails.logger.info "queries suppressed in development mode"
else
Remnant::Database.queries.map do |query|
Rails.logger.info("#{color}%.2fms#{color(true)}\t#{query.sql}" % (query.time * 1000))