I read this post by Jaana
https://docs.google.com/document/d/1GFHAksL5HQy1YacCFXMUdOTC4e21uoX-TbMzRXAtx_I/preview

I wanted to start a conversation about the Context value bag and TraceIDs. 
I am concerned with the idea of using the Context to pass TraceIDs into the 
API of packages that don't directly belong to a specific application.

I think this is a mistake on several fronts:
1) It kills readability because the TraceID is not part of the API. 
Information is being hidden.
2) It will lead to bugs that can't be found at compile time. Only at 
runtime can you identify is the TraceID was not provided.
3) It will force some API's to accept a Context with no clear understanding 
of why. What I mean, when I see Context I want to think cancellation.

I think it is a big mistake to hide anything in the Context for API's that 
exist outside the actual application. The use of the Context value bag is a 
policy decision that should not be found outside of the actual application 
itself. Middleware packages up to the handler could use the Context value 
bag, but then the handler needs to extract the TraceID and pass that into 
the business/service level API's. I would also say database connections 
show follow the same pattern.

I just wanted to start a larger conversation and get other thoughts and 
opinions.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to