-
Notifications
You must be signed in to change notification settings - Fork 170
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
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5267eb5
Use same logging rules as ActiveRecord
ankane ed3a789
Use super
ankane 456f77f
Better flow
ankane 94c8655
Add failing test to demonstrate 'SET' matching bug
righi 445fcf2
Add test for case-insensitive matching on 'SET'
righi 35b8f4d
Improve match of 'SET' statements
righi 2f9ae53
Remove unnecessary caret in SQL_ALL_MATCHERS
righi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
self.class.runtime += event.duration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't you just want to call super here? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.