Commit 740977a6 authored by Stan Hu's avatar Stan Hu

Fix for raven-ruby v3.x

parent e1459079
...@@ -7,38 +7,32 @@ module Gitlab ...@@ -7,38 +7,32 @@ module Gitlab
DEBUG_ERROR_STRING_REGEX = RE2('(.*) debug_error_string:(.*)') DEBUG_ERROR_STRING_REGEX = RE2('(.*) debug_error_string:(.*)')
def process(value) def process(value)
return value unless grpc_exception?(value) process_first_exception_value(value)
process_message(value)
process_exception_values(value)
process_custom_fingerprint(value) process_custom_fingerprint(value)
value value
end end
def grpc_exception?(value) # Sentry can report multiple exceptions in an event. Sanitize
value[:exception] && value[:message].start_with?('GRPC::') # only the first one since that's what is used for grouping.
end def process_first_exception_value(value)
exceptions = value.dig(:exception, :values)
def process_message(value) return unless exceptions.is_a?(Array)
message, debug_str = split_debug_error_string(value[:message])
return unless message entry = exceptions.first
value[:message] = message return unless entry.is_a?(Hash)
extra = value[:extra] || {}
extra[:grpc_debug_error_string] = debug_str if debug_str
end
def process_exception_values(value) raw_message = entry[:value]
exceptions = value.dig(:exception, :values)
return unless exceptions.is_a?(Array) return unless raw_message.start_with?('GRPC::')
exceptions.each do |entry| message, debug_str = split_debug_error_string(raw_message)
message, _ = split_debug_error_string(entry[:value])
entry[:value] = message if message entry[:value] = message if message
end extra = value[:extra] || {}
extra[:grpc_debug_error_string] = debug_str if debug_str
end end
def process_custom_fingerprint(value) def process_custom_fingerprint(value)
......
...@@ -27,7 +27,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -27,7 +27,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
extra: { extra: {
caller: 'test' caller: 'test'
}, },
message: "GRPC::DeadlineExceeded: 4:DeadlineExceeded. debug_error_string:{\"hello\":1}",
fingerprint: [ fingerprint: [
"GRPC::DeadlineExceeded", "GRPC::DeadlineExceeded",
"4:Deadline Exceeded. debug_error_string:{\"created\":\"@1598938192.005782000\",\"description\":\"Error received from peer unix:/home/git/gitalypraefect.socket\",\"file\":\"src/core/lib/surface/call.cc\",\"file_line\":1055,\"grpc_message\":\"Deadline Exceeded\",\"grpc_status\":4}" "4:Deadline Exceeded. debug_error_string:{\"created\":\"@1598938192.005782000\",\"description\":\"Error received from peer unix:/home/git/gitalypraefect.socket\",\"file\":\"src/core/lib/surface/call.cc\",\"file_line\":1055,\"grpc_message\":\"Deadline Exceeded\",\"grpc_status\":4}"
...@@ -37,7 +36,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do ...@@ -37,7 +36,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
let(:expected) do let(:expected) do
{ {
message: "GRPC::DeadlineExceeded: 4:DeadlineExceeded.",
fingerprint: [ fingerprint: [
"GRPC::DeadlineExceeded", "GRPC::DeadlineExceeded",
"4:Deadline Exceeded." "4:Deadline Exceeded."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment