Module: Appsignal::Hooks::DataMapperLogListener Private

Defined in:
lib/appsignal/integrations/data_mapper.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

SQL_CLASSES =

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.

[
  "DataObjects::SqlServer::Connection",
  "DataObjects::Sqlite3::Connection",
  "DataObjects::Mysql::Connection",
  "DataObjects::Postgres::Connection"
].freeze

Instance Method Summary collapse

Instance Method Details

#log(message) ⇒ Object

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.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/appsignal/integrations/data_mapper.rb', line 14

def log(message)
  # If scheme is SQL-like, try to sanitize it, otherwise clear the body
  if SQL_CLASSES.include?(self.class.to_s)
    body_content = message.query
    body_format = Appsignal::EventFormatter::SQL_BODY_FORMAT
  else
    body_content = ""
    body_format = Appsignal::EventFormatter::DEFAULT
  end

  # Record event
  Appsignal::Transaction.current.record_event(
    "query.data_mapper",
    "DataMapper Query",
    body_content,
    message.duration,
    body_format
  )
  super
end