Permalink
Browse files

use newrelic grape middleware before Grape::Middleware::Error #5

  • Loading branch information...
1 parent 3a560cc commit fdb9112ddf28fac037f5d99acb5b80d96e1092f0 @flyerhzm flyerhzm committed Feb 25, 2013
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/newrelic-grape/instrument.rb
View
15 lib/newrelic-grape/instrument.rb
@@ -30,7 +30,7 @@ def request_method
end
end
-DependencyDetection.defer do
+DependencyDetection.defer do
@name = :grape
depends_on do
@@ -42,13 +42,14 @@ def request_method
end
executes do
- ::Grape::Endpoint.class_eval do
- alias_method :grape_build_middleware, :build_middleware
+ ::Rack::Builder.class_eval do
+ alias_method :origin_use, :use
- def build_middleware
- builder = grape_build_middleware
- builder.use ::NewRelic::Agent::Instrumentation::Grape
- builder
+ def use(middleware, *args, &block)
+ if middleware == Grape::Middleware::Error
+ use ::NewRelic::Agent::Instrumentation::Grape
+ end
+ origin_use(middleware, *args, &block)
end
end
end

0 comments on commit fdb9112

Please sign in to comment.