Module: Gitlab::Logging::JsonMetadataHelper

Included in:
Gitlab::Lograge::CustomOptions, RequestPayloadLogger
Defined in:
lib/gitlab/logging/json_metadata_helper.rb

Constant Summary collapse

JSON_METADATA_HEADERS =
i[
  json_body_bytesize
  json_total_elements
  json_max_array_count
  json_max_hash_count
  json_max_depth
].freeze

Instance Method Summary collapse

Instance Method Details

#store_json_metadata_headers!(payload, request) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/logging/json_metadata_helper.rb', line 14

def (payload, request)
  # Add JSON metadata from middleware if available
   = request.env[::Gitlab::Middleware::JsonValidation::]
  return unless .present?

  # Add a json_ prefix to distinguish from other metadata
  .each do |key, value|
    payload[:"json_#{key}"] = value
  end
end