diff options
Diffstat (limited to 'lib/gitlab/grape_logging/loggers/response_logger.rb')
-rw-r--r-- | lib/gitlab/grape_logging/loggers/response_logger.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/grape_logging/loggers/response_logger.rb b/lib/gitlab/grape_logging/loggers/response_logger.rb index 0465f01f7f5..767c282d62e 100644 --- a/lib/gitlab/grape_logging/loggers/response_logger.rb +++ b/lib/gitlab/grape_logging/loggers/response_logger.rb @@ -8,7 +8,14 @@ module Gitlab return {} unless Feature.enabled?(:log_response_length) response_bytes = 0 - response.each { |resp| response_bytes += resp.to_s.bytesize } + + case response + when String + response_bytes = response.bytesize + else + response.each { |resp| response_bytes += resp.to_s.bytesize } + end + { response_bytes: response_bytes } |