Browse files

Add riak_client and ripple support.

  • Loading branch information...
1 parent b59436b commit 70e4fee56394583eb3f1cd63f8be1b1ef54ef02d @alinpopa committed Apr 23, 2012
View
2 .gitignore
@@ -0,0 +1,2 @@
+*.swp
+
View
0 README.md → README.txt
File renamed without changes.
View
3 lib/newrelic-riak.rb
@@ -0,0 +1,3 @@
+require 'newrelic_riak/riak_client'
+require 'newrelic_riak/ripple'
+
View
50 lib/newrelic_riak/riak_client.rb
@@ -0,0 +1,50 @@
+require 'new_relic/agent/method_tracer'
+
+DependencyDetection.defer do
+ @name = :riak_client
+
+ depends_on do
+ defined?(::Riak) and not NewRelic::Control.instance['disable_riak_client']
+ end
+
+ executes do
+ NewRelic::Agent.logger.debug 'Installing Riak client instrumentation'
+ end
+
+ executes do
+ backend_tracers = proc do
+ add_method_tracer :ping, 'Database/Riak/ping'
+
+ add_method_tracer :list_buckets, 'Database/Riak/list_buckets'
+ add_method_tracer :get_bucket_props, 'Database/Riak/get_bucket_props'
+ add_method_tracer :set_bucket_props, 'Database/Riak/set_bucket_props'
+
+ add_method_tracer :mapred, 'Database/Riak/mapred'
+
+ add_method_tracer :list_keys, 'Database/Riak/list_keys'
+ add_method_tracer :fetch_object, 'Database/Riak/fetch_object'
+ add_method_tracer :reload_object, 'Database/Riak/reload_object'
+ add_method_tracer :store_object, 'Database/Riak/store_object'
+ add_method_tracer :delete_object, 'Database/Riak/delete_object'
+ end
+
+ ::Riak::Client::BeefcakeProtobuffsBackend.class_eval &backend_tracers
+ ::Riak::Client::BeefcakeProtobuffsBackend.class_eval do
+ add_method_tracer :server_info, 'Database/Riak/server_info'
+ add_method_tracer :get_client_id, 'Database/Riak/get_client_id'
+ add_method_tracer :set_client_id, 'Database/Riak/set_client_id'
+ end
+ ::Riak::Client::HTTPBackend.class_eval &backend_tracers
+ ::Riak::Client::HTTPBackend.class_eval do
+ add_method_tracer :stats, 'Database/Riak/stats'
+ add_method_tracer :link_walk, 'Database/Riak/link_walk'
+ add_method_tracer :get_index, 'Database/Riak/get_index'
+ add_method_tracer :search, 'Database/Riak/search'
+ add_method_tracer :update_search_index, 'Database/Riak/update_search_index'
+ end
+
+ ::Riak::RObject.class_eval do
+ add_method_tracer :serialize, 'Database/Riak/serialize'
+ end
+ end
+end
View
40 lib/newrelic_riak/ripple.rb
@@ -0,0 +1,40 @@
+require 'new_relic/agent/method_tracer'
+
+DependencyDetection.defer do
+ @name = :ripple
+
+ depends_on do
+ defined?(::Ripple) and not
+ NewRelic::Control.instance['disable_ripple']
+ end
+
+ executes do
+ NewRelic::Agent.logger.debug 'Installing Ripple instrumentation'
+ end
+
+ executes do
+ ::Ripple::Callbacks.class_eval do
+ add_method_tracer :valid?, 'Database/Riak/Ripple/valid?'
+ end
+
+ ::Ripple::Document::Persistence::ClassMethods.class_eval do
+ add_method_tracer :create, 'Database/Riak/Ripple/create'
+ add_method_tracer :destroy_all, 'Database/Riak/Ripple/destroy_all'
+ end
+
+
+ (defined?(::Ripple::Document::Persistence::InstanceMethods) ?
+ ::Ripple::Document::Persistence::InstanceMethods : ::Ripple::Document::Persistence).class_eval do
+ add_method_tracer :really_save, 'Database/Riak/Ripple/really_save'
+ add_method_tracer :reload, 'Database/Riak/Ripple/reload'
+ add_method_tracer :destroy!, 'Database/Riak/Ripple/destroy'
+ add_method_tracer :update_attribute, 'Database/Riak/Ripple/update_attribute'
+ add_method_tracer :update_attributes, 'Database/Riak/Ripple/update_attributes'
+ end
+
+ ::Ripple::Document::Finders::ClassMethods.class_eval do
+ add_method_tracer :find, 'Database/Riak/Ripple/find'
+ add_method_tracer :list, 'Database/Riak/Ripple/list'
+ end
+ end
+end
View
21 newrelic-riak.gemspec
@@ -0,0 +1,21 @@
+Gem::Specification.new do |s|
+ s.name = "newrelic-riak"
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Alin Popa"]
+ s.date = "2012-04-23"
+ s.description = "NewRelic instrumentation for Riak."
+ s.email = ["alin.popa@gmail.com"]
+ s.extra_rdoc_files = ["README.txt"]
+ s.files = ["README.txt", "Rakefile", "lib/newrelic-riak.rb", "lib/newrelic_riak/riak_client.rb", "lib/newrelic_riak/ripple.rb", "newrelic-riak.gemspec", "test/test_newrelic_riak.rb"]
+ s.homepage = "https://github.com/alinpopa/newrelic-riak"
+ s.rdoc_options = ["--main", "README.txt"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = "newrelic-riak"
+ s.rubygems_version = "1.8.17"
+ s.summary = "NewRelic instrumentation for Riak."
+ #s.test_files = ["test/test_newrelic_riak_client.rb", "test/test_newrelic_ripple.rb"]
+ s.add_runtime_dependency(%q<newrelic_rpm>, ["~> 3.0"])
+end
+

0 comments on commit 70e4fee

Please sign in to comment.