Sha256: d209230eb9e3fe2761622c111392e68ff3f4887d286a76cb2c4d4b9f78328343

Contents?: true

Size: 829 Bytes

Versions: 4

Compression:

Stored size: 829 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module ActiveRecord
      module Patches
        # Module to prepend to ActiveRecord::Base for instrumentation
        module Querying
          def self.prepended(base)
            class << base
              prepend ClassMethods
            end
          end

          # Contains ActiveRecord::Querying to be patched
          module ClassMethods
            def find_by_sql(...)
              tracer.in_span("#{self}.find_by_sql") do
                super
              end
            end

            private

            def tracer
              ActiveRecord::Instrumentation.instance.tracer
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_record-0.7.4 lib/opentelemetry/instrumentation/active_record/patches/querying.rb
opentelemetry-instrumentation-active_record-0.7.3 lib/opentelemetry/instrumentation/active_record/patches/querying.rb
opentelemetry-instrumentation-active_record-0.7.2 lib/opentelemetry/instrumentation/active_record/patches/querying.rb
opentelemetry-instrumentation-active_record-0.7.1 lib/opentelemetry/instrumentation/active_record/patches/querying.rb