user664833
user664833

Reputation: 19505

undefined local variable or method `newrelic_ignore_enduser'

New Relic documentation says: To prevent page load timing (sometimes referred to as real user monitoring or RUM) for all actions in a controller, add a call like this to the controller class: newrelic_ignore_enduser

I added a call to newrelic_ignore_enduser as follows, and got the error undefined local variable or method 'newrelic_ignore_enduser'.

books_controller.rb

class BooksController < ApplicationController
    require 'newrelic_rpm'
    ...
    def show
        newrelic_ignore_enduser
    end
    ...
end

Gemfile

gem 'newrelic_rpm', '~> 3.9.9.275'

Question: What do I need to do (require something perhaps?) in order to be able to call this method?


Update

Oops! I had previously only included newrelic_rpm in Gemfile in the production group. I have now added it to group :development, :production do and that helped. The second thing I had to do is call the method as newrelic_ignore_enduser only: :show from the class level (as shown in the selected answer), not from within the action as I initial tried. Note that ideally I would prefer to call this method from within the action, and based on a condition.

Upvotes: 0

Views: 670

Answers (1)

Aguardientico
Aguardientico

Reputation: 7779

I think you should use newrelic_ignore_enduser as follows

class BooksController < ApplicationController
    newrelic_ignore_enduser only: :show
    ...
end

Upvotes: 3

Related Questions