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

filters/sql: ignore more irrelevant queries from Postgres #507

Merged
merged 1 commit into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Airbrake Ruby Changelog

### master

* Added more irrelevant SQL queries to the query stats ignore list
([#507](https://github.com/airbrake/airbrake-ruby/pull/507))

### [v4.7.0][v4.7.0] (October 3, 2019)

* Improved grouping of some SQL queries
Expand Down
5 changes: 4 additions & 1 deletion lib/airbrake-ruby/filters/sql_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ class SqlFilter
/\ASET/i,
/\ASHOW/i,
/\AWITH/i,
/FROM pg_attribute/i
/FROM pg_attribute/i,
/FROM pg_index/i,
/FROM pg_class/i,
/FROM pg_type/i
].freeze

def initialize(dialect)
Expand Down
16 changes: 15 additions & 1 deletion spec/filters/sql_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,22 @@
'cons AS ( SELECT conrelid, connum, row_number() OVER() AS rownum FROM ' \
'pk_constraint ) SELECT attr.attname FROM pg_attribute attr INNER JOIN ' \
'cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.connum ' \
'ORDER BY cons.rownum'
'ORDER BY cons.rownum',

'SELECT c.relname FROM pg_class c LEFT JOIN pg_namespace n ON ' \
'n.oid = c.relnamespace WHERE n.nspname = ANY (?)',

'SELECT a.attname FROM ( SELECT indrelid, indkey, generate_subscripts(?) ' \
'idx FROM pg_index WHERE indrelid = ?::regclass AND indisprimary ) i ' \
'JOIN pg_attribute a ON a.attrelid = i.indrelid AND ' \
'a.attnum = i.indkey[i.idx] ORDER BY i.idx',

'SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, ' \
't.typtype, t.typbasetype FROM pg_type as t LEFT JOIN pg_range as r ON ' \
'oid = rngtypid WHERE t.typname IN (?) OR t.typtype IN (?) OR t.typinput ' \
'= ?::regprocedure OR t.typelem != ?',

'SELECT t.oid, t.typname FROM pg_type as t WHERE t.typname IN (?)'
].each do |query|
include_examples 'query blacklisting', query, should_ignore: true
end
Expand Down