lib/labkit/context.rb in gitlab-labkit-0.25.0 vs lib/labkit/context.rb in gitlab-labkit-0.26.0

- old
+ new

@@ -121,11 +121,11 @@ attributes = attributes.transform_keys(&method(:log_key)) data.merge!(attributes) # Remove keys that had their values set to `nil` in the new attributes - data.keep_if { |_, value| value.present? } + data.keep_if { |_, value| valid_data?(value) } # Assign a correlation if it was missing in the first context or when # explicitly removed data[CORRELATION_ID_KEY] ||= new_id @@ -144,14 +144,18 @@ def expand_data data.transform_values do |value| value = call_or_value(value) - value.presence + value if valid_data?(value) end.compact end def new_id SecureRandom.hex + end + + def valid_data?(value) + value == false || value.present? end end end