Reputation: 48490
I am investigating some performance issue in my Ruby on Rails application. NewRelic is showing me a lot of a particular object having its updated_at attribute updated many times. I'm not entirely sure where this is happening. I decided one way to try to locate this manifestation would be to create an observer for my model and grab a stack trace whenever that attribute gets modified. So I have something like:
class FooObserver < ActiveRecord::Observer
def before_save(foo)
if foo.updated_at_changed?
Rails.logger.info("Foo changed - print stack trace??")
end
end
end
What's the best way to get this stack trace at this point? Or the caller?
Any advice would be great. I need to stop having this update happen over and over, it's hurting performance.
Upvotes: 2
Views: 227