Module: Datadog::OpenFeature::Exposures::Event
- Defined in:
- lib/datadog/open_feature/exposures/event.rb
Overview
A data model for an exposure event
Constant Summary collapse
- TARGETING_KEY_FIELD =
"targeting_key"- ALLOWED_FIELD_TYPES =
[String, Integer, Float, TrueClass, FalseClass].freeze
Class Method Summary collapse
- .build(result, flag_key:, context:) ⇒ Object
- .cache_key(result, flag_key:, context:) ⇒ Object
-
.cache_value(result, flag_key:, context:) ⇒ Object
NOTE: The serial id is part of the value because it can appear or change on a configuration refresh while the allocation and the variant stay the same.
Class Method Details
.build(result, flag_key:, context:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/datadog/open_feature/exposures/event.rb', line 24 def build(result, flag_key:, context:) event = { timestamp: , allocation: { key: result.allocation_key, }, flag: { key: flag_key, }, variant: { key: result.variant, }, subject: { id: context.targeting_key, attributes: extract_attributes(context), }, } serial_id = result.serial_id event[:serial_id] = serial_id unless serial_id.nil? event.freeze end |
.cache_key(result, flag_key:, context:) ⇒ Object
14 15 16 |
# File 'lib/datadog/open_feature/exposures/event.rb', line 14 def cache_key(result, flag_key:, context:) "#{flag_key}:#{context.targeting_key}" end |
.cache_value(result, flag_key:, context:) ⇒ Object
NOTE: The serial id is part of the value because it can appear or change on a configuration refresh while the allocation and the variant stay the same.
20 21 22 |
# File 'lib/datadog/open_feature/exposures/event.rb', line 20 def cache_value(result, flag_key:, context:) "#{result.allocation_key}:#{result.variant}:#{result.serial_id}" end |