Class: Datadog::OpenFeature::ExposureHook::Evaluation
- Inherits:
-
Object
- Object
- Datadog::OpenFeature::ExposureHook::Evaluation
- Defined in:
- lib/datadog/open_feature/exposure_hook.rb
Overview
A completed evaluation and its Datadog exposure decision.
Instance Attribute Summary collapse
-
#evaluation_context ⇒ Object
readonly
Returns the value of attribute evaluation_context.
-
#evaluation_details ⇒ Object
readonly
Returns the value of attribute evaluation_details.
-
#flag_key ⇒ Object
readonly
Returns the value of attribute flag_key.
Instance Method Summary collapse
- #allocation_key ⇒ Object
-
#cache_hit? ⇒ Boolean
True when this subject was already exposed to the same allocation, variant and serial id.
-
#exposure? ⇒ Boolean
True for a successful evaluation of an allocation that logs exposures, repeats included.
-
#features ⇒ Hash{String => String, Float, Boolean}
The selected split's features, such as "holdout.key"; values are String, Float or true/false.
-
#initialize(hook_context, evaluation_details) ⇒ Evaluation
constructor
A new instance of Evaluation.
-
#should_send? ⇒ Boolean
True for a new or changed exposure: the exposures the provider selects for reporting to Datadog while DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED is on.
- #split_serial_id ⇒ Object
- #targeting_key ⇒ Object
- #variant ⇒ Object
Constructor Details
#initialize(hook_context, evaluation_details) ⇒ Evaluation
Returns a new instance of Evaluation.
38 39 40 41 42 43 44 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 38 def initialize(hook_context, evaluation_details) @flag_key = hook_context.flag_key @evaluation_context = hook_context.evaluation_context @evaluation_details = evaluation_details = evaluation_details. @metadata = .is_a?(Hash) ? : SplitFeatures::EMPTY end |
Instance Attribute Details
#evaluation_context ⇒ Object (readonly)
Returns the value of attribute evaluation_context.
36 37 38 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 36 def evaluation_context @evaluation_context end |
#evaluation_details ⇒ Object (readonly)
Returns the value of attribute evaluation_details.
36 37 38 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 36 def evaluation_details @evaluation_details end |
#flag_key ⇒ Object (readonly)
Returns the value of attribute flag_key.
46 47 48 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 46 def flag_key @flag_key end |
Instance Method Details
#allocation_key ⇒ Object
52 53 54 55 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 52 def allocation_key allocation_key = @metadata[Ext::METADATA_ALLOCATION_KEY] allocation_key if allocation_key.is_a?(String) end |
#cache_hit? ⇒ Boolean
True when this subject was already exposed to the same allocation, variant and serial id.
76 77 78 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 76 def cache_hit? exposure? && @metadata[Ext::METADATA_EXPOSURE_CACHE_HIT] == true end |
#exposure? ⇒ Boolean
True for a successful evaluation of an allocation that logs exposures, repeats included.
67 68 69 70 71 72 73 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 67 def exposure? @evaluation_details.error_code.nil? && @evaluation_details.reason != Ext::ERROR && !variant.nil? && !allocation_key.nil? && @metadata[Ext::METADATA_DO_LOG] == true end |
#features ⇒ Hash{String => String, Float, Boolean}
The selected split's features, such as "holdout.key"; values are String, Float or true/false.
89 90 91 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 89 def features @features ||= SplitFeatures.read(@metadata, Ext::METADATA_FEATURE_PREFIX) end |
#should_send? ⇒ Boolean
True for a new or changed exposure: the exposures the provider selects for reporting to Datadog while DD_FEATURE_FLAGS_EXPOSURES_DATADOG_LOGGING_ENABLED is on. This does not confirm delivery.
82 83 84 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 82 def should_send? exposure? && @metadata[Ext::METADATA_EXPOSURE_CACHE_HIT] == false end |
#split_serial_id ⇒ Object
57 58 59 60 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 57 def split_serial_id serial_id = @metadata[Ext::METADATA_SPLIT_SERIAL_ID] serial_id if serial_id.is_a?(Integer) end |
#targeting_key ⇒ Object
62 63 64 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 62 def targeting_key @evaluation_context&.targeting_key end |
#variant ⇒ Object
48 49 50 |
# File 'lib/datadog/open_feature/exposure_hook.rb', line 48 def variant @evaluation_details.variant end |