Sha256: b35de0a39c84eb6383444bc8863d8641b3827bd50128febd6b223299f4528b4c

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

module ILove
  module Tracing
    module Sql
      def self.setup(_cfg)
        raise 'Cannot trace sql without ActiveSupport' unless defined?(::ActiveSupport)

        ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, start, finish, _id, payload|
          span = OpenTracing.start_span 'sql.active_record',
                                        start_time: start,
                                        child_of: OpenTracing.active_span,
                                        tags: {
                                          'sql.statement' => payload[:sql],
                                          'sql.statement_name' => payload[:statement_name],
                                          'sql.name' => payload[:name]
                                        }

          span.finish end_time: finish
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ilove-tracing-0.2.0 lib/ilove/tracing/sql.rb