Module: Datadog::DeprecatedPin
- Includes:
- Patcher
- Included in:
- Contrib::Dalli::Patcher::DeprecatedPin, Contrib::Faraday::Patcher::DeprecatedPin, Contrib::GRPC::Patcher::DeprecatedPin, Contrib::Grape::Patcher::DeprecatedPin
- Defined in:
- lib/ddtrace/pin.rb
Overview
Modification to Pin which logs deprecation warnings if accessed. Will be used by integrations which are phasing out the direct use of #datadog_pin.
Constant Summary collapse
- DEPRECATION_WARNING =
%( Use of Datadog::Pin is DEPRECATED. Upgrade to the configuration API using the migration guide here: https://github.com/DataDog/dd-trace-rb/releases/tag/v0.11.0).freeze
Instance Method Summary collapse
- #log_deprecation_warning(method_name) ⇒ Object
-
#onto(obj) ⇒ Object
Raise a deprecation warning when #datadog_pin or #datadog_pin= is accessed.
Methods included from Patcher
Methods included from Patcher::CommonMethods
#do_once, #done?, #without_warnings
Instance Method Details
#log_deprecation_warning(method_name) ⇒ Object
131 132 133 134 135 136 |
# File 'lib/ddtrace/pin.rb', line 131 def log_deprecation_warning(method_name) # Only log each deprecation warning once (safeguard against log spam) do_once(method_name) do Datadog.logger.warn("#{method_name}:#{DEPRECATION_WARNING}") end end |
#onto(obj) ⇒ Object
Raise a deprecation warning when #datadog_pin or #datadog_pin= is accessed.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ddtrace/pin.rb', line 106 def onto(obj) obj.instance_exec(self) do |pin| @datadog_deprecated_pin = pin unless respond_to? :datadog_pin= def datadog_pin=(pin) @datadog_deprecated_pin.log_deprecation_warning('#datadog_pin=') @datadog_pin = pin end end unless respond_to? :datadog_pin def datadog_pin @datadog_deprecated_pin.log_deprecation_warning('#datadog_pin') @datadog_pin end end # Set instance variable to avoid deprecation warnings @datadog_pin = @datadog_deprecated_pin end self end |