Posted 1/5/2026

We finished the logging upgrade on one of our products at work and its working much better. Each request has one single log line with all the data you would need to debug. We use custom go types to handle things like return codes or metrics reporting too, so you can kinda just chain together whatever errors you want in your own stack trace and each layer can find its specific error type and get the data it needs, or throw a default.

For example, one of the error types we have looks like the following:

type RequestError struct {
	StatusCode int
	Err        error
}

Using this, we can throw this error anywhere in our codebase as deep as we want and get a specific status code. If something else happens on the way, you can just mix the existing errors with an errors.Join and parse out the nested RequestError via errors.As.

While working on this we were also able to squash a few extra bugs that had been plaguing us for a while since this was both a logging rework and general refactor of the codebase. Overall very happy with it, excited to use the same template with our other services.

I also just finished the first season of Pluribus, great show.


Contact me