Class: Datadog::OpenFeature::Hooks::DebugLoggingHook
- Inherits:
-
Object
- Object
- Datadog::OpenFeature::Hooks::DebugLoggingHook
- Includes:
- OpenFeature::SDK::Hooks::Hook
- Defined in:
- lib/datadog/open_feature/hooks/debug_logging_hook.rb
Overview
Logs each SDK-final evaluation outcome for onboarding diagnostics.
Logs raw flag values, default values, targeting keys, context attributes, and error messages, so it is only registered while debug logging is enabled.
Class Method Summary collapse
Instance Method Summary collapse
- #finally(hook_context:, evaluation_details:, **_opts) ⇒ Object
-
#initialize(logger) ⇒ DebugLoggingHook
constructor
A new instance of DebugLoggingHook.
Constructor Details
#initialize(logger) ⇒ DebugLoggingHook
Returns a new instance of DebugLoggingHook.
19 20 21 |
# File 'lib/datadog/open_feature/hooks/debug_logging_hook.rb', line 19 def initialize(logger) @logger = logger end |
Class Method Details
.available? ⇒ Boolean
15 16 17 |
# File 'lib/datadog/open_feature/hooks/debug_logging_hook.rb', line 15 def self.available? !!defined?(::OpenFeature::SDK::Hooks::Hook) end |
Instance Method Details
#finally(hook_context:, evaluation_details:, **_opts) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datadog/open_feature/hooks/debug_logging_hook.rb', line 23 def finally(hook_context:, evaluation_details:, **_opts) @logger.debug do evaluation_context = hook_context.evaluation_context "Feature Flags: evaluated #{hook_context.flag_key.inspect} (" \ "type=#{hook_context.flag_value_type}, " \ "default=#{hook_context.default_value.inspect}, " \ "value=#{evaluation_details.value.inspect}, " \ "variant=#{evaluation_details.variant.inspect}, " \ "reason=#{evaluation_details.reason.inspect}, " \ "allocation=#{extract_allocation_key(evaluation_details).inspect}, " \ "error_code=#{evaluation_details.error_code.inspect}, " \ "error_message=#{evaluation_details..inspect}, " \ "targeting_key=#{evaluation_context&.targeting_key.inspect}, " \ "attributes=#{attributes(evaluation_context).inspect}, " \ "flag_metadata=#{evaluation_details..inspect})" end end |