Skip to content
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

Use same logging rules as ActiveRecord #76

Merged
merged 7 commits into from
Apr 27, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/makara/logging/subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ module Makara
module Logging

module Subscriber
IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"]

def sql(event)
name = event.payload[:name]
name = [current_wrapper_name(event), name].compact.join(' ')
event.payload[:name] = name
super(event)
if IGNORE_PAYLOAD_NAMES.include?(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just use ActiveRecord::LogSubscriber::IGNORE_PAYLOAD_NAMES directly if possible. Are there AR version semantics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally did, but IGNORE_PAYLOAD_NAMES isn't present before ActiveRecord 4 and could disappear at any time, so it's a bit safer to define it ourselves. I don't feel too strongly either way.

self.class.runtime += event.duration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you just want to call super here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call.

else
name = [current_wrapper_name(event), name].compact.join(' ')
event.payload[:name] = name
super(event)
end
end

protected
Expand Down