Skip to content

GH-49382: [Python] Enable OpenTelemetry on PyArrow wheels#49383

Open
raulcd wants to merge 9 commits intoapache:mainfrom
raulcd:GH-49382
Open

GH-49382: [Python] Enable OpenTelemetry on PyArrow wheels#49383
raulcd wants to merge 9 commits intoapache:mainfrom
raulcd:GH-49382

Conversation

@raulcd
Copy link
Member

@raulcd raulcd commented Feb 24, 2026

Rationale for this change

Currently we are not building wheels with OpenTelemetry.

What changes are included in this PR?

  • Adding a new feature on our vcpkg.json to install required opentelemetry-cpp
  • Enabling the opentelemetry feature when downloading dependencies via vcpkg for our wheels.
  • Setting ARROW_WITH_OPENTELEMETRY=ON on the wheel build scripts
  • Minor fix on checking exposed symbols (opentelemetry symbols are exposed)
  • Minor improvement to python/examples/flight/middleware.py to be able to easily enable opentelemetry middleware tracing for testing.
  • Fix on server_tracing_middleware.cc to retrieve tracer from arrow::internal::tracing::GetTracer(); instead of otel::trace::Provider::GetTracerProvider()->GetTracer("arrow");
  • Expose missing symbols to enable Windows builds
  • Fix Windows compatibility adding windows compat header.
  • Add is_opentelemetry_enabled utility function in pyarrow to validate whether OpenTelemetry was enabled or not when building Arrow C++. Expose this information on pa.show_info().

Are these changes tested?

Yes, wheels are being successfully built and tested locally with a built wheel that traces are being generated when properly configured.
Added test to validate traces appear on stdout and I've also validated Acero traces are being correctly generated by running the test suite and seeing the opentelemetry traces on Jaeger UI.

Are there any user-facing changes?

Yes, PyArrow wheel users will be able to enable OpenTelemetry traces.

@github-actions
Copy link

⚠️ GitHub issue #49382 has been automatically assigned in GitHub to PR creator.

@raulcd
Copy link
Member Author

raulcd commented Feb 24, 2026

@github-actions crossbow submit wheel-manylinux-2-28-cp313-cp313-amd64

@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Feb 24, 2026
@github-actions
Copy link

Revision: 7426f25

Submitted crossbow builds: ursacomputing/crossbow @ actions-1e10ae4c04

Task Status
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions

…ple and fix using the proper arrow tracer singleton
options.parent = otel::trace::GetSpan(new_otel_context)->GetContext();

auto tracer = otel::trace::Provider::GetTracerProvider()->GetTracer("arrow");
auto tracer = arrow::internal::tracing::GetTracer();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lidavidm I am not entirely sure why this is necessary but using the example middleware.py enabling otel as updated below with a running server:

$ export OTEL_SERVICE_NAME=arrow-raul
$ ARROW_TRACING_BACKEND=otlp_http python examples/flight/middleware.py server --listen grpc://localhost:5050 --otel

and client:

python examples/flight/middleware.py  client grpc://localhost:5050

I wasn't able to get traces unless I update this to use arrow::internal::tracing::GetTracer. Example of local traces with the built wheel and this changes:

Image

Initially I thought it might be due to the addition of CMAKE_INTERPROCEDURAL_OPTIMIZATION to the wheels but I've validated is unrelated.

Without this change I haven't been able to get opentelemetry traces using the flight.TracingServerMiddlewareFactory

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it's been a while since I've worked with OTel...possibly the OTel trace provider isn't being configured (vs the hardcoded Arrow one)? The Arrow util is about equivalent, but does some static initialization first

Copy link
Member Author

@raulcd raulcd Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that was my feeling too, either not being initialized or something to do with libarrow.so and libarrow_flight.so both linking opentelementry statically and getting their own copy of the static opentelemetry provider that's why I thought CMAKE_INTERPROCEDUREAL_OPTIMIZATION might be related (but proved it wasn't).
The Arrow util one should cross the shared object boundary and use the already initialized one (or initialize it) which I think is correct.
I just wanted to validate the change looks ok to you or whether do you think it would be better to keep investigating and try to configure when calling MakeTracingServerMiddlewareFactory instead of using the one initialized via libarrow.so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Feb 25, 2026
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Feb 25, 2026
@raulcd
Copy link
Member Author

raulcd commented Feb 25, 2026

@github-actions crossbow submit wheel-macos-monterey-cp313-cp313-amd64

@github-actions
Copy link

Revision: 9ccb832

Submitted crossbow builds: ursacomputing/crossbow @ actions-c6d347423f

Task Status
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Feb 25, 2026

@github-actions crossbow submit wheel-windows-cp313-cp313-amd64 wheel-musllinux-1-2-cp313-cp313-amd64

@github-actions
Copy link

Revision: 8d2daf8

Submitted crossbow builds: ursacomputing/crossbow @ actions-4d34d6d1e1

Task Status
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Feb 25, 2026
@raulcd
Copy link
Member Author

raulcd commented Feb 25, 2026

@github-actions crossbow submit wheel-windows-cp313-cp313-amd64

@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Feb 25, 2026
@github-actions
Copy link

Revision: be1de48

Submitted crossbow builds: ursacomputing/crossbow @ actions-3168ee0ef2

Task Status
wheel-windows-cp313-cp313-amd64 GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Feb 25, 2026

@github-actions crossbow submit wheel-windows-cp313-cp313-amd64

@github-actions
Copy link

Revision: 2bbd485

Submitted crossbow builds: ursacomputing/crossbow @ actions-2be70cfc4f

Task Status
wheel-windows-cp313-cp313-amd64 GitHub Actions

};

opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
ARROW_EXPORT opentelemetry::nostd::shared_ptr<opentelemetry::trace::Span>& UnwrapSpan(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These symbols seem to be required to be exported for Windows:

2026-02-25T17:46:03.6802906Z   
2026-02-25T17:46:03.6803059Z   Finished searching libraries
2026-02-25T17:46:03.6813183Z unity_3_cxx.obj : error LNK2001: unresolved external symbol "class opentelemetry::v1::nostd::shared_ptr<class opentelemetry::v1::trace::Span> & __cdecl arrow::internal::tracing::RewrapSpan(class arrow::util::tracing::SpanDetails *,class opentelemetry::v1::nostd::shared_ptr<class opentelemetry::v1::trace::Span>)" (?RewrapSpan@tracing@internal@arrow@@YAAEAV?$shared_ptr@VSpan@trace@v1@opentelemetry@@@nostd@v1@opentelemetry@@PEAVSpanDetails@1util@3@V4567@@Z) [C:\arrow-build\src\arrow\acero\arrow_acero_shared.vcxproj]
2026-02-25T17:46:03.6817761Z unity_2_cxx.obj : error LNK2001: unresolved external symbol "class opentelemetry::v1::nostd::shared_ptr<class opentelemetry::v1::trace::Span> & __cdecl arrow::internal::tracing::UnwrapSpan(class arrow::util::tracing::SpanDetails *)" (?UnwrapSpan@tracing@internal@arrow@@YAAEAV?$shared_ptr@VSpan@trace@v1@opentelemetry@@@nostd@v1@opentelemetry@@PEAVSpanDetails@1util@3@@Z) [C:\arrow-build\src\arrow\acero\arrow_acero_shared.vcxproj]
2026-02-25T17:46:03.6820710Z C:\arrow-build\release\Release\arrow_acero.dll : fatal error LNK1120: 2 unresolved externals [C:\arrow-build\src\arrow\acero\arrow_acero_shared.vcxproj]

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Feb 25, 2026
@raulcd
Copy link
Member Author

raulcd commented Feb 25, 2026

@github-actions crossbow submit -g wheel

@github-actions
Copy link

Revision: 2bbd485

Submitted crossbow builds: ursacomputing/crossbow @ actions-b2c694ec7c

Task Status
python-sdist GitHub Actions
wheel-macos-monterey-cp310-cp310-amd64 GitHub Actions
wheel-macos-monterey-cp310-cp310-arm64 GitHub Actions
wheel-macos-monterey-cp311-cp311-amd64 GitHub Actions
wheel-macos-monterey-cp311-cp311-arm64 GitHub Actions
wheel-macos-monterey-cp312-cp312-amd64 GitHub Actions
wheel-macos-monterey-cp312-cp312-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-arm64 GitHub Actions
wheel-macos-monterey-cp314-cp314-amd64 GitHub Actions
wheel-macos-monterey-cp314-cp314-arm64 GitHub Actions
wheel-macos-monterey-cp314-cp314t-amd64 GitHub Actions
wheel-macos-monterey-cp314-cp314t-arm64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-amd64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-arm64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-amd64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-arm64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-amd64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-arm64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314-amd64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314-arm64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314t-amd64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314t-arm64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-amd64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-arm64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-amd64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-arm64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-amd64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-arm64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314-amd64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314-arm64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314t-amd64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314t-arm64 GitHub Actions
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions
wheel-windows-cp314-cp314-amd64 GitHub Actions
wheel-windows-cp314-cp314t-amd64 GitHub Actions

Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting changes Awaiting changes labels Feb 26, 2026
for module in modules:
status = "Enabled" if _module_is_available(module) else "-"
print(f" {module: <20}: {status: <8}")
print(f" {"opentelemetry": <20}: {"Enabled" if is_opentelemetry_enabled() else "-": <8}")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of output:

>>> pyarrow.show_info()
pyarrow version info
--------------------
Package kind              : python-wheel-manylinux228
Arrow C++ library version : 24.0.0-SNAPSHOT
Arrow C++ compiler        : GNU 14.2.1
Arrow C++ compiler flags  :  -Wno-noexcept-type -Wno-self-move -Wno-subobject-linkage  -fdiagnostics-color=always  -Wall -fno-semantic-interposition -msse4.2 
Arrow C++ git revision    :         
Arrow C++ git description :         
Arrow C++ build type      : release 
PyArrow build type        : release 

Platform:
  OS / Arch           : Linux x86_64
  SIMD Level          : avx2    
  Detected SIMD Level : avx2    

Memory:
  Default backend     : mimalloc
  Bytes allocated     : 0 bytes 
  Max memory          : 0 bytes 
  Supported Backends  : mimalloc, jemalloc, system

Optional modules:
  csv                 : Enabled 
  cuda                : -       
  dataset             : Enabled 
  feather             : Enabled 
  flight              : Enabled 
  fs                  : Enabled 
  gandiva             : -       
  json                : Enabled 
  orc                 : Enabled 
  parquet             : Enabled 
  opentelemetry       : Enabled 

Filesystems:
  AzureFileSystem     : Enabled 
  GcsFileSystem       : Enabled 
  HadoopFileSystem    : Enabled 
  S3FileSystem        : Enabled 

Compression Codecs:
  brotli              : Enabled 
  bz2                 : Enabled 
  gzip                : Enabled 
  lz4_frame           : Enabled 
  lz4                 : Enabled 
  snappy              : Enabled 
  zstd                : Enabled 

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Feb 27, 2026
…dout when using flight.TracingServerMiddlewareFactory
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Feb 27, 2026
@raulcd
Copy link
Member Author

raulcd commented Feb 27, 2026

@github-actions crossbow submit -g wheel -g python

@github-actions

This comment was marked as outdated.

@raulcd
Copy link
Member Author

raulcd commented Feb 27, 2026

@github-actions crossbow submit -g wheel -g python

@github-actions
Copy link

Revision: 0357767

Submitted crossbow builds: ursacomputing/crossbow @ actions-2156854d96

Task Status
example-python-minimal-build-fedora-conda GitHub Actions
example-python-minimal-build-ubuntu-venv GitHub Actions
python-sdist GitHub Actions
test-conda-python-3.10 GitHub Actions
test-conda-python-3.10-hdfs-2.9.2 GitHub Actions
test-conda-python-3.10-hdfs-3.2.1 GitHub Actions
test-conda-python-3.10-pandas-1.3.4-numpy-1.21.2 GitHub Actions
test-conda-python-3.11 GitHub Actions
test-conda-python-3.11-dask-latest GitHub Actions
test-conda-python-3.11-dask-upstream_devel GitHub Actions
test-conda-python-3.11-hypothesis GitHub Actions
test-conda-python-3.11-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.11-spark-master GitHub Actions
test-conda-python-3.12 GitHub Actions
test-conda-python-3.12-cpython-debug GitHub Actions
test-conda-python-3.12-pandas-latest-numpy-1.26 GitHub Actions
test-conda-python-3.12-pandas-latest-numpy-latest GitHub Actions
test-conda-python-3.13 GitHub Actions
test-conda-python-3.13-pandas-nightly-numpy-nightly GitHub Actions
test-conda-python-3.13-pandas-upstream_devel-numpy-nightly GitHub Actions
test-conda-python-3.14 GitHub Actions
test-conda-python-emscripten GitHub Actions
test-debian-13-python-3-amd64 GitHub Actions
test-debian-13-python-3-i386 GitHub Actions
test-fedora-42-python-3 GitHub Actions
test-ubuntu-22.04-python-3 GitHub Actions
test-ubuntu-22.04-python-313-freethreading GitHub Actions
test-ubuntu-24.04-python-3 GitHub Actions
wheel-macos-monterey-cp310-cp310-amd64 GitHub Actions
wheel-macos-monterey-cp310-cp310-arm64 GitHub Actions
wheel-macos-monterey-cp311-cp311-amd64 GitHub Actions
wheel-macos-monterey-cp311-cp311-arm64 GitHub Actions
wheel-macos-monterey-cp312-cp312-amd64 GitHub Actions
wheel-macos-monterey-cp312-cp312-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313-arm64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-amd64 GitHub Actions
wheel-macos-monterey-cp313-cp313t-arm64 GitHub Actions
wheel-macos-monterey-cp314-cp314-amd64 GitHub Actions
wheel-macos-monterey-cp314-cp314-arm64 GitHub Actions
wheel-macos-monterey-cp314-cp314t-amd64 GitHub Actions
wheel-macos-monterey-cp314-cp314t-arm64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-amd64 GitHub Actions
wheel-manylinux-2-28-cp310-cp310-arm64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-amd64 GitHub Actions
wheel-manylinux-2-28-cp311-cp311-arm64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-amd64 GitHub Actions
wheel-manylinux-2-28-cp312-cp312-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313-arm64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-amd64 GitHub Actions
wheel-manylinux-2-28-cp313-cp313t-arm64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314-amd64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314-arm64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314t-amd64 GitHub Actions
wheel-manylinux-2-28-cp314-cp314t-arm64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-amd64 GitHub Actions
wheel-musllinux-1-2-cp310-cp310-arm64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-amd64 GitHub Actions
wheel-musllinux-1-2-cp311-cp311-arm64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-amd64 GitHub Actions
wheel-musllinux-1-2-cp312-cp312-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313-arm64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-amd64 GitHub Actions
wheel-musllinux-1-2-cp313-cp313t-arm64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314-amd64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314-arm64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314t-amd64 GitHub Actions
wheel-musllinux-1-2-cp314-cp314t-arm64 GitHub Actions
wheel-windows-cp310-cp310-amd64 GitHub Actions
wheel-windows-cp311-cp311-amd64 GitHub Actions
wheel-windows-cp312-cp312-amd64 GitHub Actions
wheel-windows-cp313-cp313-amd64 GitHub Actions
wheel-windows-cp313-cp313t-amd64 GitHub Actions
wheel-windows-cp314-cp314-amd64 GitHub Actions
wheel-windows-cp314-cp314t-amd64 GitHub Actions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants