-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Context objects vs using named context #126
Comments
I guess It'll be helpful to have a concrete code example to explain why we want to do this. |
This probably boils down to having a discussion about being more explicit with what is defined in a context within open telemetry. For instance, I would imagine a context could contain both the current default tracer and the current distributed context. We could define interfaces like
I still think there may be a misunderstanding about this. As far as I can tell,
Shouldn't this be the other way around? There should be 1 context that contains the current DistributedContext and the current tracer (I know this isn't exactly how things are currently defined)? |
I agree some global context container with clear methods is the right approach. See: #123 for a proposal around that. My personal opinion is a global object that we can instantiate multiple of as needed. for example:
I think regarding the scope of DistributedContext and SpanContext: it's true they are separate, but I think there is some implicit common scoping by virtue of requests being generally the broadest scope. I think to refine this I want to start a PR around how OTEL will actually be used and integrated with apps. I think I'd like to leave this issue alone until then. |
What's that about naming? Where does it come from? Do you think about open-telemetry/oteps#16? The intent of that PR is (or was at least when I last read it) to allow disabling of individual instrumentations by tracer name. To support this use case, tracers with different names would need to share the same context. E.g., one example there is a tracer named "io.opentelemetry.contrib.mongodb". Of course you'd want a mongodb span to adopt the web request span from the "io.opentelemetry.ext.wsgi.flask" tracer as parent when specifying CURRENT_SPAN. |
I'm fine with supporting only one current context, at least initially. I don't see any relevant use cases that would use multiple current contexts, and I think that support would make specification, configuration and implementation of OpenTelemetry significantly more complex. Just to highlight one point where this would increase implementation complexity: Python contextvars doc says:
|
I believe OTEL66 (Context API) resolves this issue, by defining a specification for context variables. |
* Add Plugin Loader * Load simple-module * gts fix * Use type variable T instead of any * Log instead of throwing and remove redundant Plugins suffix * Add package specific .gitignore * Add @todo * Change DEFAULT_PLUGIN_PACKAGE_NAME_PREFIX to plugin * fix: build pipeline * fix: remove test functions out of the class * fix: use private members in test without exposing it * feat: add PluginConfig during load * fix: make comment more descriptive * fix: move the any to the Plugin type * fix: remove constants container
I was working through #89, which enabled formatters to directly read and write to context objects. One aspect there is that this requires a standard way to set and get context values within a specific namespace.
There are two examples which use that today: DistributedContextManager and Tracer. Both use the Context object under the hood, and allow the passing of a name to access the specific context.
If a user wants to pair the DistributedContext and Tracer, that would require them to create one of each with the same name. This pattern will have to be applied to every unit test that needs to work with one of these contexts.
Instead, I propose the creation of multiple Context objects. Tracers and DistributedContextManager could consume a context object. This simplifies unit testing and also allows one to have a complete context object that could be passed into propagators.
The text was updated successfully, but these errors were encountered: