Sha256: 6a5765626f91c4341877e07465f165a490db1769369f82fc1161a4989d30e70e
Contents?: true
Size: 1.35 KB
Versions: 14
Compression:
Stored size: 1.35 KB
Contents
# frozen_string_literal: true require "json" module Skylight module Normalizers # Normalizer for SQL requests class SQL < Normalizer CAT = "db.sql.query" # @param trace [Skylight::Messages::Trace::Builder] ignored, only present to match API # @param name [String] ignored, only present to match API # @param payload [Hash] # @option payload [String] [:name] The SQL operation # @option payload [Hash] [:binds] The bound parameters # @return [Array] 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 end end end
Version data entries
14 entries across 14 versions & 1 rubygems