Skip to content

Commit

Permalink
Add Solr client support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kayser committed May 13, 2010
1 parent 217ad22 commit 39938d5
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
v2.12.0
* support basic instrumentation for ActsAsSolr and Sunspot

v2.11.3
* fix bug in startup when running JRuby

Expand Down
45 changes: 45 additions & 0 deletions lib/new_relic/agent/instrumentation/acts_as_solr.rb
@@ -0,0 +1,45 @@
if defined?(::ActsAsSolr)

module NewRelic
module Instrumentation
module ActsAsSolrInstrumentation
module ParserMethodsInstrumentation
def parse_query_with_newrelic(*args)
self.class.trace_execution_scoped(["SolrClient/ActsAsSolr/query"]) do
t0 = Time.now
begin
parse_query_without_newrelic(*args)
ensure
NewRelic::Agent.instance.transaction_sampler.notice_nosql(args.first.inspect, (Time.now - t0).to_f) rescue nil
end
end

end
end
end
end
end

module ActsAsSolr
module ParserMethods #:nodoc
include NewRelic::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
alias :parse_query_without_newrelic :parse_query
alias :parse_query :parse_query_with_newrelic
end

module ClassMethods #:nodoc
%w[find_by_solr find_id_by_solr multi_solr_search count_by_solr].each do |method|
add_method_tracer method, 'SolrClient/ActsAsSolr/query'
end
add_method_tracer :rebuild_solr_index, 'SolrClient/ActsAsSolr/index'
end

module CommonMethods #:nodoc
add_method_tracer :solr_add, 'SolrClient/ActsAsSolr/add'
add_method_tracer :solr_delete, 'SolrClient/ActsAsSolr/delete'
add_method_tracer :solr_commit, 'SolrClient/ActsAsSolr/commit'
add_method_tracer :solr_optimize, 'SolrClient/ActsAsSolr/optimize'
end
end
end

17 changes: 17 additions & 0 deletions lib/new_relic/agent/instrumentation/sunspot.rb
@@ -0,0 +1,17 @@
if defined?(::Sunspot)
::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
4 changes: 2 additions & 2 deletions lib/new_relic/version.rb
Expand Up @@ -2,8 +2,8 @@
module NewRelic
module VERSION #:nodoc:
MAJOR = 2
MINOR = 11
TINY = 3
MINOR = 12
TINY = 0
BUILD = nil #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
end
Expand Down
8 changes: 5 additions & 3 deletions newrelic_rpm.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{newrelic_rpm}
s.version = "2.11.3"
s.version = "2.12.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Bill Kayser"]
s.date = %q{2010-05-01}
s.date = %q{2010-05-13}
s.description = %q{New Relic RPM is a Ruby performance management system, developed by
New Relic, Inc (http://www.newrelic.com). RPM provides you with deep
information about the performance of your Ruby on Rails or Merb
Expand Down Expand Up @@ -38,6 +38,7 @@ http://github.com/newrelic/rpm/tree/master.
"lib/new_relic/agent/error_collector.rb",
"lib/new_relic/agent/instrumentation/active_merchant.rb",
"lib/new_relic/agent/instrumentation/active_record_instrumentation.rb",
"lib/new_relic/agent/instrumentation/acts_as_solr.rb",
"lib/new_relic/agent/instrumentation/authlogic.rb",
"lib/new_relic/agent/instrumentation/controller_instrumentation.rb",
"lib/new_relic/agent/instrumentation/data_mapper.rb",
Expand All @@ -55,6 +56,7 @@ http://github.com/newrelic/rpm/tree/master.
"lib/new_relic/agent/instrumentation/rails3/action_controller.rb",
"lib/new_relic/agent/instrumentation/rails3/errors.rb",
"lib/new_relic/agent/instrumentation/sinatra.rb",
"lib/new_relic/agent/instrumentation/sunspot.rb",
"lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb",
"lib/new_relic/agent/method_tracer.rb",
"lib/new_relic/agent/sampler.rb",
Expand Down Expand Up @@ -191,7 +193,7 @@ http://github.com/newrelic/rpm/tree/master.
s.post_install_message = %q{
Please see http://support.newrelic.com/faqs/docs/ruby-agent-release-notes
for a complete description of the features and enhancements available
in version 2.11 of the Ruby Agent.
in version 2.12 of the Ruby Agent.
For details on this specific release, refer to the CHANGELOG file.
Expand Down

0 comments on commit 39938d5

Please sign in to comment.