Sha256: f675dc3256cac95491b7245d4b687cc46d8bd2cf8afbfaaa72ed1a27d7ff319f

Contents?: true

Size: 1019 Bytes

Versions: 20

Compression:

Stored size: 1019 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
        # We patch these methods because they either raise, or call
        # the super implementation in persistence.rb
        # https://github.com/rails/rails/blob/v5.2.4.5/activerecord/lib/active_record/validations.rb#L42-L53
        # Contains the ActiveRecord::Validations methods to be patched
        module Validations
          def save(**options)
            tracer.in_span("#{self.class}#save") do
              super
            end
          end

          def save!(**options)
            tracer.in_span("#{self.class}#save!") do
              super
            end
          end

          private

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_record-0.8.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.8.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.7.4 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.7.3 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.7.2 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.7.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.7.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.6.3 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.6.2 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.6.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.6.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.5.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.4.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.4.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.3.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.2.2 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.2.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.2.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.1.1 lib/opentelemetry/instrumentation/active_record/patches/validations.rb
opentelemetry-instrumentation-active_record-0.1.0 lib/opentelemetry/instrumentation/active_record/patches/validations.rb