News for hackers. Stuff that matters.
Re:How to ship production-grade Go by paulddraper on Wednesday May 03, 2017 @04:52PM (#14259948)
(1) I see this all the time.

An error is logged and propogated, then logged and propogated, then logged and propogated, then pretty soon your logs are 50x copies of themselves and the flood of logging sweeps you away.

You either (a) know what you to do about an error and log it or (b) you don't know what to do and propogate it.

An error should be logged eventually, but it shouldn't be logged 20 times.

Re:How to ship production-grade Go by tedsuo on Wednesday May 03, 2017 @05:20PM (#14260219)
I totally agree, there's no need to log that you bubbled an error. My recommendation is to have the function that generates the error also log it internally. That way, you don't need to log any returned errors at all, unless you are calling a 3rd party library that can't log it's own error.
Re:How to ship production-grade Go by twblalock on Wednesday May 03, 2017 @08:34PM (#14261507)
Error handling, which includes logging the error, should almost always be the responsibility of the caller. Only the caller knows why the call was made, and only the caller knows the impact of the error on what the caller is trying to do.
Re:How to ship production-grade Go by paulddraper on Thursday May 04, 2017 @12:22AM (#14262434)
Exactly.

You run a process that exits with a non-zero code. Is that an error that should be logged? Or just informational? (E.g. `diff`.)

You request an HTTP resource that doesn't exist. Loggable error? Or normal result?

Only the caller knows.

Re:How to ship production-grade Go by tedsuo on Thursday May 04, 2017 @02:46PM (#14267558)
I recommend separating collection from instrumentation. Always instrument at the source, so that you can instrument the flow of your entire application. If the caller decides there is something about the code flow that is worth recording, it can trigger collection of the entire trace.
Re:How to ship production-grade Go by Nican on Wednesday May 03, 2017 @07:52PM (#14261296)
I see that way too often. Bonus points if the exceptions are being logged in different ways, in different parts of the library.