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

Fix for raven-ruby v3.x

parent e1459079
......@@ -7,38 +7,32 @@ module Gitlab
DEBUG_ERROR_STRING_REGEX = RE2('(.*) debug_error_string:(.*)')
def process(value)
return value unless grpc_exception?(value)
process_message(value)
process_exception_values(value)
process_first_exception_value(value)
process_custom_fingerprint(value)
value
end
def grpc_exception?(value)
value[:exception] && value[:message].start_with?('GRPC::')
end
# Sentry can report multiple exceptions in an event. Sanitize
# only the first one since that's what is used for grouping.
def process_first_exception_value(value)
exceptions = value.dig(:exception, :values)
def process_message(value)
message, debug_str = split_debug_error_string(value[:message])
return unless exceptions.is_a?(Array)
return unless message
entry = exceptions.first
value[:message] = message
extra = value[:extra] || {}
extra[:grpc_debug_error_string] = debug_str if debug_str
end
return unless entry.is_a?(Hash)
def process_exception_values(value)
exceptions = value.dig(:exception, :values)
raw_message = entry[:value]
return unless exceptions.is_a?(Array)
return unless raw_message.start_with?('GRPC::')
message, debug_str = split_debug_error_string(raw_message)
exceptions.each do |entry|
message, _ = split_debug_error_string(entry[:value])
entry[:value] = message if message
end
extra = value[:extra] || {}
extra[:grpc_debug_error_string] = debug_str if debug_str
end
def process_custom_fingerprint(value)
......
......@@ -27,7 +27,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
extra: {
caller: 'test'
},
message: "GRPC::DeadlineExceeded: 4:DeadlineExceeded. debug_error_string:{\"hello\":1}",
fingerprint: [
"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}"
......@@ -37,7 +36,6 @@ RSpec.describe Gitlab::ErrorTracking::Processor::GrpcErrorProcessor do
let(:expected) do
{
message: "GRPC::DeadlineExceeded: 4:DeadlineExceeded.",
fingerprint: [
"GRPC::DeadlineExceeded",
"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