Class: Fluent::SqlFingerprintFilter
- Inherits:
-
Filter
- Object
- Filter
- Fluent::SqlFingerprintFilter
- Defined in:
- lib/fluent/plugin/filter_sql_fingerprint.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #filter(tag, time, record) ⇒ Object
- #fingerprint(sql) ⇒ Object
- #hash_get(hash, key) ⇒ Object
-
#initialize ⇒ SqlFingerprintFilter
constructor
A new instance of SqlFingerprintFilter.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ SqlFingerprintFilter
5 6 7 8 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 5 def initialize super require "open3" end |
Instance Method Details
#configure(conf) ⇒ Object
14 15 16 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 14 def configure(conf) super end |
#filter(tag, time, record) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 26 def filter(tag, time, record) sql = hash_get(record, @target_key) if !sql.nil? && !sql.empty? record[@added_key] = fingerprint(sql) end record end |
#fingerprint(sql) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 34 def fingerprint(sql) unless sql.empty? o, s = Open3.capture2(@fingerprint_tool_path, :stdin_data => sql) if s.success? o.chomp! sql = o unless o.empty? end end sql end |
#hash_get(hash, key) ⇒ Object
45 46 47 48 49 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 45 def hash_get(hash, key) return hash[key.to_sym] if hash.key?(key.to_sym) return hash[key] if hash.key?(key) nil end |
#shutdown ⇒ Object
22 23 24 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 22 def shutdown super end |
#start ⇒ Object
18 19 20 |
# File 'lib/fluent/plugin/filter_sql_fingerprint.rb', line 18 def start super end |