bketelsen / censusai

OpenCensus + Go --> Azure AppInsights
https://cda.ms/H8
2 stars 1 forks source link

Avoid using log.Fatal? #2

Open foxbot opened 5 years ago

foxbot commented 5 years ago

Dave Cheney wrote an article about how using log.Fatal is an anti-pattern, since immediately exiting the application does not allow the application to properly clean up after itself; notably when running multiple goroutines. Instead, a call to log.Panic should be used, since this will retain the previous logging behavior, but will additionally yield a stacktrace and properly close the runtime.

This application itself spawns multiple routines via net/http, and I imagine the sqlite and the opencensus libraries might have some additional cleanup code that goes unhandled as well.

Not sure if this would ever be a real-world issue, but seems like a good pattern to enforce nonetheless.

I can PR this change, should you feel it would have a positive impact.

bketelsen commented 5 years ago

that would be wonderful, thanks!