lib/labkit/context.rb in gitlab-labkit-0.21.3 vs lib/labkit/context.rb in gitlab-labkit-0.22.0

- old
+ new

@@ -7,11 +7,10 @@ require "active_support/core_ext/string/inflections" module Labkit # A context can be used to provide structured information on what resources # GitLab is working on within a service. - # The currently supported keys are defined in the `KNOWN_KEYS` constant. # # Values can be provided by passing a hash. If one of the values is a Proc # the proc will only be called when the value is actually needed. # # Multiple contexts can be nested, the nested context will inherit the values @@ -26,12 +25,10 @@ class Context LOG_KEY = "meta" CORRELATION_ID_KEY = "correlation_id" RAW_KEYS = [CORRELATION_ID_KEY].freeze HEADER_PREFIX = "X-Gitlab-" - KNOWN_KEYS = %w[user project root_namespace subscription_plan caller_id - remote_ip related_class feature_category client_id].freeze class << self def with_context(attributes = {}) context = push(attributes) @@ -120,11 +117,10 @@ protected def assign_attributes(attributes) attributes = attributes.transform_keys(&method(:log_key)) - attributes = attributes.slice(*known_log_keys) data.merge!(attributes) # Remove keys that had their values set to `nil` in the new attributes data.keep_if { |_, value| value.present? } @@ -136,10 +132,10 @@ data end private - delegate :log_key, :known_log_keys, to: :class + delegate :log_key, to: :class attr_reader :data def call_or_value(value) value.respond_to?(:call) ? value.call : value