Sutto / rocket_pants

API building tools on top of ActionController. Also, an awesome name.
MIT License
981 stars 130 forks source link

RocketPants::Instrumentation not displaying Controller Runtimes #107

Open ahegyi opened 10 years ago

ahegyi commented 10 years ago

Apologies in advance if I'm doing this wrong... I'm a bit unfamiliar with the way that instrumentation works in Rails.

With a basic setup, it appears that Rocket Pants is not properly injecting controller runtimes, because (I believe) that Rocket Pants has its own separate instrumentation class, RocketPants::Instrumentation.

For example, the following request to a Rocket Pants endpoint returns one time without a breakdown:

Started GET "/api/1/users/self" for 127.0.0.1 at 2014-07-10 16:41:38 -0700
Completed 200 OK in 42.4ms

However, a typical ActionController descendant would leave a log entry like this:

Started GET "/marks/1000" for 127.0.0.1 at 2014-07-10 16:41:19 -0700
Completed 200 OK in 231.0ms (Views: 36.9ms | ActiveRecord: 57.4ms | Solr: 0.0ms)

How can we automatically have RocketPants tie into any injections from ActionController instrumentation add-ons, such as ActiveRecord and Solr?

I've been fudging around with this, but I can't seem to figure out the root issue.

Strangely enough, I was able to workaround for ActiveRecord by adding include ActiveRecord::Railties::ControllerRuntime into my base API controller (descending from RocketPants::Base), but not for Solr, when I tried adding include Sunspot::Rails::Railties::ControllerRuntime.

(Could this be because of some disparities between ActionController::Instrumentation and RocketPants::Instrumentation?)

Sutto commented 10 years ago

I believe it's because we're not directly including all of the runtime mixins, so controllers that manually mix this in to ActionController::Base don't include it in RocketPants::Base unfortunately.