Sha256: 685a0f27c173ae1efd6e102ac01733003e2353365aba936d83f6fd6a976ebfc6

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module Faraday
      # The Instrumentation class contains logic to detect and install the Faraday
      # instrumentation
      class Instrumentation < OpenTelemetry::Instrumentation::Base
        install do |_config|
          require_dependencies
          register_tracer_middleware
          use_middleware_by_default
        end

        present do
          defined?(::Faraday)
        end

        private

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

        def register_tracer_middleware
          ::Faraday::Middleware.register_middleware(
            open_telemetry: Middlewares::TracerMiddleware
          )
        end

        def use_middleware_by_default
          ::Faraday::RackBuilder.prepend(Patches::RackBuilder)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-faraday-0.10.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb
opentelemetry-instrumentation-faraday-0.9.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb
opentelemetry-instrumentation-faraday-0.8.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb
opentelemetry-instrumentation-faraday-0.7.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb
opentelemetry-instrumentation-faraday-0.6.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb
opentelemetry-instrumentation-faraday-0.5.0 lib/opentelemetry/instrumentation/faraday/instrumentation.rb