Sha256: db1c7278372795aab65a356e22fb5023307586baa6e841f7da22ff4716ee7485

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

module MongoProfiler
  class Stats
    def initialize(stats_client)
      @stats_client = stats_client
    end

    def populate(_caller, total_time)
      file   = sanitaze_stat_key _caller.file.split('/').last
      method = sanitaze_stat_key _caller.method

      stat_name     = "mongo_profiler.#{MongoProfiler.application_name}.#{file}.#{method}"

      total_time_ms = total_time * 1000

      @stats_client.increment stat_name
      @stats_client.timing    stat_name, total_time_ms
    end

    private

    def sanitaze_stat_key(key)
      key.gsub(/\W/, '_')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo_profiler-0.0.1 lib/mongo_profiler/stats.rb