class Sentry::Rails::LogSubscribers::ActiveRecordSubscriber
def sql(event)
-
event(ActiveSupport::Notifications::Event) -- The SQL event
def sql(event) return unless Sentry.initialized? return if logger && !logger.info? return if EXCLUDED_NAMES.include?(event.payload[:name]) sql = event.payload[:sql] statement_name = event.payload[:name] # Rails 5.0.0 doesn't include :cached in the payload, it was added in Rails 5.1 cached = event.payload.fetch(:cached, false) connection_id = event.payload[:connection_id] attributes = { sql: sql, duration_ms: duration_ms(event), cached: cached } binds = event.payload[:binds] if Sentry.configuration.send_default_pii && (binds && !binds.empty?) type_casted_binds = type_casted_binds(event) type_casted_binds.each_with_index do |value, index| bind = binds[index] name = bind.respond_to?(:name) ? bind.name : index.to_s attributes["db.query.parameter.#{name}"] = value.to_s end end attributes[:statement_name] = statement_name if statement_name && statement_name != "SQL" attributes[:connection_id] = connection_id if connection_id maybe_add_db_config_attributes(attributes, event.payload) message = build_log_message(statement_name) log_structured_event( message: message, level: :info, attributes: attributes ) rescue => e log_debug("[#{self.class}] failed to log sql event: #{e.message}") end