Module: Datadog::Core::Deprecations

Included in:
Datadog::Core
Defined in:
lib/datadog/core/deprecations.rb

Overview

Contains behavior for handling deprecated functions in the codebase.

Instance Method Summary collapse

Instance Method Details

#log_deprecation(disallowed_next_major: true, key: nil) ⇒ Object

Records the occurrence of a deprecated operation in this library.

Currently, these operations are logged to ‘Datadog.logger` at `warn` level.

‘disallowed_next_major` adds a message informing that the deprecated operation won’t be allowed in the next major release.

Parameters:

  • disallowed_next_major (Boolean) (defaults to: true)

    whether this deprecation will be enforced in the next major release.

  • key (Object) (defaults to: nil)

    A unique key for the deprecation. Only the first message with the same key will be logged.

Yield Returns:

  • (String)

    a String with the lazily evaluated deprecation message.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/datadog/core/deprecations.rb', line 17

def log_deprecation(disallowed_next_major: true, key: nil)
  return unless log_deprecation?(key)

  Datadog.logger.warn do
    message = yield
    message += ' This will be enforced in the next major release.' if disallowed_next_major
    message
  end

  # Track the deprecation being logged.
  deprecation_logged!(key)

  nil
end