Skip to content
Merged
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Pyroscope.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions Pyroscope.musl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

28 changes: 20 additions & 8 deletions Pyroscope/Pyroscope/Profiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public void SetDynamicTag(string key, string value)
{
NativeInterop.SetDynamicTag(key, value);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -59,8 +60,9 @@ public void ClearDynamicTags()
{
NativeInterop.ClearDynamicTags();
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -80,8 +82,9 @@ public void SetCPUTrackingEnabled(bool enabled)
{
NativeInterop.SetCPUTrackingEnabled(enabled);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -100,8 +103,9 @@ public void SetAllocationTrackingEnabled(bool enabled)
{
NativeInterop.SetAllocationTrackingEnabled(enabled);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -120,8 +124,9 @@ public void SetContentionTrackingEnabled(bool enabled)
{
NativeInterop.SetContentionTrackingEnabled(enabled);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -140,8 +145,9 @@ public void SetExceptionTrackingEnabled(bool enabled)
{
NativeInterop.SetExceptionTrackingEnabled(enabled);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -156,8 +162,9 @@ public void SetAuthToken(string authToken)
{
NativeInterop.SetAuthToken(authToken);
}
catch (DllNotFoundException)
catch (DllNotFoundException ex)
{
DllNotFound(ex);
_dllNotFound = true;
}
}
Expand All @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions itest.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion profiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
4 changes: 2 additions & 2 deletions profiler/test/Datadog.Profiler.Native.Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down