metrics_simple example does nothing on Windows
Describe your environment Same as in https://github.com/open-telemetry/opentelemetry-cpp/issues/3673 Windows 11, VS2022, cmake-4.1.1, ninja 1.13.1 opentelemetry-cpp dependencies are built as shared libraries
Steps to reproduce
Build opentelemetry 1.23.0 on Windows as a single shared dll (using OPENTELEMETRY_BUILD_DLL cmake option)as described in https://github.com/open-telemetry/opentelemetry-cpp/issues/3673, including patching ext/src/dll/input.src, and replacing "-DWITH_EXAMPLES=OFF -DWITH_EXAMPLES_HTTP=OFF" with "-DWITH_EXAMPLES=ON -DWITH_EXAMPLES_HTTP=ON". The build will have built the metrics_simple example and then will fail due to failure to link other examples (because of the same underlying issues as in https://github.com/open-telemetry/opentelemetry-cpp/issues/3673).
Then put the build opentelemetry-cpp.dll (along with it's dependencies such as protobuf/abseil DLLs) on PATH and run the built <BUILD_ROOT>\opentelemetry-cpp-1.23.0\build\examples\metrics_simple\metrics_ostream_example.exe with or without any parameters such as "counter".
What is the expected behavior? Exported metrics displayed on stdout, just like it happens on Linux.
What is the actual behavior? The exe appears to hang for 10 seconds then it exits. Nothing is displayed on stdout.
Additional context Modifying the example to set up an OtlpHttpMetricExporter using http://localhost:56633/v1/metric as the url and install a custom LogHandler via opentelemetry::sdk::common::internal_log::GlobalLogHandler::SetLogHandler shows there is no attempt to connect to the non-existent OTLP HTTP metric exporter url (unlike when attempting to use a non-existent OTLP Http trace exporter url for traces).
@vkrevs
opentelemetry-cpp on Windows in general is affected by 2 issues specific for this platform:
- producing a single dll for opentelemetry-cpp is weak, as you have found, and is missing many symbols. Other platforms are not affected, because these do not try to package all the code into a single shared library. This feature,
OPENTELEMETRY_BUILD_DLL, needs some work. - singletons are not working properly, see #2534
Please check if the singleton for the meter provider is the root cause here, this will help investigations.