Module: Gitlab::Lograge::CustomOptions
- Defined in:
- lib/gitlab/lograge/custom_options.rb
Constant Summary collapse
- LIMITED_ARRAY_SENTINEL =
{ key: 'truncated', value: '...' }.freeze
- IGNORE_PARAMS =
Set.new(%w[controller action format]).freeze
- KNOWN_PAYLOAD_PARAMS =
[:remote_ip, :user_id, :username, :ua, :queue_duration_s, :etag_route, :request_urgency, :target_duration_s] + \ CLOUDFLARE_CUSTOM_HEADERS.values + \ JSON_METADATA_HEADERS
Constants included from Gitlab::Logging::JsonMetadataHelper
Gitlab::Logging::JsonMetadataHelper::JSON_METADATA_HEADERS
Constants included from Gitlab::Logging::CloudflareHelper
Gitlab::Logging::CloudflareHelper::CLOUDFLARE_CUSTOM_HEADERS
Class Method Summary collapse
Methods included from Gitlab::Logging::JsonMetadataHelper
Methods included from Gitlab::Logging::CloudflareHelper
#store_cloudflare_headers!, #valid_cloudflare_header?
Class Method Details
.call(event) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/lograge/custom_options.rb', line 16 def self.call(event) params = event .payload[:params] .each_with_object([]) { |(k, v), array| array << { key: k, value: v } unless IGNORE_PARAMS.include?(k) } payload = { time: Time.now.utc.iso8601(3), params: Gitlab::Utils::LogLimitedArray.log_limited_array(params, sentinel: LIMITED_ARRAY_SENTINEL) } payload.merge!(event.payload[:metadata]) if event.payload[:metadata] optional_payload_params = event.payload.slice(*KNOWN_PAYLOAD_PARAMS).compact payload.merge!(optional_payload_params) # Add JSON metadata params (they have json_ prefix) = event.payload.select { |key, _| key.to_s.start_with?('json_') } payload.merge!() ::Gitlab::InstrumentationHelper.add_instrumentation_data(payload) payload[Labkit::Fields::CORRELATION_ID] = event.payload[Labkit::Fields::CORRELATION_ID] || Labkit::Correlation::CorrelationId.current_id # https://github.com/roidrage/lograge#logging-errors--exceptions exception = event.payload[:exception_object] ::Gitlab::ExceptionLogFormatter.format!(exception, payload) if Feature.enabled?(:feature_flag_state_logs) payload[:feature_flag_states] = Feature.logged_states.map { |key, state| "#{key}:#{state ? 1 : 0}" } end payload end |