Browse files

Merge pull request #2 from dblock/disabled

Set `DISABLE_NEW_RELIC_GRAPE` at runtime to disable instrumentation.
  • Loading branch information...
2 parents fde55c5 + bfdd8b7 commit 4bf928a3abd8a99d0200b0025ba76b4eb8856167 @flyerhzm flyerhzm committed Dec 27, 2012
Showing with 15 additions and 9 deletions.
  1. +2 −1 CHANGELOG.md
  2. +8 −3 README.md
  3. +4 −4 lib/newrelic-grape/instrument.rb
  4. +1 −1 spec/spec_helper.rb
3 CHANGELOG.md
@@ -1,7 +1,8 @@
Next Release
============
-* Changed namespace from `Newrelic` to `NewRelic` to be consistent with the RPM gem - [@dblock](https://github.com/dblock)
+* Changed namespace from `Newrelic` to `NewRelic` to be consistent with the RPM gem - [@dblock](https://github.com/dblock).
+* Set `DISABLE_NEW_RELIC_GRAPE` to disable instrumentation - [@dblock](https://github.com/dblock).
1.0.0 (12/18/2012)
==================
View
11 README.md
@@ -20,13 +20,18 @@ Or install it yourself as:
That's it.
+## Disabling Instrumentation
+
+Set `disable_grape` in `newrelic.yml` or `ENV['DISABLE_NEW_RELIC_GRAPE']` to disable instrumentation.
+
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
-3. Commit your changes (`git commit -am 'Add some feature'`)
-4. Push to the branch (`git push origin my-new-feature`)
-5. Create new Pull Request
+3. Update `CHANGELOG.md` describing your changes
+4. Commit your changes (`git commit -am 'Add some feature'`)
+5. Push to the branch (`git push origin my-new-feature`)
+6. Create new Pull Request
[0]: https://github.com/intridea/grape
[1]: http://artsy.github.com/blog/2012/11/29/measuring-performance-in-grape-apis-with-new-relic/
View
8 lib/newrelic-grape/instrument.rb
@@ -6,7 +6,6 @@ class Grape < ::Grape::Middleware::Base
def call!(env)
@env = env
-
@newrelic_request = ::Rack::Request.new(env)
trace_options = {
:category => :rack,
@@ -25,6 +24,7 @@ def request_path
def request_method
@newrelic_request.request_method
end
+
end
end
end
@@ -34,7 +34,7 @@ def request_method
@name = :grape
depends_on do
- defined?(::Grape) and not ::NewRelic::Control.instance['disable_grape']
+ defined?(::Grape) && ! ::NewRelic::Control.instance['disable_grape'] && ! ENV['DISABLE_NEW_RELIC_GRAPE']
end
executes do
@@ -43,10 +43,10 @@ def request_method
executes do
::Grape::Endpoint.class_eval do
- alias_method :origin_build_middleware, :build_middleware
+ alias_method :grape_build_middleware, :build_middleware
def build_middleware
- builder = origin_build_middleware
+ builder = grape_build_middleware
builder.use ::NewRelic::Agent::Instrumentation::Grape
builder
end
View
2 spec/spec_helper.rb
@@ -12,4 +12,4 @@
require 'grape'
require 'newrelic_rpm'
-require 'newrelic-grape'
+require 'newrelic-grape'

0 comments on commit 4bf928a

Please sign in to comment.