<commit_before>module CartoDB
  module Resque
    module Metrics
      def self.logger
        @metric_logger ||= ::Logger.new("#{Rails.root}/log/resque_metrics.log")
      end
    end
  end
end

Resque::Metrics.on_job_complete do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_complete,
     :job_class => job_class, 
     :queue => queue, 
     :time => time}.to_json
  )
end

Resque::Metrics.on_job_enqueue do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_enqueue,
     :job_class => job_class, 
     :queue => queue, 
     :time => time}.to_json
  )
end

Resque::Metrics.on_job_fork do |job_class, queue|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_fork,
     :job_class => job_class, 
     :queue => queue}.to_json
  )
end

Resque::Metrics.on_job_failure do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_failure,
     :job_class => job_class, 
     :queue => queue, 
     :time => time}.to_json
  )
end
<commit_msg>Use import job class name instead of to_json<commit_after>module CartoDB
  module Resque
    module Metrics
      def self.logger
        @metric_logger ||= ::Logger.new("#{Rails.root}/log/resque_metrics.log")
      end
    end
  end
end

Resque::Metrics.on_job_complete do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_complete,
     :job_class => job_class.class, 
     :queue => queue, 
     :time => time}.to_json
  )
end

Resque::Metrics.on_job_enqueue do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_enqueue,
     :job_class => job_class.class,
     :queue => queue, 
     :time => time}.to_json
  )
end

Resque::Metrics.on_job_fork do |job_class, queue|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_fork,
     :job_class => job_class.class, 
     :queue => queue}.to_json
  )
end

Resque::Metrics.on_job_failure do |job_class, queue, time|
  CartoDB::Resque::Metrics.logger.info(
    {:event => :job_failure,
     :job_class => job_class.class, 
     :queue => queue, 
     :time => time}.to_json
  )
end

{'fraction_non_alphanumeric': 0.14365152919369786, 'fraction_numerical': 0.0, 'mean_word_length': 3.3440643863179074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, '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': '2106813', 'n_tokens_mistral': 805, 'n_tokens_neox': 787, 'n_words': 149}