I’m getting 404 There isn’t a GitHub Pages site here.
Doesn’t work for me either, but I found the correct link: https://sergey.kamardin.org/articles/instrumentation-in-go (http://gbws.io redirects to sergey.kamardin.org).
Can you update the story link @pushcx?
Good stuff in the article, thanks for finding it.
This is a lot more invasive than what I think is the more common method of using decorators. In that case, the business logic doesn’t need to be modified whatsoever.
Could you elaborate? I have experience with Go but it’s very unclear to me how to “use decorators” here, and would love to learn that, esp. if the business logic wouldn’t need to be modified whatsoever!
Sure! Here are two examples: https://play.golang.org/p/TtzBWbhLCq5
This extends to decorators for your e.g. business logic component, as long as you can model it as an interface.
As a counterargument, as long as the original code is only logging, this unfortunately doesn’t actually appear to reduce the line count in the function at all, while adding new layers and extra complexity overall, whereas the original code was at least dumb and explicit. As to the rest of the claimed benefits, in a code review I’d say hard YAGNI: let’s not introduce this complexity until we really know we need it now and can point to an actual concrete use (which will most probably happen never). And even then a “rule of three” cost-benefit analysis, i.e. wouldn’t a dumb an explicit alternative be actually still good enough.