-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add configuration to filter out sql queries #60
Add configuration to filter out sql queries #60
Conversation
596539f
to
3d0b023
Compare
|
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.
LGTM! Thank you for adding the README section as well (complete with a ref to the memory leak bug 🙇)
|
||
# Initialise configuration with fallback to default values | ||
def setup(config) | ||
Lograge::Sql.formatter = config.formatter || default_formatter | ||
Lograge::Sql.extract_event = config.extract_event || default_extract_event | ||
Lograge::Sql.min_duration_ms = config.min_duration_ms || 0 | ||
Lograge::Sql.query_filter = config.query_filter | ||
Lograge::Sql.query_name_denylist = config.query_name_denylist || [/\ASCHEMA\z/, /\ASolidCable::/] |
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.
@fdaugs @iMacTia
Perhaps this could be better for performance and avoiding runtime error.
Lograge::Sql.query_name_denylist = config.query_name_denylist || [/\ASCHEMA\z/, /\ASolidCable::/] | |
Lograge::Sql.query_name_denylist = Regexp.union(config.query_name_denylist || [/\ASCHEMA\z/, /\ASolidCable::/]) |
related: rails/rails#46452
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 pull request introduces a new feature to filter SQL queries by name using a denylist configuration.
SQL Query Name Denylist
query_name_denylist
configuration option to filter out SQL queries by name using regular expressions.valid?
method inlib/lograge/active_record_log_subscriber.rb
to use the denylist for filtering queries.query_name_denylist
attribute to theLograge::Sql
configuration and set default values for it.query_name_denylist
in the test setup to ensure it has default values.Default value
I addition to SCHEMA-queries, queries with names starting with SolidCable:: are now also skipped. This is to prevent a issue #59 that causes a memory leak.
Additional Information
I testing this implementation of this gem locally in my application and it successfully skips all queries of solid cable.