Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Not Threadsafe #3

Open
jasonlynes opened this issue Feb 19, 2013 · 3 comments
Open

Not Threadsafe #3

jasonlynes opened this issue Feb 19, 2013 · 3 comments

Comments

@jasonlynes
Copy link

Ironically this gem is not threadsafe, preventing me from using it to compare times pre- and post- puma and threadsafe on my app.

The error is get is:

... .rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.10/lib/action_dispatch/middleware/stack.rb:120:in `assert_index': No such middleware to insert after: "Rack::Lock" (RuntimeError)

Simply uncomment config.threadsafe! in production.rb and bundle this gem and start your server to experience the error.

@jasonlynes
Copy link
Author

I've made an adjustment to railtie.rb to not rely on Rack:Lock, will continue to test:

https://github.com/jasonlynes/heroku-true-relic/blob/master/lib/heroku-true-relic/railtie.rb

@a-warner
Copy link
Contributor

@jasonlynes I think we should be instrumenting after Rack::Lock if rails is in threadsafe! mode. So I think we need something like:

if Rails.configuration.middleware.include? 'Rack::Lock'
  Rails.configuration.middleware.insert_after 'Rack::Lock', "HerokuTrueRelic::QueueTimeLogger"
else
  Rails.configuration.middleware.insert 0, "HerokuTrueRelic::QueueTimeLogger"
end

obviously this code would be different for rails 3, but the idea is the same

@mhodgson
Copy link

We're using this and it seems to work:

module HerokuTrueRelic
  class Railtie < Rails::Railtie
    initializer 'heroku_true_relic.add_queue_time_logger' do |app|
      app.config.middleware.insert_before "Rack::Runtime", "HerokuTrueRelic::QueueTimeLogger"
    end
  end
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants