-
Notifications
You must be signed in to change notification settings - Fork 449
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
Header only singletons are not working properly for Windows #2534
Comments
I've been running the |
This issue was marked as stale due to lack of activity. |
As of 2025, this issue is still unresolved. Possible options to resolve this discussed below. Option 1, make header-only singletons workThis has been attempted before, but failed. The goal is to find a proper compile option and/or linker annotations to force duplicate copies in each library to be resolved by the linker. This assumes the executable binary format supports this (Linux does). Option 2, give up on header-onlySingletons are implemented in an opentelemetry-api DLL. The major drawback is that every library instrumenting for opentelemetry-cpp now must link with this new library, which causes some impact on builds, possibly preventing adoption of opentelemetry-cpp. This is technically easy to implement, but not desirable. Option 3, give-up on singletonIn this scenario, each library has a local copy of various providers, like trace::Provider. When calling Provider::SetTracerProvider, opentelemetry is to:
This also means to somehow be notified when a library is loaded, to adjust the providers copy. This sounds very risky technically, and very dependent on Windows. |
There is one more option, call it Here is the example from the Agility SDK - https://devblogs.microsoft.com/directx/gettingstarted-dx12agility/#parametersa This would require the main application, to compile a small subset of the Now the limitation comes from not being able to use this in a plugin - e.g. a Maya / Max / Adobe, or any other system, or language relying on |
Option My biggest issue here, is that by being a This would still work for plugins, but another issue raises there - if you say have two plugins, or in Java / Python / etc., two compiled C++ libraries used from |
The opentelemetry-cpp API uses header only singletons, for example for the tracer provider.
When:
TracerProvider::SetTracerProvider()
in the main application codeTracerProvider::GetTracerProvider()
the shared library does not see the tracer provider installed in the main application.
As a result, opentelemetry is disabled in the shared library (the noop tracer provider is seen instead).
Related issues:
The issue about singletons for the Windows platform is known, but still not resolved.
The text was updated successfully, but these errors were encountered: