-
Notifications
You must be signed in to change notification settings - Fork 579
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
Global object for configuration #123
Comments
This should be the commit I meant https://github.com/dynatrace-oss-contrib/opentelemetry-python/blob/1d5c219232545ceb694db49c938eac294410f721/opentelemetry-api/opentelemetry/backend.py (not sure why that file is outside src; see also #15 & #29) |
I'd like to sketch the approach here, in case people have opinions before I start writing code. My approach at this point I think will expose the following APIs and be used as such:
|
Is that Actually, I'd prefer something that allows step-by-step configuratio, maybe something like I suggested in #45, with # Configure the global instance to use tracer, httptextformatter, ... of my.tracing.only.vendor
my.tracing.only.vendor.setup()
# Configure the the global instance to use meter from other vendor
my.metric.vendor.setup()
# Configure any remaining instances to no-op, invoke factory functions, ...
opentelemetry.loader.finish_configuration() |
BTW does anyone remember why we originally removed the single global object/dict from #29? EDIT: I think I found the discussion: #29 (comment) A comment by @c24t triggered that. |
Btw, not all vendors support metrics, and there may be a scenario where you only want metrics with a Prometheus exporter, and the default no-op tracing, for example. |
I don't like the intermediate |
Regarding instance: we could remove it, and have top-level apis that look like:
It wouldn't be that hard to discover, just need proper documentation on top-level modules. There's a good argument too that if we show singleton references in the top level module, it's a quick reference to see what is and isn't configurable. @carlosalberto would that work? |
Regarding configure: I think no matter what we do, vendors can always provide a simple aggregate function to configure OpenTelemetry however they like. I don't think #45 addresses my concern of making it clear what is or isn't configurable, or should be configured, although I see how it will help ensure configuration is deferred to first access so that people have a chance to configure globals before they're accessed. I think I'll drop the configure() method in my proposal if it's controversial. This can also be accomplished with proper documentation and examples, which I think the README and example-app can provide. |
Slightly related to #144 |
@toumorokoshi The problem with a setter is that everyone will use it to set the SDK and then if you want to override that you need to change the source code to call another setter or monkeypatching it. |
Sorry @Oberon00, I'm not clear on what you mean by "change the source code to call another setter". Do you have an example to clarify? |
Say I'm a PaaS vendor and have my own AwesomeSDK that implements the OTel API. Now I have a customer that deploys an application that uses OpenTelemetry. In the startup code, the application uses if os.getenv('AWESOME_PAAS_ENV'):
awesomeutil.setup() # Calls setTracer
else:
opentelemetry.setTracer(opentelemetry.sdk.trace.Tracer()) # Or sdk.setup() With the current loader, the PaaS vendor can just set the |
Related #144 . |
@ocelotl has a WIP prototype he'll be sending out in a PR over the next week. |
Fixes #123 This basically removes loader.py (uses entry points instead) and all the calls for set_preferred_implementation* in order to cleanly separate user code from configuration. It introduces a configuration manager that can have configuration set by a configuration file or environment variables that override the former configuration method. Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io> Co-authored-by: Chris Kleinknecht <libc@google.com>
Change return type "unknow" to HttpTextFormat for getHttpTextFormat Change return type "unknow" to BinaryFormat for getBinaryFormat Close open-telemetry#124 open-telemetry#123 Signed-off-by: Olivier Albertini <olivier.albertini@montreal.ca>
Right now, we are heading toward singletons that are created per API to set / retrieve singletons.
For example, tracer has it's own tracer.tracer(), with that pattern.
Having the APIs loosely coupled with an explicit composition object requires the SDK / API consumer to be aware of all singletons, and set them themselves. If one is missed, one could end up with no emission of tracers / metrics and would require them to understand the whole OTel API and part of the code to debug.
We should consider a global object that has a method that requires configuration of all required APIs. This would ensure that the consumer has a quick reference that will ensure that the SDK will operate as desired.
The text was updated successfully, but these errors were encountered: