diff options
Diffstat (limited to 'lib/gitlab/grape_logging/loggers/response_logger.rb')
-rw-r--r-- | lib/gitlab/grape_logging/loggers/response_logger.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/grape_logging/loggers/response_logger.rb b/lib/gitlab/grape_logging/loggers/response_logger.rb new file mode 100644 index 00000000000..0465f01f7f5 --- /dev/null +++ b/lib/gitlab/grape_logging/loggers/response_logger.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Gitlab + module GrapeLogging + module Loggers + class ResponseLogger < ::GrapeLogging::Loggers::Base + def parameters(_, response) + return {} unless Feature.enabled?(:log_response_length) + + response_bytes = 0 + response.each { |resp| response_bytes += resp.to_s.bytesize } + { + response_bytes: response_bytes + } + end + end + end + end +end |