diff --git a/examples/dotnet/fast-slow/Dockerfile b/examples/dotnet/fast-slow/Dockerfile index 9a77af3d57..8a56bc5963 100644 --- a/examples/dotnet/fast-slow/Dockerfile +++ b/examples/dotnet/fast-slow/Dockerfile @@ -2,16 +2,26 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0 WORKDIR /dotnet -COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-glibc /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-glibc /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so + ADD example . RUN dotnet publish -o . -r $(dotnet --info | grep RID | cut -b 6- | tr -d ' ') +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 PYROSCOPE_APPLICATION_NAME=fast-slow.dotnet.app ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/ ENV PYROSCOPE_LOG_LEVEL=debug +ENV PYROSCOPE_PROFILING_ENABLED=1 +ENV PYROSCOPE_PROFILING_ALLOCATION_ENABLED=true +ENV PYROSCOPE_PROFILING_CONTENTION_ENABLED=true +ENV PYROSCOPE_PROFILING_EXCEPTION_ENABLED=true -RUN adduser --disabled-password --gecos --quiet pyroscope -USER pyroscope -CMD ["pyroscope", "exec", "-spy-name", "dotnetspy", "/dotnet/example"] +CMD ["/dotnet/example"] diff --git a/examples/dotnet/fast-slow/docker-compose.yml b/examples/dotnet/fast-slow/docker-compose.yml index 459ea2598c..72b3402b49 100644 --- a/examples/dotnet/fast-slow/docker-compose.yml +++ b/examples/dotnet/fast-slow/docker-compose.yml @@ -7,5 +7,11 @@ services: - '4040:4040' command: - 'server' - app: - build: '' + app-glibc: + build: + context: . + dockerfile: Dockerfile + app-musl: + build: + context: . + dockerfile: musl.Dockerfile \ No newline at end of file diff --git a/examples/dotnet/fast-slow/musl.Dockerfile b/examples/dotnet/fast-slow/musl.Dockerfile new file mode 100644 index 0000000000..51725d8ce4 --- /dev/null +++ b/examples/dotnet/fast-slow/musl.Dockerfile @@ -0,0 +1,27 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine + +WORKDIR /dotnet + +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-musl /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-musl /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so + +ADD example . + +RUN dotnet publish -o . -r $(dotnet --info | grep RID | cut -b 6- | tr -d ' ') + +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 PYROSCOPE_APPLICATION_NAME=fast-slow.dotnet.app +ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/ +ENV PYROSCOPE_LOG_LEVEL=debug +ENV PYROSCOPE_PROFILING_ENABLED=1 +ENV PYROSCOPE_PROFILING_ALLOCATION_ENABLED=true +ENV PYROSCOPE_PROFILING_CONTENTION_ENABLED=true +ENV PYROSCOPE_PROFILING_EXCEPTION_ENABLED=true + + +CMD ["/dotnet/example"] diff --git a/examples/dotnet/rideshare/Dockerfile b/examples/dotnet/rideshare/Dockerfile index 2f255a05ce..3c4161eec5 100644 --- a/examples/dotnet/rideshare/Dockerfile +++ b/examples/dotnet/rideshare/Dockerfile @@ -1,12 +1,11 @@ -FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0 -# FROM --platform=linux/amd64 mcr.microsoft.com/dotnet/sdk:6.0-alpine +FROM mcr.microsoft.com/dotnet/sdk:6.0 WORKDIR /dotnet -RUN wget -qO- https://github.com/grafana/pyroscope-dotnet/releases/download/v0.8.3-pyroscope/pyroscope.glibc.tar.gz \ - | tar xvz -# RUN wget -qO- https://github.com/grafana/pyroscope-dotnet/releases/download/v0.8.3-pyroscope/pyroscope.musl.tar.gz \ -# | tar xvz +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-glibc /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-glibc /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so + + ADD example . RUN dotnet publish -o . -r $(dotnet --info | grep RID | cut -b 6- | tr -d ' ') diff --git a/examples/dotnet/rideshare/docker-compose.yml b/examples/dotnet/rideshare/docker-compose.yml index aad391fa16..a9f8e703fe 100644 --- a/examples/dotnet/rideshare/docker-compose.yml +++ b/examples/dotnet/rideshare/docker-compose.yml @@ -34,6 +34,19 @@ services: build: context: . + ap-south-alpine: + ports: + - 5000 + environment: + - REGION=ap-south + - PYROSCOPE_LABELS=region:ap-south-alpine + - PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 + - ASPNETCORE_URLS=http://*:5000 + build: + context: . + dockerfile: musl.Dockerfile + + pyroscope: image: pyroscope/pyroscope:latest environment: diff --git a/examples/dotnet/rideshare/musl.Dockerfile b/examples/dotnet/rideshare/musl.Dockerfile new file mode 100644 index 0000000000..9d6f3bc030 --- /dev/null +++ b/examples/dotnet/rideshare/musl.Dockerfile @@ -0,0 +1,27 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine + +WORKDIR /dotnet + +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-musl /Pyroscope.Profiler.Native.so ./Pyroscope.Profiler.Native.so +COPY --from=pyroscope/pyroscope-dotnet:0.8.7-musl /Pyroscope.Linux.ApiWrapper.x64.so ./Pyroscope.Linux.ApiWrapper.x64.so + + +ADD example . + +RUN dotnet publish -o . -r $(dotnet --info | grep RID | cut -b 6- | tr -d ' ') + +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 PYROSCOPE_APPLICATION_NAME=rideshare.dotnet.app +ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 +ENV PYROSCOPE_LOG_LEVEL=debug +ENV PYROSCOPE_PROFILING_ENABLED=1 +ENV PYROSCOPE_PROFILING_ALLOCATION_ENABLED=true +ENV PYROSCOPE_PROFILING_CONTENTION_ENABLED=true +ENV PYROSCOPE_PROFILING_EXCEPTION_ENABLED=true + + +CMD ["dotnet", "/dotnet/example.dll"] diff --git a/examples/dotnet/web/Dockerfile b/examples/dotnet/web/Dockerfile deleted file mode 100644 index 5b6a9d510c..0000000000 --- a/examples/dotnet/web/Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 - -WORKDIR /dotnet - -COPY --from=pyroscope/pyroscope:latest /usr/bin/pyroscope /usr/bin/pyroscope -ADD example . - -RUN dotnet publish -o . -r $(dotnet --info | grep RID | cut -b 6- | tr -d ' ') - -ENV PYROSCOPE_APPLICATION_NAME=web.dotnet.app -ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/ -ENV PYROSCOPE_LOG_LEVEL=debug - -RUN adduser --disabled-password --gecos --quiet pyroscope -USER pyroscope - -CMD ["pyroscope", "exec", "dotnet", "/dotnet/example.dll"] diff --git a/examples/dotnet/web/docker-compose.yml b/examples/dotnet/web/docker-compose.yml deleted file mode 100644 index 2d047e8f81..0000000000 --- a/examples/dotnet/web/docker-compose.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -version: '3.9' -services: - pyroscope: - image: 'pyroscope/pyroscope:latest' - ports: - - '4040:4040' - command: - - 'server' - app: - environment: - ASPNETCORE_URLS: http://*:5000 - ports: - - '5000:5000' - build: '' diff --git a/examples/dotnet/web/example/Example.csproj b/examples/dotnet/web/example/Example.csproj deleted file mode 100644 index 5056495f1f..0000000000 --- a/examples/dotnet/web/example/Example.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - net6.0 - example - Exe - example - - \ No newline at end of file diff --git a/examples/dotnet/web/example/Program.cs b/examples/dotnet/web/example/Program.cs deleted file mode 100644 index e9746636be..0000000000 --- a/examples/dotnet/web/example/Program.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; - -public static class Program -{ - public static void Main() - { - WebHost.CreateDefaultBuilder() - .Configure(app => - { - app.UseRouting(); - app.UseEndpoints(endpoints => - { - endpoints.MapGet("/", async context => - { - var j = 0; - for (var i = 0; i < 100000000; i++) j++; - await context.Response.WriteAsync("Hello!"); - }); - }); - }) - .Build() - .Run(); - } -} \ No newline at end of file