<commit_before>module RpmContrib
  module Instrumentation
    module Mongo
      # Mongo Instrumentation contributed by <NAME>

      if defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
        ::Mongo::Connection.class_eval do
          include NewRelic::Agent::MethodTracer

          def instrument_with_newrelic_trace(name, payload = {}, &blk)
            collection = payload[:collection]
            if collection == '$cmd'
              f = payload[:selector].first
              name, collection = f if f
            end

            trace_execution_scoped("Database/#{collection}/#{name}") do
              t0 = Time.now
              res = instrument_without_newrelic_trace(name, payload, &blk)
              NewRelic::Agent.instance.transaction_sampler.notice_nosql(payload.inspect, (Time.now - t0).to_f)
              res
            end
          end

          alias_method :instrument_without_newrelic_trace, :instrument
          alias_method :instrument, :instrument_with_newrelic_trace
        end<commit_msg>swap notice_nosql out for notice_sql for now - sadly not implemented in the UI yet<commit_after>module RpmContrib
  module Instrumentation
    module Mongo
      # Mongo Instrumentation contributed by <NAME>

      if defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
        ::Mongo::Connection.class_eval do
          include NewRelic::Agent::MethodTracer

          def instrument_with_newrelic_trace(name, payload = {}, &blk)
            collection = payload[:collection]
            if collection == '$cmd'
              f = payload[:selector].first
              name, collection = f if f
            end

            trace_execution_scoped("Database/#{collection}/#{name}") do
              t0 = Time.now
              res = instrument_without_newrelic_trace(name, payload, &blk)
              NewRelic::Agent.instance.transaction_sampler.notice_sql(payload.inspect, nil, (Time.now - t0).to_f)
              res
            end
          end

          alias_method :instrument_without_newrelic_trace, :instrument
          alias_method :instrument, :instrument_with_newrelic_trace
        end
{'fraction_non_alphanumeric': 0.0847145488029466, 'fraction_numerical': 0.001841620626151013, 'mean_word_length': 2.390015600624025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3092824', 'n_tokens_mistral': 591, 'n_tokens_neox': 576, 'n_words': 129}