Sha256: 0c7e5ad1120fe01a00a19c3ce7fa18941e381dbd3b237099d4b0249f67578e1b

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module Bunny
      # The Instrumentation class contains logic to detect and install the
      # bunny instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        install do |_config|
          require_patches
          patch
        end

        present do
          defined?(::Bunny)
        end

        private

        def require_patches
          require_relative 'patch_helpers'
          require_relative 'patches/channel'
          require_relative 'patches/consumer'
          require_relative 'patches/queue'
          require_relative 'patches/reader_loop'
        end

        def patch
          ::Bunny::Channel.prepend(Patches::Channel)
          ::Bunny::Consumer.prepend(Patches::Consumer)
          ::Bunny::Queue.prepend(Patches::Queue)
          ::Bunny::ReaderLoop.prepend(Patches::ReaderLoop)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-bunny-0.18.0 lib/opentelemetry/instrumentation/bunny/instrumentation.rb