Class: Skylight::Normalizers::SQL Private
- Inherits:
-
Normalizer
- Object
- Normalizer
- Skylight::Normalizers::SQL
- Defined in:
- lib/skylight/normalizers/sql.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Normalizer for SQL requests
Direct Known Subclasses
ActiveRecord::SQL, DataMapper::SQL, Skylight::Normalizers::Sequel::SQL
Constant Summary collapse
- CAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"db.sql.query"
Instance Attribute Summary
Attributes inherited from Normalizer
Instance Method Summary collapse
Methods inherited from Normalizer
#initialize, #normalize_after, #normalize_with_meta, register
Methods included from Util::Logging
#config_for_logging, #debug, #error, #fmt, #info, #log, #log_context, #raise_on_error?, #t, #trace, #trace?, #warn
Constructor Details
This class inherits a constructor from Skylight::Normalizers::Normalizer
Instance Method Details
#normalize(_trace, _name, payload) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/skylight/normalizers/sql.rb', line 17 def normalize(_trace, _name, payload) return :skip if payload[:name] == "SCHEMA" || payload[:name] == "CACHE" title = payload[:name] || "SQL" # We can only handle UTF-8 encoded strings. # (Construction method here avoids extra allocations) sql = String.new.concat("<sk-sql>", payload[:sql], "</sk-sql>").force_encoding(Encoding::UTF_8) unless sql.valid_encoding? if config[:log_sql_parse_errors] config.logger.error "[#{Skylight::SqlLexError.formatted_code}] Unable to extract binds from non-UTF-8 " \ "query. " \ "encoding=#{payload[:sql].encoding.name} " \ "sql=#{payload[:sql].inspect} " end sql = nil end [CAT, title, sql] end |