<commit_before>module Rack::Insight

  class CachePanel < Panel
    require "rack/insight/panels/cache_panel/panel_app"
    require "rack/insight/panels/cache_panel/stats"

    def initialize(app)
      super

      probe(self) do
        instrument("Memcached") do
          instance_probe :decrement, :get, :increment, :set, :add,
            :replace, :delete, :prepend, :append
        end

        instrument("MemCache") do
          instance_probe :decr, :get, :get_multi, :incr, :set, :add, :delete
        end

        instrument("Dalli::Client") do
          instance_probe :perform
        end
      end

      table_setup("cache")
    end

    def request_start(env, start)
      @stats = Stats.new
    end

    def request_finish(env, st, hd, bd, timing)
      store(env, @stats)
    end

    def after_detect(method_call, timing, args, result)
      method, key = method_call.method, args.first
      if(defined? Dalli and Dalli::Client === method_call.object)
        method, key = args[0], args[1]
      end
      logger.info{ "Cache panel got #{method} #{key.inspect}" } if verbose(:high)
      @stats.record_call(method, timing.duration, !result.nil?, key)
    end

    def panel_app
      PanelApp.new
    end

    def name
      "cache"
    end

    def heading_for_request(number)
      stats = retrieve(number).first

      "Cache: %.2fms (#{stats.queries.size} calls)" % stats.time
    end

    def content_for_request(number)
      # TODO: What is this syntax with the double {{}}?
      logger.debug{{ :req_num => number }} if verbose(:debug)<commit_msg>Removed :req_num logging from cache_panel<commit_after>module Rack::Insight

  class CachePanel < Panel
    require "rack/insight/panels/cache_panel/panel_app"
    require "rack/insight/panels/cache_panel/stats"

    def initialize(app)
      super

      probe(self) do
        instrument("Memcached") do
          instance_probe :decrement, :get, :increment, :set, :add,
            :replace, :delete, :prepend, :append
        end

        instrument("MemCache") do
          instance_probe :decr, :get, :get_multi, :incr, :set, :add, :delete
        end

        instrument("Dalli::Client") do
          instance_probe :perform
        end
      end

      table_setup("cache")
    end

    def request_start(env, start)
      @stats = Stats.new
    end

    def request_finish(env, st, hd, bd, timing)
      store(env, @stats)
    end

    def after_detect(method_call, timing, args, result)
      method, key = method_call.method, args.first
      if(defined? Dalli and Dalli::Client === method_call.object)
        method, key = args[0], args[1]
      end
      logger.info{ "Cache panel got #{method} #{key.inspect}" } if verbose(:high)
      @stats.record_call(method, timing.duration, !result.nil?, key)
    end

    def panel_app
      PanelApp.new
    end

    def name
      "cache"
    end

    def heading_for_request(number)
      stats = retrieve(number).first

      "Cache: %.2fms (#{stats.queries.size} calls)" % stats.time
    end

    def content_for_request(number)
{'fraction_non_alphanumeric': 0.1131767775603392, 'fraction_numerical': 0.0019569471624266144, 'mean_word_length': 2.5456647398843932, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6424004', 'n_tokens_mistral': 995, 'n_tokens_neox': 956, 'n_words': 242}