Sha256: 5b996826def1fa9b748ae431410a7523f90829a689b30baa2aa7c43435f015de
Contents?: true
Size: 1.83 KB
Versions: 27
Compression:
Stored size: 1.83 KB
Contents
module Datadog module Contrib module Faraday COMPATIBLE_UNTIL = Gem::Version.new('1.0.0') SERVICE = 'faraday'.freeze NAME = 'faraday.request'.freeze # Responsible for hooking the instrumentation into faraday module Patcher include Base register_as :faraday, auto_patch: true DEFAULT_ERROR_HANDLER = lambda do |env| Ext::HTTP::ERROR_RANGE.cover?(env[:status]) end option :service_name, default: SERVICE option :distributed_tracing, default: false option :error_handler, default: DEFAULT_ERROR_HANDLER option :tracer, default: Datadog.tracer @patched = false class << self def patch return @patched if patched? || !compatible? require 'ddtrace/ext/app_types' require 'ddtrace/contrib/faraday/middleware' add_pin add_middleware @patched = true rescue => e Tracer.log.error("Unable to apply Faraday integration: #{e}") @patched end def patched? @patched end def register_service(name) get_option(:tracer).set_service_info(name, 'faraday', Ext::AppTypes::WEB) end private def compatible? return unless defined?(::Faraday::VERSION) Gem::Version.new(::Faraday::VERSION) < COMPATIBLE_UNTIL end def add_pin Pin.new( get_option(:service_name), app: 'faraday', app_type: Ext::AppTypes::WEB, tracer: get_option(:tracer) ).onto(::Faraday) end def add_middleware ::Faraday::Middleware.register_middleware(ddtrace: Middleware) end end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems