Sha256: 572f73312f80d1b6f477f511d4aac324e4c3ffab66ace37ab265467f34b01c05

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

# require 'active_support'

module Rails
  module Instrumentation
    module ActiveRecordSubscriber
      include Subscriber

      EVENT_NAMESPACE = 'active_record'.freeze

      EVENTS = %w[
        sql
        instantiation
      ].freeze

      # rubocop:disable Style/MutableConstant
      BASE_TAGS = { 'component' => 'ActiveRecord' }
      # rubocop:enable Style/MutableConstant.

      class << self
        def sql(event)
          raw = event.payload[:sql]
          statement = raw.respond_to?(:to_str) ? raw : raw.to_s
          tags = span_tags(
            'db.statement' => statement[0, 1024],
            'name' => event.payload[:name],
            'connection_id' => event.payload[:connection_id],
            'binds' => event.payload[:binds],
            'cached' => event.payload[:cached]
          )

          Utils.trace_notification(event: event, tags: tags)
        end

        def instantiation(event)
          tags = span_tags(
            'record.count' => event.payload[:record_count],
            'record.class' => event.payload[:class_name]
          )

          Utils.trace_notification(event: event, tags: tags)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
signalfx-rails-instrumentation-0.2.1 lib/rails/instrumentation/subscribers/active_record_subscriber.rb
signalfx-rails-instrumentation-0.2.0 lib/rails/instrumentation/subscribers/active_record_subscriber.rb
rails-instrumentation-0.1.5 lib/rails/instrumentation/subscribers/active_record_subscriber.rb
rails-instrumentation-0.1.4 lib/rails/instrumentation/subscribers/active_record_subscriber.rb
rails-instrumentation-0.1.3 lib/rails/instrumentation/subscribers/active_record_subscriber.rb