New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Relic support #128

Closed
fbjork opened this Issue Jul 31, 2012 · 60 comments

Comments

Projects
None yet
@fbjork

fbjork commented Jul 31, 2012

Does Puma work with New Relic out of the box? I cannot get it to report data from my app.

@rafaelss

This comment has been minimized.

Show comment
Hide comment
@rafaelss

rafaelss Aug 2, 2012

after almost a whole day trying to figure this out, I got this working.
newrelic gem doesn't recognize puma as a dispatcher, so you need to configure it manually. you can do that by adding dispatcher: puma to newrelic.yml or setting NEWRELIC_DISPATCHER env variable, like NEWRELIC_DISPATCHER=puma rails s puma.

rafaelss commented Aug 2, 2012

after almost a whole day trying to figure this out, I got this working.
newrelic gem doesn't recognize puma as a dispatcher, so you need to configure it manually. you can do that by adding dispatcher: puma to newrelic.yml or setting NEWRELIC_DISPATCHER env variable, like NEWRELIC_DISPATCHER=puma rails s puma.

@kostia

This comment has been minimized.

Show comment
Hide comment
@kostia

kostia Aug 9, 2012

In my case the environment variable helped. But I had to add following initializer config/initializers/newrelic.rb:

if defined?(NewRelic) && defined?(Puma)
  NewRelic::Agent.after_fork force_reconnect: true
end

I also had to put gem 'newrelic_rpm'outside of the group :production section, for otherwise the assets wont compile...

kostia commented Aug 9, 2012

In my case the environment variable helped. But I had to add following initializer config/initializers/newrelic.rb:

if defined?(NewRelic) && defined?(Puma)
  NewRelic::Agent.after_fork force_reconnect: true
end

I also had to put gem 'newrelic_rpm'outside of the group :production section, for otherwise the assets wont compile...

@davidray

This comment has been minimized.

Show comment
Hide comment
@davidray

davidray Aug 25, 2012

I can't get this to work with any of these approaches

davidray commented Aug 25, 2012

I can't get this to work with any of these approaches

@kostia

This comment has been minimized.

Show comment
Hide comment
@kostia

kostia Aug 25, 2012

@davidray

  1. Rails-Version?
  2. RPM-Version?
  3. Puma-Version?

Please try following:

  1. Add NEWRELIC_DISPATCHER=puma to /etc/environment
  2. Add the above Initializer
  3. Move gem 'newrelic_rpm outside of the group production
  4. Add dispatcher: 'puma' to config/newrelic.yml
  5. Restart, reload everything...

kostia commented Aug 25, 2012

@davidray

  1. Rails-Version?
  2. RPM-Version?
  3. Puma-Version?

Please try following:

  1. Add NEWRELIC_DISPATCHER=puma to /etc/environment
  2. Add the above Initializer
  3. Move gem 'newrelic_rpm outside of the group production
  4. Add dispatcher: 'puma' to config/newrelic.yml
  5. Restart, reload everything...
@davidray

This comment has been minimized.

Show comment
Hide comment
@davidray

davidray Aug 25, 2012

#1 and #4 fixed it - I already had the other two things in place. I did #1 a bit differently though - I set the value in my command to start up puma (we use foreman to manage it) and it's all fixed. Thanks!

davidray commented Aug 25, 2012

#1 and #4 fixed it - I already had the other two things in place. I did #1 a bit differently though - I set the value in my command to start up puma (we use foreman to manage it) and it's all fixed. Thanks!

@haberbyte

This comment has been minimized.

Show comment
Hide comment
@haberbyte

haberbyte Sep 2, 2012

Had the same issue. It really only works for me if the env variable NEWRELIC_DISPATCHER=puma is set...
It would be nice if a "dispatcher: puma" line in rewrelic.yml would suffice.

Not sure why it doesn't work without the env var!?

haberbyte commented Sep 2, 2012

Had the same issue. It really only works for me if the env variable NEWRELIC_DISPATCHER=puma is set...
It would be nice if a "dispatcher: puma" line in rewrelic.yml would suffice.

Not sure why it doesn't work without the env var!?

@evanphx

This comment has been minimized.

Show comment
Hide comment
@evanphx

evanphx Sep 2, 2012

Member

I'm currently debugging this and plan to make some adjustments so it works out of the box. Should be out soon.

Member

evanphx commented Sep 2, 2012

I'm currently debugging this and plan to make some adjustments so it works out of the box. Should be out soon.

@jpascal

This comment has been minimized.

Show comment
Hide comment
@jpascal

jpascal Sep 3, 2012

Contributor

+1 NewRelic work with NEWRELIC_DISPATCHER=puma.

Contributor

jpascal commented Sep 3, 2012

+1 NewRelic work with NEWRELIC_DISPATCHER=puma.

@davidcelis

This comment has been minimized.

Show comment
Hide comment
@davidcelis

davidcelis Sep 27, 2012

Even with the ENV variable or dispatcher: key in my newrelic.yml file, as well as the after_fork block in an initializer, I can't get the newrelic_rpm agent to report data. Any status on this?

davidcelis commented Sep 27, 2012

Even with the ENV variable or dispatcher: key in my newrelic.yml file, as well as the after_fork block in an initializer, I can't get the newrelic_rpm agent to report data. Any status on this?

@rengland-newrelic

This comment has been minimized.

Show comment
Hide comment
@rengland-newrelic

rengland-newrelic Oct 2, 2012

There has been a report that manually including NEWRELIC_DISPATCHER=puma in the actual start-up script of puma as opposed to an environment variable was required, in one instance

rengland-newrelic commented Oct 2, 2012

There has been a report that manually including NEWRELIC_DISPATCHER=puma in the actual start-up script of puma as opposed to an environment variable was required, in one instance

@tscolari

This comment has been minimized.

Show comment
Hide comment
@tscolari

tscolari Oct 8, 2012

I got this error message when using the above initializer:

Plugin not initialized

I was trying to deploy with capistrano (it was from running assets precompile rake task)

tscolari commented Oct 8, 2012

I got this error message when using the above initializer:

Plugin not initialized

I was trying to deploy with capistrano (it was from running assets precompile rake task)

@davidcelis

This comment has been minimized.

Show comment
Hide comment
@davidcelis

davidcelis Oct 8, 2012

@rengland-newrelic I've tried all "solutions" listed in this thread: the environment variable, setting it manually in the start-up script, including dispatcher: puma in newrelic.yml. None of them have worked.

EDIT: false alarm. it looks like setting the environment variable in my startup script did work. I'm reporting data. Cool.

davidcelis commented Oct 8, 2012

@rengland-newrelic I've tried all "solutions" listed in this thread: the environment variable, setting it manually in the start-up script, including dispatcher: puma in newrelic.yml. None of them have worked.

EDIT: false alarm. it looks like setting the environment variable in my startup script did work. I'm reporting data. Cool.

@ehlertij

This comment has been minimized.

Show comment
Hide comment
@ehlertij

ehlertij Oct 11, 2012

Contributor

Adding ENV['NEWRELIC_DISPATCHER'] = 'puma' to my config/boot.rb and dispatcher: 'puma' to config/newrelic.yml did the trick for me.

Rails 3.2.8, Puma 1.6.3

Contributor

ehlertij commented Oct 11, 2012

Adding ENV['NEWRELIC_DISPATCHER'] = 'puma' to my config/boot.rb and dispatcher: 'puma' to config/newrelic.yml did the trick for me.

Rails 3.2.8, Puma 1.6.3

@evanphx evanphx closed this in 2280b68 Oct 20, 2012

@concept47

This comment has been minimized.

Show comment
Hide comment
@concept47

concept47 Jan 22, 2013

This doesn't work out the box for me with puma 2.0.0.b4, rails 3.2.11 and ruby 2.0.0.rc1
Works with Ruby 1.9.3 but not Ruby 2.0.0.

Here's the stack trace
https://gist.github.com/4592477

concept47 commented Jan 22, 2013

This doesn't work out the box for me with puma 2.0.0.b4, rails 3.2.11 and ruby 2.0.0.rc1
Works with Ruby 1.9.3 but not Ruby 2.0.0.

Here's the stack trace
https://gist.github.com/4592477

@aaronchi

This comment has been minimized.

Show comment
Hide comment
@aaronchi

aaronchi Feb 27, 2013

No longer working under ruby 2.0.0

aaronchi commented Feb 27, 2013

No longer working under ruby 2.0.0

@davidcelis

This comment has been minimized.

Show comment
Hide comment
@davidcelis

davidcelis Feb 27, 2013

@concept47 based on that stack trace, it's likely a bug in the Ruby agent rather than in puma. We're taking a look.

davidcelis commented Feb 27, 2013

@concept47 based on that stack trace, it's likely a bug in the Ruby agent rather than in puma. We're taking a look.

@concept47

This comment has been minimized.

Show comment
Hide comment
@concept47

concept47 Feb 27, 2013

@davidcelis ... you're absolutely right, I ran it by newrelic and its an issue with ruby 2.0.0 and their newrelic agent

concept47 commented Feb 27, 2013

@davidcelis ... you're absolutely right, I ran it by newrelic and its an issue with ruby 2.0.0 and their newrelic agent

@mpoisot

This comment has been minimized.

Show comment
Hide comment
@mpoisot

mpoisot Mar 29, 2013

Looks like New Relic Agent 3.5.8.72 added support for Ruby 2.0.0. Agent 3.6.0.78 added support for "thread safety" and specifically mentions Puma. I'm still on Ruby 1.9.3 so I can't confirm anything.

Unfortunately looks like I still have to set NEWRELIC_DISPATCHER=puma.

https://newrelic.com/docs/releases/ruby

mpoisot commented Mar 29, 2013

Looks like New Relic Agent 3.5.8.72 added support for Ruby 2.0.0. Agent 3.6.0.78 added support for "thread safety" and specifically mentions Puma. I'm still on Ruby 1.9.3 so I can't confirm anything.

Unfortunately looks like I still have to set NEWRELIC_DISPATCHER=puma.

https://newrelic.com/docs/releases/ruby

@concept47

This comment has been minimized.

Show comment
Hide comment
@concept47

concept47 Mar 29, 2013

I can confirm it works now.
Frickin awesome!!!

concept47 commented Mar 29, 2013

I can confirm it works now.
Frickin awesome!!!

@samg

This comment has been minimized.

Show comment
Hide comment
@samg

samg Apr 16, 2013

I wanted to let you all know I've just pushed a beta version of newrelic_rpm which should work in puma without needing to set NEWRELIC_DISPATCHER variables or other shenanigans.

More specifically, I've simplified the logic that controls when the agent attempts to start, and switched to blacklisting environments (e.g. rails console, irb, certain rake tasks) instead of trying to detect if the agent is in a "supported environment".

I'd be very interested in getting some feedback on whether this works for your puma apps and simplifies their deployment.
https://rubygems.org/gems/newrelic_rpm/versions/3.6.1.85.beta

Thanks!

samg commented Apr 16, 2013

I wanted to let you all know I've just pushed a beta version of newrelic_rpm which should work in puma without needing to set NEWRELIC_DISPATCHER variables or other shenanigans.

More specifically, I've simplified the logic that controls when the agent attempts to start, and switched to blacklisting environments (e.g. rails console, irb, certain rake tasks) instead of trying to detect if the agent is in a "supported environment".

I'd be very interested in getting some feedback on whether this works for your puma apps and simplifies their deployment.
https://rubygems.org/gems/newrelic_rpm/versions/3.6.1.85.beta

Thanks!

@jjb

This comment has been minimized.

Show comment
Hide comment
@jjb

jjb May 24, 2013

Contributor

@samg it's working for my app when running in a webserver, but seems to not be detected during asset compilation when deploying to heroku. "No known dispatcher detected"

Contributor

jjb commented May 24, 2013

@samg it's working for my app when running in a webserver, but seems to not be detected during asset compilation when deploying to heroku. "No known dispatcher detected"

@samg

This comment has been minimized.

Show comment
Hide comment
@samg

samg May 25, 2013

@jjb - thanks for the update. I sounds like that's the intended behavior. The recent change I described makes it so the agent will start up even if it doesn't detect a "known dispatcher" as long as it's in a monitored environment. It will still log the message you described. I haven't added any specific code to detect puma. I've just made it so we don't need to detect every web server out there in order to start.

Thanks!

samg commented May 25, 2013

@jjb - thanks for the update. I sounds like that's the intended behavior. The recent change I described makes it so the agent will start up even if it doesn't detect a "known dispatcher" as long as it's in a monitored environment. It will still log the message you described. I haven't added any specific code to detect puma. I've just made it so we don't need to detect every web server out there in order to start.

Thanks!

@pawel2105

This comment has been minimized.

Show comment
Hide comment
@pawel2105

pawel2105 Jul 11, 2013

Using Ruby 2.0.0-p247, Rails 4.0.0 and newrelic_rpm (3.6.5.130)

I've added dispatcher: 'puma' to the newrelic.yml file and added ENV['NEWRELIC_DISPATCHER'] = 'puma' to the boot.rb file and the newrelic log file on the server reports:

[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Sidekiq instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Net instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Dalli Memcache instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Rails 4 Controller instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing ActiveRecord 4 instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing Rails4 Error instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing Rails 4 view instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Finished instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Reporting to: https://rpm.newrelic.com/accounts/xxx/applications/xxx
[07/11/13 14:32:47 +0000 domain.com (12336)] INFO : Installing Sinatra instrumentation

Still not seeing anything for the application even after another cap deploy. Production mode does have monitor_mode: true set in the yml file.

pawel2105 commented Jul 11, 2013

Using Ruby 2.0.0-p247, Rails 4.0.0 and newrelic_rpm (3.6.5.130)

I've added dispatcher: 'puma' to the newrelic.yml file and added ENV['NEWRELIC_DISPATCHER'] = 'puma' to the boot.rb file and the newrelic log file on the server reports:

[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Sidekiq instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Net instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Dalli Memcache instrumentation
[07/11/13 14:32:44 +0000 domain.com (12336)] INFO : Installing Rails 4 Controller instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing ActiveRecord 4 instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing Rails4 Error instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Installing Rails 4 view instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Finished instrumentation
[07/11/13 14:32:45 +0000 domain.com (12336)] INFO : Reporting to: https://rpm.newrelic.com/accounts/xxx/applications/xxx
[07/11/13 14:32:47 +0000 domain.com (12336)] INFO : Installing Sinatra instrumentation

Still not seeing anything for the application even after another cap deploy. Production mode does have monitor_mode: true set in the yml file.

@masterkain

This comment has been minimized.

Show comment
Hide comment
@masterkain

masterkain Jul 11, 2013

Getting this without tampering anything, but no report in newrelic_rpm (3.6.5.130), Rails 3-2-stable, Ruby 2.0.0-p247
Same config worked out of the box with Rainbows!:

INFO : Starting the New Relic agent in "staging" environment.
INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "staging" section of your newrelic.yml.
INFO : Reading configuration from config/newrelic.yml
INFO : Enabling the Request Sampler.
INFO : Environment: staging
INFO : Dispatcher: puma
INFO : Application: Myapp (Staging)
INFO : Installing ActiveRecord instrumentation
INFO : Installing Sidekiq instrumentation
INFO : Installing Sinatra instrumentation
INFO : Installing Net instrumentation
INFO : Installing middleware-based Excon instrumentation
INFO : Installing Dalli Memcache instrumentation
INFO : Installing Rails 3 Controller instrumentation
INFO : Installing Rails 3.1/3.2 view instrumentation
INFO : Installing Rails3 Error instrumentation
INFO : Finished instrumentation
INFO : Reporting to: https://rpm.newrelic.com/accounts/xxxx/applications/xxx

masterkain commented Jul 11, 2013

Getting this without tampering anything, but no report in newrelic_rpm (3.6.5.130), Rails 3-2-stable, Ruby 2.0.0-p247
Same config worked out of the box with Rainbows!:

INFO : Starting the New Relic agent in "staging" environment.
INFO : To prevent agent startup add a NEWRELIC_ENABLE=false environment variable or modify the "staging" section of your newrelic.yml.
INFO : Reading configuration from config/newrelic.yml
INFO : Enabling the Request Sampler.
INFO : Environment: staging
INFO : Dispatcher: puma
INFO : Application: Myapp (Staging)
INFO : Installing ActiveRecord instrumentation
INFO : Installing Sidekiq instrumentation
INFO : Installing Sinatra instrumentation
INFO : Installing Net instrumentation
INFO : Installing middleware-based Excon instrumentation
INFO : Installing Dalli Memcache instrumentation
INFO : Installing Rails 3 Controller instrumentation
INFO : Installing Rails 3.1/3.2 view instrumentation
INFO : Installing Rails3 Error instrumentation
INFO : Finished instrumentation
INFO : Reporting to: https://rpm.newrelic.com/accounts/xxxx/applications/xxx
@concept47

This comment has been minimized.

Show comment
Hide comment
@concept47

concept47 Jul 13, 2013

I'm having the same problem as @pawel2105
Ruby 2.0.0 p247, rails 3.2.12, puma 2.3.2

new relic log looks like this

[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Environment: production
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Dispatcher: puma
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Application: xxxxx
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Net instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing ActiveRecord instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails 3 Controller instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails 3.1/3.2 view instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails3 Error instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Finished instrumentation
[07/13/13 22:15:30 +0000 xxx (27173)] INFO : Reporting to: https://rpm.newrelic.com/accounts/xxxx/applications/xxxx

but I'm getting no data to newrelic whatsoever

When I downgrade to puma 2.0.1, it works just fine.

concept47 commented Jul 13, 2013

I'm having the same problem as @pawel2105
Ruby 2.0.0 p247, rails 3.2.12, puma 2.3.2

new relic log looks like this

[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Environment: production
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Dispatcher: puma
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Application: xxxxx
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Net instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing ActiveRecord instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails 3 Controller instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails 3.1/3.2 view instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Installing Rails3 Error instrumentation
[07/13/13 22:15:29 +0000 xxx (27173)] INFO : Finished instrumentation
[07/13/13 22:15:30 +0000 xxx (27173)] INFO : Reporting to: https://rpm.newrelic.com/accounts/xxxx/applications/xxxx

but I'm getting no data to newrelic whatsoever

When I downgrade to puma 2.0.1, it works just fine.

@ehutzelman

This comment has been minimized.

Show comment
Hide comment
@ehutzelman

ehutzelman Jul 14, 2013

I'm seeing the same thing. Using Ruby 2.0.0-p247, Rails 4.0.0 and newrelic_rpm (3.6.5.130). In New Relic, there is no data except for it detecting a single instance pegged at 100MB. I'm running 4 workers.

ehutzelman commented Jul 14, 2013

I'm seeing the same thing. Using Ruby 2.0.0-p247, Rails 4.0.0 and newrelic_rpm (3.6.5.130). In New Relic, there is no data except for it detecting a single instance pegged at 100MB. I'm running 4 workers.

@masterkain

This comment has been minimized.

Show comment
Hide comment
@masterkain

masterkain Jul 15, 2013

I see lot of this in the puma err log:

==> rails/log/puma.err.log <==
The following keys are invalid: :newrelic_trace_data

might be a hint.

Also at the same time:

==> rails/log/newrelic_agent.log <==
[07/15/13 15:45:26 +0000 staging (19945)] ERROR : Caught exception in trace_method_execution footer.
[07/15/13 15:45:26 +0000 staging (19945)] ERROR : RuntimeError: unbalanced pop from blame stack, got net_http, expected method_tracer

masterkain commented Jul 15, 2013

I see lot of this in the puma err log:

==> rails/log/puma.err.log <==
The following keys are invalid: :newrelic_trace_data

might be a hint.

Also at the same time:

==> rails/log/newrelic_agent.log <==
[07/15/13 15:45:26 +0000 staging (19945)] ERROR : Caught exception in trace_method_execution footer.
[07/15/13 15:45:26 +0000 staging (19945)] ERROR : RuntimeError: unbalanced pop from blame stack, got net_http, expected method_tracer
@jasonrclark

This comment has been minimized.

Show comment
Hide comment
@jasonrclark

jasonrclark Jul 16, 2013

Hey all. I'm an engineer on the Ruby agent team at New Relic and I'm looking into this today.

Can those who are seeing the issue confirm whether they're using clustered mode with multiple workers? If so, we've encountered an issue with that recently. While we're getting a fix ready, you can work around it by:

Adding :require => false to your gem 'newrelic_rpm' line in your Gemfile

In your puma configuration file, add a block like this:

on_worker_boot do
  require 'newrelic_rpm'
  NewRelic::Agent.manual_start
end

If anyone is not running in clustered mode but has problems with recent versions, I'm especially interested to hear about that too.

jasonrclark commented Jul 16, 2013

Hey all. I'm an engineer on the Ruby agent team at New Relic and I'm looking into this today.

Can those who are seeing the issue confirm whether they're using clustered mode with multiple workers? If so, we've encountered an issue with that recently. While we're getting a fix ready, you can work around it by:

Adding :require => false to your gem 'newrelic_rpm' line in your Gemfile

In your puma configuration file, add a block like this:

on_worker_boot do
  require 'newrelic_rpm'
  NewRelic::Agent.manual_start
end

If anyone is not running in clustered mode but has problems with recent versions, I'm especially interested to hear about that too.

@rafbm

This comment has been minimized.

Show comment
Hide comment
@rafbm

rafbm Jul 16, 2013

Thank you so much @jasonrclark for this timely intervention. Just switched to clustered mode and was experiencing this issue. Everything just works when following your instructions!

rafbm commented Jul 16, 2013

Thank you so much @jasonrclark for this timely intervention. Just switched to clustered mode and was experiencing this issue. Everything just works when following your instructions!

@mrbrdo

This comment has been minimized.

Show comment
Hide comment
@mrbrdo

mrbrdo Sep 20, 2013

Hm, today I restarted puma on the server just in case and now it's not detecting unicorn anymore. I think I did a stop & start yesterday too, but maybe I just did a restart, not sure. Anyway it seems newrelic was then detecting unicorn because the gem was present (even though puma was present too).

Before I added the environment variable, I didn't get any data in newrelic (but logs were showing that newrelic did start).

mrbrdo commented Sep 20, 2013

Hm, today I restarted puma on the server just in case and now it's not detecting unicorn anymore. I think I did a stop & start yesterday too, but maybe I just did a restart, not sure. Anyway it seems newrelic was then detecting unicorn because the gem was present (even though puma was present too).

Before I added the environment variable, I didn't get any data in newrelic (but logs were showing that newrelic did start).

@ponny

This comment has been minimized.

Show comment
Hide comment
@ponny

ponny Nov 29, 2013

What exactly do I need to do now? I've added ENV['NEWRELIC_DISPATCHER'] = 'puma' to boot.rb and dispatcher: puma to my newrelic.yml.

Is there anything else I need to do? I'm getting practically no data (just a cpm count - everything else is zero).

Update: Puma 1.6.3 Ruby 1.9.3 Rails 4.0.1 w/ Resque Sinatra app

ponny commented Nov 29, 2013

What exactly do I need to do now? I've added ENV['NEWRELIC_DISPATCHER'] = 'puma' to boot.rb and dispatcher: puma to my newrelic.yml.

Is there anything else I need to do? I'm getting practically no data (just a cpm count - everything else is zero).

Update: Puma 1.6.3 Ruby 1.9.3 Rails 4.0.1 w/ Resque Sinatra app

@haggen

This comment has been minimized.

Show comment
Hide comment
@haggen

haggen Nov 29, 2013

Hey @ponny how is your launch script, I mean what do you use to boot up the server ? Also, do you know the version of your new_relic Gem ?

haggen commented Nov 29, 2013

Hey @ponny how is your launch script, I mean what do you use to boot up the server ? Also, do you know the version of your new_relic Gem ?

@seuros

This comment has been minimized.

Show comment
Hide comment
@seuros

seuros Nov 29, 2013

@ponny New Relic gem work out of the box with puma.

seuros commented Nov 29, 2013

@ponny New Relic gem work out of the box with puma.

@ponny

This comment has been minimized.

Show comment
Hide comment
@ponny

ponny Nov 29, 2013

Hi @haggen I use some jungle scripts from the puma project. New relic gem v 3.6.9.171

@seuros Except when it doesn't ;-)

ponny commented Nov 29, 2013

Hi @haggen I use some jungle scripts from the puma project. New relic gem v 3.6.9.171

@seuros Except when it doesn't ;-)

@madwork

This comment has been minimized.

Show comment
Hide comment
@madwork

madwork Nov 30, 2013

@ponny newrelic agent v3.6.9.171 don't work (no auto_instrument) with daemonize option (#335) in single mode (workers 0), I did not test in cluster mode.

I use upstart to daemonize puma and newrelic agent works as expected.

madwork commented Nov 30, 2013

@ponny newrelic agent v3.6.9.171 don't work (no auto_instrument) with daemonize option (#335) in single mode (workers 0), I did not test in cluster mode.

I use upstart to daemonize puma and newrelic agent works as expected.

@ponny

This comment has been minimized.

Show comment
Hide comment
@ponny

ponny Dec 1, 2013

@madwork So what exactly do I need to do to fix it? I don't see how switching to upstart would make a difference.

ponny commented Dec 1, 2013

@madwork So what exactly do I need to do to fix it? I don't see how switching to upstart would make a difference.

@madwork

This comment has been minimized.

Show comment
Hide comment
@madwork

madwork Dec 2, 2013

@ponny Set daemonize option to false will fix the newrelic agent issue, but puma will not start as a daemon, so to fix this behavior, I use upstart to daemonize puma (and start/stop/monitor puma process).
I made a gist for this issue: http://git.io/UjuxwQ

madwork commented Dec 2, 2013

@ponny Set daemonize option to false will fix the newrelic agent issue, but puma will not start as a daemon, so to fix this behavior, I use upstart to daemonize puma (and start/stop/monitor puma process).
I made a gist for this issue: http://git.io/UjuxwQ

@jasonrclark

This comment has been minimized.

Show comment
Hide comment
@jasonrclark

jasonrclark Dec 2, 2013

@ponny If you set the daemonize option true in your puma configuration, newrelic_rpm as of 3.6.9.171 doesn't detect properly. We're working on a fix, but don't have it ready yet.

@madwork's suggestion or something similar should fix things. As long as Puma doesn't daemonize itself, you should be fine--another process managing Puma can daemonize/background all it wants, as long as Puma itself isn't calling Process.daemon.

An alternative some people have had success with is setting workers 1 in your puma configuration, but that requires Puma 2 and you said you're using 1.6.3, so that's probably not an easy option.

jasonrclark commented Dec 2, 2013

@ponny If you set the daemonize option true in your puma configuration, newrelic_rpm as of 3.6.9.171 doesn't detect properly. We're working on a fix, but don't have it ready yet.

@madwork's suggestion or something similar should fix things. As long as Puma doesn't daemonize itself, you should be fine--another process managing Puma can daemonize/background all it wants, as long as Puma itself isn't calling Process.daemon.

An alternative some people have had success with is setting workers 1 in your puma configuration, but that requires Puma 2 and you said you're using 1.6.3, so that's probably not an easy option.

jeroenj added a commit to jeroenj/stringer that referenced this issue Jan 2, 2014

[live] Set puma_cmd in capistrano to use the config and start one thr…
…ead with one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128
@thehappycoder

This comment has been minimized.

Show comment
Hide comment
@thehappycoder

thehappycoder Jan 14, 2014

Setting workers to 1 worked for me as well and -w 2 works too.
newrelic_rpm-3.7.1.182
puma-2.6.0

puma -t 8:50 -e production -b unix:///tmp/utro.0.sock -w 1 -d && puma -t 8:50 -e production -b unix:///tmp/utro.1.sock -w 1 -d

but this also works
puma -t 8:50 -e production -b unix:///tmp/utro.0.sock -w 2 -d

thehappycoder commented Jan 14, 2014

Setting workers to 1 worked for me as well and -w 2 works too.
newrelic_rpm-3.7.1.182
puma-2.6.0

puma -t 8:50 -e production -b unix:///tmp/utro.0.sock -w 1 -d && puma -t 8:50 -e production -b unix:///tmp/utro.1.sock -w 1 -d

but this also works
puma -t 8:50 -e production -b unix:///tmp/utro.0.sock -w 2 -d

@nTraum

This comment has been minimized.

Show comment
Hide comment
@nTraum

nTraum Mar 22, 2014

Can confirm that setting workers > 0 fixes the issue.

bundle show | egrep \(relic\|puma\)
  * capistrano-newrelic (0.0.8)
  * capistrano3-puma (0.2.2)
  * newrelic_rpm (3.7.3.204)
  * puma (2.8.1)

nTraum commented Mar 22, 2014

Can confirm that setting workers > 0 fixes the issue.

bundle show | egrep \(relic\|puma\)
  * capistrano-newrelic (0.0.8)
  * capistrano3-puma (0.2.2)
  * newrelic_rpm (3.7.3.204)
  * puma (2.8.1)

jeroenj added a commit to jeroenj/stringer that referenced this issue Apr 15, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Apr 15, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue May 10, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue May 16, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue May 19, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue May 27, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Jun 9, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Jul 16, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Aug 20, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Sep 26, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

jeroenj added a commit to jeroenj/stringer that referenced this issue Sep 26, 2014

Set puma_cmd in capistrano to use the config and start one thread wit…
…h one worker.

The thread/worker config is a workaround for newrelic:
puma/puma#128

Tomohiro added a commit to Tomohiro/plate that referenced this issue Feb 23, 2015

dentarg added a commit to Starkast/wikimum that referenced this issue Dec 6, 2015

michaelpreston added a commit to onthebeach/new_relic_test_app that referenced this issue Nov 28, 2016

michaelpreston added a commit to onthebeach/new_relic_test_app that referenced this issue Nov 28, 2016

michaelpreston added a commit to onthebeach/new_relic_test_app that referenced this issue Nov 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment