Skip to content

Is context-zone required for a working context on a Browser environment? #2060

Answered by Flarna
niekert asked this question in Q&A
Discussion options

You must be logged in to vote

There is no special context manager required in general. You can always pass around the context object manually if this fits your usecase.

e.g. if you look at Tracer.startSpan() it has and optional third argument context. If you don't pass anything api.context.active() is used but if you have your favorite context object available you can use it.

Be aware that the NoopContextManager (used if you don't specify anything special either direct or via TracerProvider options) is quite Noop - active() will always return ROOT_CONTEXT.

It's not that hard to implement a simple context manager which has at least some basic functionality for sync calls but "breaks" on async:

class SimpleContextManager 

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@niekert
Comment options

@vmarchaud
Comment options

Answer selected by niekert
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants