Sha256: d5a12ec054d81c3b1e4f80c6b0515e0eadbb56aaa7a492e46bf1e30d89473af6

Contents?: true

Size: 839 Bytes

Versions: 2

Compression:

Stored size: 839 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(...)
            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

2 entries across 2 versions & 1 rubygems

Version Path
opentelemetry-instrumentation-faraday-0.26.0 lib/opentelemetry/instrumentation/faraday/patches/connection.rb
opentelemetry-instrumentation-faraday-0.25.0 lib/opentelemetry/instrumentation/faraday/patches/connection.rb