<commit_before>require 'new_relic/agent/method_tracer'

DependencyDetection.defer do
  @name = :moped

  depends_on do
    puts 'Checking Moped dependency'
    should_run = defined?(::Moped) && !NewRelic::Control.instance['disable_moped']
    puts "Checking Moped dependency -> #{should_run}"
    should_run
  end

  executes do
    puts 'Installing Moped instrumentation'
    NewRelic::Agent.logger.info 'Installing Moped instrumentation'
    puts 'Installing Moped instrumentation'
  end

  executes do
    puts "Moped Nearly Installed"
    Moped::Node.class_eval do
      include NewRelic::Moped::Instrumentation
      alias_method :logging_without_newrelic_trace, :logging
      alias_method :logging, :logging_with_newrelic_trace
    end
    puts "Moped Installed"
  end
end

module NewRelic
  module Moped
    module Instrumentation
      def logging_with_newrelic_trace(operations, &blk)
        puts 'Logging Moped'
        operation_name, collection = determine_operation_and_collection(operations.first)
        log_statement = operations.first.log_inspect.encode("UTF-8")

        metric = case operation_name
                 when 'INSERT', 'UPDATE', 'CREATE'  then 'save'
                 when 'QUERY'                       then 'find'
                 when 'DELETE'                      then 'destroy'<commit_msg>Removed puts<commit_after>require 'new_relic/agent/method_tracer'

DependencyDetection.defer do
  @name = :moped

  depends_on do
    defined?(::Moped) && !NewRelic::Control.instance['disable_moped']
  end

  executes do
    NewRelic::Agent.logger.info 'Installing Moped instrumentation'
  end

  executes do
    Moped::Node.class_eval do
      include NewRelic::Moped::Instrumentation
      alias_method :logging_without_newrelic_trace, :logging
      alias_method :logging, :logging_with_newrelic_trace
    end
  end
end

module NewRelic
  module Moped
    module Instrumentation
      def logging_with_newrelic_trace(operations, &blk)
        operation_name, collection = determine_operation_and_collection(operations.first)
        log_statement = operations.first.log_inspect.encode("UTF-8")

        metric = case operation_name
                 when 'INSERT', 'UPDATE', 'CREATE'  then 'save'
                 when 'QUERY'                       then 'find'
                 when 'DELETE'                      then 'destroy'
{'fraction_non_alphanumeric': 0.07809847198641766, 'fraction_numerical': 0.0008488964346349745, 'mean_word_length': 2.9283333333333332, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2217027', 'n_tokens_mistral': 688, 'n_tokens_neox': 679, 'n_words': 157}