Skip to content

Commit

Permalink
Merge pull request #507 from airbrake/sql-filter-ignore
Browse files Browse the repository at this point in the history
filters/sql: ignore more irrelevant queries from Postgres
  • Loading branch information
kyrylo authored Oct 4, 2019
2 parents 9523415 + 713c667 commit 5ed4998
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
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

0 comments on commit 5ed4998

Please sign in to comment.