Sha256: 002ed79aeb88352f7fdb4edb7e7bab095c4d9af55ce442253e233b72c51d5063

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.

DependencyDetection.defer do
  @name = :sunspot

  depends_on do
    defined?(::Sunspot)
  end

  executes do
    ::NewRelic::Agent.logger.info 'Installing Rails Sunspot instrumentation'
    deprecation_msg = 'The instrumentation for Sunspot is deprecated.' \
      ' It will be removed in version 9.0.0.' \

    ::NewRelic::Agent.logger.log_once(
      :warn,
      :deprecated_sunspot,
      deprecation_msg
    )

    ::NewRelic::Agent.record_metric("Supportability/Deprecated/Sunspot", 1)
  end

  executes do
    ::Sunspot.module_eval do
      class << self
        %w[index index!].each do |method|
          add_method_tracer method, 'SolrClient/Sunspot/index'
        end
        add_method_tracer :commit, 'SolrClient/Sunspot/commit'

        %w[search more_like_this].each do |method|
          add_method_tracer method, 'SolrClient/Sunspot/query'
        end
        %w[remove remove! remove_by_id remove_by_id! remove_all remove_all!].each do |method|
          add_method_tracer method, 'SolrClient/Sunspot/delete'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
newrelic_rpm-8.8.0 lib/new_relic/agent/instrumentation/sunspot.rb
newrelic_rpm-8.7.0 lib/new_relic/agent/instrumentation/sunspot.rb