Sha256: b2e8135aa8d20e78d394da3865f168af9155f03060a41d9d9b29d6a49f65bfee

Contents?: true

Size: 894 Bytes

Versions: 20

Compression:

Stored size: 894 Bytes

Contents

module Rack::Insight

  class MongoPanel < Panel
    require "rack/insight/panels/mongo_panel/mongo_extension"
    require "rack/insight/panels/mongo_panel/stats"

    self.has_table = false

    def self.record(command, &block)
      return block.call unless Rack::Insight.enabled?

      start_time = Time.now
      result = block.call
      total_time = Time.now - start_time
      stats.record_call(total_time * 1_000, command)
      return result
    end

    def self.reset
      Thread.current["rack-insight.mongo"] = Stats.new
    end

    def self.stats
      Thread.current["rack-insight.mongo"] ||= Stats.new
    end

    def heading
      "Mongo: %.2fms (#{self.class.stats.queries.size} calls)" % self.class.stats.time
    end

    def content
      result = render_template "panels/mongo", :stats => self.class.stats
      self.class.reset
      return result
    end

  end

end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rack-insight-0.6.4 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.6.3 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.6.2 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.30 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.29 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.28 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.27 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.26 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.25 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.24 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.23 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.22 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.21 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.20 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.19 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.18 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.17 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.16 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.15 lib/rack/insight/panels/mongo_panel.rb
rack-insight-0.5.14 lib/rack/insight/panels/mongo_panel.rb