Skip to content

[C++] ENH: enable building against system opentelemetry on windows #45033

@h-vetinari

Description

@h-vetinari

Describe the enhancement requested

In #44982, I ran into some problems while trying to build arrow against a local opentelemetry on windows. Failure looks as follows

[115/935] Building CXX object src\arrow\CMakeFiles\arrow_util_shared.dir\util\thread_pool.cc.obj
FAILED: src/arrow/CMakeFiles/arrow_util_shared.dir/util/thread_pool.cc.obj 
C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1442~1.344\bin\Hostx64\x64\cl.exe  /nologo /TP -DABSL_CONSUME_DLL -DARROW_EXPORTING -DARROW_HAVE_RUNTIME_AVX2 -DARROW_HAVE_RUNTIME_AVX512 -DARROW_HAVE_RUNTIME_BMI2 -DARROW_HAVE_RUNTIME_SSE4_2 -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DHAVE_ABSEIL -DHAVE_MSGPACK -DOPENTELEMETRY_ABI_VERSION_NO=1 -DPROTOBUF_USE_DLLS -DURI_STATIC_BUILD -DUSE_IMPORT_EXPORT -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -I%SRC_DIR%\cpp\build\src -I%SRC_DIR%\cpp\src -I%SRC_DIR%\cpp\src\generated -external:I%PREFIX%\Library\include -external:W0 /DWIN32 /D_WINDOWS /GR /EHsc /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING  /EHsc /wd5105 /bigobj /utf-8 /W3 /wd4800 /wd4996 /wd4065  /O2 /Ob2 /DNDEBUG -std:c++17 -MD /showIncludes /Fosrc\arrow\CMakeFiles\arrow_util_shared.dir\util\thread_pool.cc.obj /Fdsrc\arrow\CMakeFiles\arrow_util_shared.dir\ /FS -c %SRC_DIR%\cpp\src\arrow\util\thread_pool.cc
%SRC_DIR%\cpp\src\arrow/util/async_generator.h(1636): warning C4003: not enough arguments for function-like macro invocation 'max'

I commented that this might have something to do with NOMINMAX; resp. that it only happens when enabling otel-support on windows.

Going back further (since I had been trying to enable otel-support for a long time), I had at some point needed the following patch

diff --git a/cpp/src/arrow/util/tracing_internal.h b/cpp/src/arrow/util/tracing_internal.h
index 6ed731599..79907cf0c 100644
--- a/cpp/src/arrow/util/tracing_internal.h
+++ b/cpp/src/arrow/util/tracing_internal.h
@@ -122,13 +122,13 @@ struct Scope {
   opentelemetry::trace::Scope scope_impl;
 };

-opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
+ARROW_EXPORT opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
     ::arrow::util::tracing::SpanDetails* span);

-const opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
+ARROW_EXPORT const opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
     const ::arrow::util::tracing::SpanDetails* span);

-opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& RewrapSpan(
+ARROW_EXPORT opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& RewrapSpan(
     ::arrow::util::tracing::SpanDetails* span,
     opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span> ot_span);

@kou said:

The ARROW_EXPORT/max problems are that our OpenTelemetry integration doesn't work on Windows. It doesn't depend on bundled opentelemetry-cpp nor system opentelemetry-cpp.

So this issue is for making arrow compatible with an existing otel on the system (no problem if this requires a very recent version)

Component(s)

C++, Packaging

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions