Sha256: 75ec7e1eb96480107a9bad90fa9069a2f473d1e904c66d188dc8c6b6f636abb3

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

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

require_relative '../concerns/untraced_hosts'

module OpenTelemetry
  module Instrumentation
    module Excon
      # The Instrumentation class contains logic to detect and install the Excon
      # instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        include OpenTelemetry::Instrumentation::Concerns::UntracedHosts

        install do |_config|
          require_dependencies
          add_middleware
          patch
        end

        present do
          defined?(::Excon)
        end

        option :peer_service, default: nil, validate: :string

        private

        def require_dependencies
          require_relative 'middlewares/tracer_middleware'
          require_relative 'patches/socket'
        end

        def add_middleware
          ::Excon.defaults[:middlewares] = Middlewares::TracerMiddleware.around_default_stack
        end

        def patch
          ::Excon::Socket.prepend(Patches::Socket)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-excon-0.22.5 lib/opentelemetry/instrumentation/excon/instrumentation.rb
opentelemetry-instrumentation-excon-0.22.4 lib/opentelemetry/instrumentation/excon/instrumentation.rb
opentelemetry-instrumentation-excon-0.22.3 lib/opentelemetry/instrumentation/excon/instrumentation.rb
opentelemetry-instrumentation-excon-0.22.1 lib/opentelemetry/instrumentation/excon/instrumentation.rb
opentelemetry-instrumentation-excon-0.22.0 lib/opentelemetry/instrumentation/excon/instrumentation.rb