Sha256: c0ec608a9cbf46ea52437e363d1708e30af5bf621776d9b365ea8c7c16de895f

Contents?: true

Size: 841 Bytes

Versions: 4

Compression:

Stored size: 841 Bytes

Contents

# frozen_string_literal: true

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

module OpenTelemetry
  module Instrumentation
    module Faraday
      module Patches
        # Module to be prepended to force Faraday to use the middleware by
        # default so the user doesn't have to call `use` for every connection.
        module Connection
          # Wraps Faraday::Connection#initialize:
          # https://github.com/lostisland/faraday/blob/ff9dc1d1219a1bbdba95a9a4cf5d135b97247ee2/lib/faraday/connection.rb#L62-L92
          def initialize(*args)
            super.tap do
              use(:open_telemetry) unless builder.handlers.any? do |handler|
                handler.klass == Middlewares::TracerMiddleware
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-faraday-0.24.8 lib/opentelemetry/instrumentation/faraday/patches/connection.rb
opentelemetry-instrumentation-faraday-0.24.7 lib/opentelemetry/instrumentation/faraday/patches/connection.rb
opentelemetry-instrumentation-faraday-0.24.6 lib/opentelemetry/instrumentation/faraday/patches/connection.rb
opentelemetry-instrumentation-faraday-0.24.5 lib/opentelemetry/instrumentation/faraday/patches/connection.rb