bfe icon indicating copy to clipboard operation
bfe copied to clipboard

Consider supporting log tracing in request scope

Open wrayzheng opened this issue 5 years ago • 0 comments

Is your feature request related to a problem? Please describe. Since BFE is an application designed for high concurrency, in most cases, large numbers of requests are processed at the same time. When I want to inspect the debug log throughout the lifecycle of a request, I found that there is no way to tell apart from the logs of thousands of other requests.

Describe the solution you'd like Associate the log with a request id to identify which request it is related, or provide a mechanism to make it easy to enable the log tracing of any request.

Describe alternatives you've considered As far as I know, there are generally two ways to do it. One way is to store the request id in a request scoped context, and pass the context object through the call stack; wherever we print a log, we append the request id retrieved from the context.(see: https://blog.golang.org/context) Another way is to store the request id in the goroutine local storage, which requires third-party implementation and is not recommended officially.(see: https://github.com/jtolio/gls)

I prefer the former way because it conforms to golang code style, though it requires numerous modifications of the source code.

wrayzheng avatar Aug 11 '20 05:08 wrayzheng