Skip to content

Best practices for adding OTEL to a codebase while avoiding messy/verbose code? #6680

Answered by XSAM
C-Loftus asked this question in Q&A
Discussion options

You must be logged in to vote

In short, I am finding the golang otel semantics to require passing lots of ctx objects around in sections of the code that ordinarily wouldn't need it. I am trying to find ways of reducing this verbosity.

In Go, explicitly passing ctx objects is the convention that every method with context info should have. https://go.dev/blog/context#conclusion

Tracer.start method uses context to retrieve the current span, so it can create a new span with the same trace_id.

I am not familiar with the otel implementation in Python, but I guess it uses thread-local storage to propagate the current span info (implicitly passing ctx objects). So users don't need to specify the context.

There is no such t…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@C-Loftus
Comment options

@dmathieu
Comment options

Answer selected by dmathieu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants