Module: Appsignal::Hooks::DataMapperLogListener

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

Constant Summary collapse

SQL_CLASSES =
[
  "DataObjects::SqlServer::Connection",
  "DataObjects::Sqlite3::Connection",
  "DataObjects::Mysql::Connection",
  "DataObjects::Postgres::Connection"
]

Instance Method Summary collapse

Instance Method Details

#log(message) ⇒ Object



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

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