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(flag_key:, allocation_key:, variant:, serial_id:, context:, features:) ⇒ Object
Features stay out of the cache value: a features change alone is not a new exposure.
- .cache_key(flag_key:, targeting_key:) ⇒ Object
-
.cache_value(allocation_key:, variant:, serial_id:) ⇒ 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(flag_key:, allocation_key:, variant:, serial_id:, context:, features:) ⇒ Object
Features stay out of the cache value: a features change alone is not a new exposure.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/datadog/open_feature/exposures/event.rb', line 25 def build(flag_key:, allocation_key:, variant:, serial_id:, context:, features:) # @type var event: t event = { timestamp: , allocation: { key: allocation_key, }, flag: { key: flag_key, }, variant: { key: variant, }, subject: { id: context.targeting_key, attributes: extract_attributes(context), }, } event[:serial_id] = serial_id unless serial_id.nil? event[:features] = features unless features.empty? event.freeze end |
.cache_key(flag_key:, targeting_key:) ⇒ Object
14 15 16 |
# File 'lib/datadog/open_feature/exposures/event.rb', line 14 def cache_key(flag_key:, targeting_key:) "#{flag_key}:#{targeting_key}" end |
.cache_value(allocation_key:, variant:, serial_id:) ⇒ 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(allocation_key:, variant:, serial_id:) "#{allocation_key}:#{variant}:#{serial_id}" end |