Sha256: 1c1edfbd3acddc056e7fe1984d168c49db6a5de347028ebc0fad74260ce21dd6

Contents?: true

Size: 877 Bytes

Versions: 11

Compression:

Stored size: 877 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 TransactionsClassMethods
          def self.prepended(base)
            class << base
              prepend ClassMethods
            end
          end

          # Contains ActiveRecord::Transactions::ClassMethods to be patched
          module ClassMethods
            def transaction(**options, &block)
              tracer.in_span("#{self}.transaction") do
                super
              end
            end

            private

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_record-0.6.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.6.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.5.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.4.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.4.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.3.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.2.2 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.2.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.2.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.1.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.1.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb