Class: Appsignal::EventFormatter::ActiveRecord::SqlFormatter

Inherits:
Appsignal::EventFormatter show all
Defined in:
lib/appsignal/event_formatter/active_record/sql_formatter.rb

Constant Summary

Constants inherited from Appsignal::EventFormatter

DEFAULT, SQL_BODY_FORMAT

Instance Method Summary collapse

Methods inherited from Appsignal::EventFormatter

register, registered?, unregister

Instance Method Details

#format(payload) ⇒ Object



27
28
29
# File 'lib/appsignal/event_formatter/active_record/sql_formatter.rb', line 27

def format(payload)
  [payload[:name], payload[:sql], SQL_BODY_FORMAT]
end

#opentelemetry_attributes(payload) ⇒ Object

The payload carries the connection the query ran on (Rails 6.0+), whose adapter_name is each adapter's own name for itself, such as "PostgreSQL" or "Mysql2". A name the mapping does not recognise is left to the SQL sentinel, same as an adapter this gem has never heard of.



18
19
20
21
22
23
24
25
# File 'lib/appsignal/event_formatter/active_record/sql_formatter.rb', line 18

def opentelemetry_attributes(payload)
  name = Appsignal::OpenTelemetry::SqlDbSystem.name_for_active_record(
    payload[:connection]&.adapter_name
  )
  return unless name

  { "db.system.name" => name }
end

#opentelemetry_kindObject

A query is an outgoing call to a datastore.



9
10
11
# File 'lib/appsignal/event_formatter/active_record/sql_formatter.rb', line 9

def opentelemetry_kind
  :client
end