appsignal-ruby icon indicating copy to clipboard operation
appsignal-ruby copied to clipboard

ROM (Ruby Object Mapper) support

Open gotar opened this issue 5 years ago • 4 comments

Hi, any plans to support it? More and more popular every day, and new hanami will use it too.

gotar avatar Nov 26 '19 15:11 gotar

rom-sql use sequel below, maybe it will help? But Sequel setup do not work (manual either)

gotar avatar Nov 26 '19 15:11 gotar

This works for me:

notifications.subscribe(:sql) do |time:, name:, query:|
  Appsignal.instrument_sql("sql.#{name}.rom", nil, query)
end

can I somehow add extra tag to it. I want to report query execution time somehow (so overwrite Duration)

gotar avatar Nov 27 '19 10:11 gotar

Discussed in https://app.intercom.io/a/apps/yzor8gyw/inbox/inbox/conversation/24771981790

tombruijn avatar Dec 02 '19 10:12 tombruijn

working quite well dry-web (roda + rom) example:

Your::Container.boot :appsignal do |container|
  init do
    require "appsignal"
    require 'appsignal/integrations/object'

    use :persistence # rom setup and load
  end

  start do
    Appsignal.config = Appsignal::Config.new(
      container.root,
      container[:settings].appsignal_app_env,
      name: 'logbrowser'
    )

    Appsignal.start
    Appsignal.start_logger

    notifications.subscribe(:sql) do |time:, name:, query:|
      relation = query.match(/\"(\w*?)\"/)

      if relation
        log_path = "sql.#{name}.#{relation[1]}.rom"
      else
        log_path = "sql.#{name}.rom"
      end

      time = time*(10**6)

      Appsignal::Transaction.current.record_event(log_path, nil, query, time, Appsignal::EventFormatter::SQL_BODY_FORMAT)
    end
  end
end

gotar avatar Dec 02 '19 11:12 gotar