Skip to content
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

Registries created through builders should be returned by OpenTelemetry static methods #747

Closed
kbrockhoff opened this issue Jan 11, 2020 · 4 comments · Fixed by #1857
Closed

Comments

@kbrockhoff
Copy link
Member

TracerSdkRegistry, MeterSdkRegistry and DistributedContextManagerSdk objects created programmatically using the builders and intended to be global registries should be returned by the static methods of the OpenTelemetry class. Currently new registry objects with default configuration get created using the Java ServiceLoader mechanism. This should be the fallback if they are not set explicitly.

@kbrockhoff
Copy link
Member Author

Relates to PR #724

An alternate approach could be similar to log4j 2.x.
http://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/ConfigurationFactory.html

@jkwatson
Copy link
Contributor

So, if something like #724 was in place, then you could use the setter to assign to the global OpenTelemetry instance. I wouldn't expect that the builder would do that itself. For Spring, it would probably make sense for some sort of helper class in the Spring integration would call the setter on the global instance to assign it. Do think think that's a viable approach? I'd be happy to have an alternative proposal to #724 to enable this functionality, as well.

@kbrockhoff
Copy link
Member Author

In Spring, it will be the auto-configuration mechanism which would use the build to create a TracerFactory, etc, then set using the static setter in OpenTelemetry, and then return the built TracerFactory as a bean. At that point, whether TracerFactory is injected by Spring or retrieved using OpenTelemetry.getTracerFactory() the same instance would be seen.

The only thing I am concerned about with this approach is if the static method gets called before the Spring lifecycle makes the bean available. I want to think some more on how that may be handled.

@jkwatson
Copy link
Contributor

jkwatson commented Oct 9, 2020

I'm almost 100% sure this would be addressed by #1737 . 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants