Sha256: 8e3c9ef906baec0e3d7f6bb9fe911a09da556ba16db43a5354a271a271874945

Contents?: true

Size: 924 Bytes

Versions: 9

Compression:

Stored size: 924 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('ActiveRecord.transaction', attributes: { 'code.namespace' => name }) do
                super
              end
            end

            private

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-active_record-0.8.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.8.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.7.4 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.7.3 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.7.2 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.7.1 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.7.0 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.6.3 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb
opentelemetry-instrumentation-active_record-0.6.2 lib/opentelemetry/instrumentation/active_record/patches/transactions_class_methods.rb