diff options
Diffstat (limited to 'lib/gitlab/grape_logging/loggers/context_logger.rb')
-rw-r--r-- | lib/gitlab/grape_logging/loggers/context_logger.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/gitlab/grape_logging/loggers/context_logger.rb b/lib/gitlab/grape_logging/loggers/context_logger.rb index 468a296886e..1da96fdfdff 100644 --- a/lib/gitlab/grape_logging/loggers/context_logger.rb +++ b/lib/gitlab/grape_logging/loggers/context_logger.rb @@ -1,11 +1,18 @@ # frozen_string_literal: true -# This module adds additional correlation id the grape logger +# This class adds application context to the grape logger module Gitlab module GrapeLogging module Loggers class ContextLogger < ::GrapeLogging::Loggers::Base - def parameters(_, _) + def parameters(request, _) + # Add remote_ip if this request wasn't already handled. If we + # add it unconditionally we can break client_id due to the way + # the context inherits the user. + unless Gitlab::ApplicationContext.current_context_include?(:remote_ip) + Gitlab::ApplicationContext.push(remote_ip: request.ip) + end + Gitlab::ApplicationContext.current end end |