diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index ccdaf8a48..51894654d 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -12,7 +12,7 @@ permissions: jobs: build-profiler-images: name: Build Profiler Image - runs-on: ubuntu-x64-small + runs-on: ubuntu-x64-large strategy: matrix: flavour: @@ -39,7 +39,7 @@ jobs: run-integration-test: name: Run Integration Test needs: build-profiler-images - runs-on: ubuntu-x64-small + runs-on: ubuntu-x64-large strategy: fail-fast: false matrix: diff --git a/Pyroscope.Dockerfile b/Pyroscope.Dockerfile index 6f9969d89..fb186b966 100644 --- a/Pyroscope.Dockerfile +++ b/Pyroscope.Dockerfile @@ -30,9 +30,9 @@ RUN mkdir build-${CMAKE_BUILD_TYPE} && \ -DCMAKE_CXX_FLAGS_DEBUG="-g -O0" \ -DCMAKE_C_FLAGS_DEBUG="-g -O0" -RUN cd build-${CMAKE_BUILD_TYPE} && make -j16 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64 +RUN cd build-${CMAKE_BUILD_TYPE} && make -j16 Pyroscope.Profiler.Native Datadog.Linux.ApiWrapper.x64 FROM busybox:1.36.1-glibc -COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so +COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux/Pyroscope.Profiler.Native.so /Pyroscope.Profiler.Native.so COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so diff --git a/Pyroscope.musl.Dockerfile b/Pyroscope.musl.Dockerfile index b2cf5261e..7249220e0 100644 --- a/Pyroscope.musl.Dockerfile +++ b/Pyroscope.musl.Dockerfile @@ -38,9 +38,9 @@ RUN mkdir build-${CMAKE_BUILD_TYPE} && \ -DCMAKE_CXX_FLAGS_DEBUG="-g -O0" \ -DCMAKE_C_FLAGS_DEBUG="-g -O0" -RUN cd build-${CMAKE_BUILD_TYPE} && make -j16 Datadog.Profiler.Native Datadog.Linux.ApiWrapper.x64 +RUN cd build-${CMAKE_BUILD_TYPE} && make -j16 Pyroscope.Profiler.Native Datadog.Linux.ApiWrapper.x64 FROM busybox:1.36.1-musl -COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl/Datadog.Profiler.Native.so /Pyroscope.Profiler.Native.so +COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl/Pyroscope.Profiler.Native.so /Pyroscope.Profiler.Native.so COPY --from=builder /profiler/profiler/_build/DDProf-Deploy/linux-musl/Datadog.Linux.ApiWrapper.x64.so /Pyroscope.Linux.ApiWrapper.x64.so diff --git a/Pyroscope/Pyroscope/Profiler.cs b/Pyroscope/Pyroscope/Profiler.cs index b17dd404c..37fc5b408 100644 --- a/Pyroscope/Pyroscope/Profiler.cs +++ b/Pyroscope/Pyroscope/Profiler.cs @@ -43,8 +43,9 @@ public void SetDynamicTag(string key, string value) { NativeInterop.SetDynamicTag(key, value); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -59,8 +60,9 @@ public void ClearDynamicTags() { NativeInterop.ClearDynamicTags(); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -80,8 +82,9 @@ public void SetCPUTrackingEnabled(bool enabled) { NativeInterop.SetCPUTrackingEnabled(enabled); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -100,8 +103,9 @@ public void SetAllocationTrackingEnabled(bool enabled) { NativeInterop.SetAllocationTrackingEnabled(enabled); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -120,8 +124,9 @@ public void SetContentionTrackingEnabled(bool enabled) { NativeInterop.SetContentionTrackingEnabled(enabled); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -140,8 +145,9 @@ public void SetExceptionTrackingEnabled(bool enabled) { NativeInterop.SetExceptionTrackingEnabled(enabled); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -156,8 +162,9 @@ public void SetAuthToken(string authToken) { NativeInterop.SetAuthToken(authToken); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } @@ -172,11 +179,16 @@ public void SetBasicAuth(string username, string password) { NativeInterop.SetBasicAuth(username, password); } - catch (DllNotFoundException) + catch (DllNotFoundException ex) { + DllNotFound(ex); _dllNotFound = true; } } + + private static void DllNotFound(DllNotFoundException ex) { + Console.WriteLine($"[Profiler] Failed to load Pyroscope.Profiler.Native.so : {ex}.\nConsider setting LD_LIBRARY_PATH pointing to the directory containing the Pyroscope.Profiler.Native.so"); + } private readonly ContextTracker _contextTracker; private bool _dllNotFound; diff --git a/itest.Dockerfile b/itest.Dockerfile index 7533bcd56..24352d485 100644 --- a/itest.Dockerfile +++ b/itest.Dockerfile @@ -33,15 +33,19 @@ FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/aspnet:$SDK_VERSION$SDK_IMA WORKDIR /dotnet -COPY --from=sdk /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so -COPY --from=sdk /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so +# place the binaries in a subfolder - to rigger a problme when SONAME was Datadog.Profiler.Native +# and dynamic linker could not find the profiler lib. +COPY --from=sdk /Pyroscope.Profiler.Native.so ./subfolder/Pyroscope.Profiler.Native.so +COPY --from=sdk /Pyroscope.Linux.ApiWrapper.x64.so ./subfolder/Pyroscope.Linux.ApiWrapper.x64.so COPY --from=build /dotnet/app ./ +# Fix for alpine not being able to dlopen an already loaded library +ENV LD_LIBRARY_PATH=/dotnet/subfolder/ ENV CORECLR_ENABLE_PROFILING=1 ENV CORECLR_PROFILER={BD1A650D-AC5D-4896-B64F-D6FA25D6B26A} -ENV CORECLR_PROFILER_PATH=/dotnet/Pyroscope.Profiler.Native.so -ENV LD_PRELOAD=/dotnet/Pyroscope.Linux.ApiWrapper.x64.so +ENV CORECLR_PROFILER_PATH=/dotnet/subfolder/Pyroscope.Profiler.Native.so +ENV LD_PRELOAD=/dotnet/subfolder/Pyroscope.Linux.ApiWrapper.x64.so ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 ENV PYROSCOPE_LOG_LEVEL=debug diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 6a18ce71a..80cbe1690 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -143,7 +143,7 @@ enable_testing() add_subdirectory(test) add_custom_target(profiler) -add_dependencies(profiler Datadog.Profiler.Native) +add_dependencies(profiler Pyroscope.Profiler.Native) add_custom_target(all-profiler) add_dependencies(all-profiler profiler profiler-native-tests) diff --git a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CMakeLists.txt b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CMakeLists.txt index 0d71abd70..97428f461 100644 --- a/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CMakeLists.txt +++ b/profiler/src/ProfilerEngine/Datadog.Profiler.Native.Linux/CMakeLists.txt @@ -55,7 +55,7 @@ endif() # Environment detection # ****************************************************** -SET(PROFILER_BASENAME Datadog.Profiler.Native) +SET(PROFILER_BASENAME Pyroscope.Profiler.Native) SET(PROFILER_STATIC_LIB_NAME ${PROFILER_BASENAME}.static) SET(PROFILER_SHARED_LIB_NAME ${PROFILER_BASENAME}) diff --git a/profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt b/profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt index d6c2c4e00..e89debade 100644 --- a/profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt +++ b/profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt @@ -63,7 +63,7 @@ target_include_directories(${TEST_EXECUTABLE_NAME} PUBLIC ${googletest_SOURCE_DIR}/googlemock/include ) -add_dependencies(${TEST_EXECUTABLE_NAME} gmock gtest Datadog.Profiler.Native.static libunwind) +add_dependencies(${TEST_EXECUTABLE_NAME} gmock gtest Pyroscope.Profiler.Native.static libunwind) if (RUN_ASAN) target_link_libraries(${TEST_EXECUTABLE_NAME} -fsanitize=address) @@ -74,7 +74,7 @@ if (RUN_UBSAN) endif() target_link_libraries(${TEST_EXECUTABLE_NAME} - Datadog.Profiler.Native.static + Pyroscope.Profiler.Native.static gtest_main gmock_main -static-libgcc