10 #include "opentelemetry/plugin/detail/dynamic_library_handle.h"
11 #include "opentelemetry/plugin/detail/loader_info.h"
12 #include "opentelemetry/plugin/detail/utility.h"
13 #include "opentelemetry/plugin/factory.h"
14 #include "opentelemetry/plugin/hook.h"
15 #include "opentelemetry/version.h"
31 inline std::unique_ptr<Factory>
LoadFactory(
const char *
plugin, std::string &error_message) noexcept
35 auto handle = ::dlopen(
plugin, RTLD_NOW | RTLD_LOCAL);
36 if (handle ==
nullptr)
42 std::shared_ptr<DynamicLibraryHandle> library_handle{
new (std::nothrow)
44 if (library_handle ==
nullptr)
49 auto make_factory_impl =
50 reinterpret_cast<OpenTelemetryHook *
>(::dlsym(handle,
"OpenTelemetryMakeFactoryImpl"));
51 if (make_factory_impl ==
nullptr)
56 if (*make_factory_impl ==
nullptr)
63 auto factory_impl = (**make_factory_impl)(loader_info, plugin_error_message);
64 if (factory_impl ==
nullptr)
69 return std::unique_ptr<Factory>{
new (std::nothrow)