Log exception backtrace in gRPC server logging interceptor
In gitlab-org/gitlab#301154 (closed), we saw a gitaly-ruby UTF-8 encoding exception, but it difficult to narrow down the cause. Even though the backtrace did land in Sentry, in a development or customer environment this may not be available.
We now log the first 5 lines of an exception backtrace to provide more context.
Sample:
{
"type": "gitaly-ruby",
"grpc.start_time": "2021-02-18T08:37:55Z",
"grpc.time_ms": 4.482,
"grpc.code": "Unknown",
"grpc.method": "WikiFindPage",
"grpc.service": "gitaly.WikiService",
"pid": 27652,
"correlation_id": "",
"time": "2021-02-18T08:37:55.775Z",
"exception": "U+00E9 from UTF-8 to ASCII-8BIT",
"exception_backtrace": [
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:60:in `initialize'",
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:60:in `new'",
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:60:in `block in gitaly_trailers_from_rugged'",
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:59:in `map'",
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:59:in `gitaly_trailers_from_rugged'",
"/Users/stanhu/gitlab/gdk-ee/gitaly/ruby/lib/gitaly_server/utils.rb:17:in `gitaly_commit_from_rugged'"
]
}
Edited by Stan Hu