Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .Net support #200

Merged
merged 6 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ifeq ("$(shell go env GOARCH || true)", "arm64")
GODEBUG=asyncpreemptoff=1
endif

ALL_SPIES = "ebpfspy,rbspy,pyspy,debugspy"
ALL_SPIES = "ebpfspy,rbspy,pyspy,dotnetspy,debugspy"
ifeq ("$(shell go env GOOS || true)", "linux")
ENABLED_SPIES ?= "ebpfspy,rbspy,pyspy,phpspy"
ENABLED_SPIES ?= "ebpfspy,rbspy,pyspy,phpspy,dotnetspy"
else
ENABLED_SPIES ?= "rbspy,pyspy"
endif
Expand Down
13 changes: 13 additions & 0 deletions examples/dotnet/3.1/fast-slow/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:3.1

WORKDIR /dotnet

COPY --from=pyroscope/pyroscope:dev /usr/bin/pyroscope /usr/bin/pyroscope
ADD example .

RUN dotnet publish -o . -r linux-x64

ENV PYROSCOPE_APPLICATION_NAME=fast-slow.dotnet.app
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/
ENV PYROSCOPE_LOG_LEVEL=debug
CMD ["pyroscope", "exec", "-spy-name", "dotnetspy", "/dotnet/example"]
13 changes: 13 additions & 0 deletions examples/dotnet/3.1/fast-slow/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: "3.9"
services:
pyroscope:
image: "pyroscope/pyroscope:latest"
ports:
- "4040:4040"
command:
- "server"
app:
build: ""
cap_add:
- SYS_PTRACE
8 changes: 8 additions & 0 deletions examples/dotnet/3.1/fast-slow/example/Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>example</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>example</PackageId>
</PropertyGroup>
</Project>
38 changes: 38 additions & 0 deletions examples/dotnet/3.1/fast-slow/example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Example
{
public class Program
{
public static void Main(string[] args)
{
while (true)
{
_ = new Fast.Work();
_ = new Slow.Work();
}
}
}
}

namespace Slow
{
public class Work
{
public Work()
{
var j = 0;
for (var i = 0; i < 8000; i++) j++;
}
}
}

namespace Fast
{
public class Work
{
public Work()
{
var j = 0;
for (var i = 0; i < 2000; i++) j++;
}
}
}
13 changes: 13 additions & 0 deletions examples/dotnet/3.1/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:3.1

WORKDIR /dotnet

COPY --from=pyroscope/pyroscope:dev /usr/bin/pyroscope /usr/bin/pyroscope
ADD example .

RUN dotnet publish -o . -r linux-x64

ENV PYROSCOPE_APPLICATION_NAME=web.dotnet.app
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/
ENV PYROSCOPE_LOG_LEVEL=debug
CMD ["pyroscope", "exec", "dotnet", "/dotnet/example.dll"]
17 changes: 17 additions & 0 deletions examples/dotnet/3.1/web/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: "3.9"
services:
pyroscope:
image: "pyroscope/pyroscope:latest"
ports:
- "4040:4040"
command:
- "server"
app:
environment:
ASPNETCORE_URLS: http://*:5000
ports:
- "5000:5000"
build: ""
cap_add:
- SYS_PTRACE
8 changes: 8 additions & 0 deletions examples/dotnet/3.1/web/example/Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyName>example</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>example</PackageId>
</PropertyGroup>
</Project>
27 changes: 27 additions & 0 deletions examples/dotnet/3.1/web/example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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();
}
}
13 changes: 13 additions & 0 deletions examples/dotnet/5.0/fast-slow/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0

WORKDIR /dotnet

COPY --from=pyroscope/pyroscope:dev /usr/bin/pyroscope /usr/bin/pyroscope
ADD example .

RUN dotnet publish -o . -r linux-x64

ENV PYROSCOPE_APPLICATION_NAME=fast-slow.dotnet.app
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/
ENV PYROSCOPE_LOG_LEVEL=debug
CMD ["pyroscope", "exec", "-spy-name", "dotnetspy", "/dotnet/example"]
13 changes: 13 additions & 0 deletions examples/dotnet/5.0/fast-slow/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: "3.9"
services:
pyroscope:
image: "pyroscope/pyroscope:latest"
ports:
- "4040:4040"
command:
- "server"
app:
build: ""
cap_add:
- SYS_PTRACE
8 changes: 8 additions & 0 deletions examples/dotnet/5.0/fast-slow/example/Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>example</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>example</PackageId>
</PropertyGroup>
</Project>
38 changes: 38 additions & 0 deletions examples/dotnet/5.0/fast-slow/example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Example
{
public class Program
{
public static void Main(string[] args)
{
while (true)
{
_ = new Fast.Work();
_ = new Slow.Work();
}
}
}
}

namespace Slow
{
public class Work
{
public Work()
{
var j = 0;
for (var i = 0; i < 8000; i++) j++;
}
}
}

namespace Fast
{
public class Work
{
public Work()
{
var j = 0;
for (var i = 0; i < 2000; i++) j++;
}
}
}
13 changes: 13 additions & 0 deletions examples/dotnet/5.0/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0

WORKDIR /dotnet

COPY --from=pyroscope/pyroscope:dev /usr/bin/pyroscope /usr/bin/pyroscope
ADD example .

RUN dotnet publish -o . -r linux-x64

ENV PYROSCOPE_APPLICATION_NAME=web.dotnet.app
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040/
ENV PYROSCOPE_LOG_LEVEL=debug
CMD ["pyroscope", "exec", "dotnet", "/dotnet/example.dll"]
17 changes: 17 additions & 0 deletions examples/dotnet/5.0/web/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
version: "3.9"
services:
pyroscope:
image: "pyroscope/pyroscope:latest"
ports:
- "4040:4040"
command:
- "server"
app:
environment:
ASPNETCORE_URLS: http://*:5000
ports:
- "5000:5000"
build: ""
cap_add:
- SYS_PTRACE
8 changes: 8 additions & 0 deletions examples/dotnet/5.0/web/example/Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>example</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>example</PackageId>
</PropertyGroup>
</Project>
27 changes: 27 additions & 0 deletions examples/dotnet/5.0/web/example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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();
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ require (
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/peterbourgon/ff v1.7.0
github.com/peterbourgon/ff/v3 v3.0.0
github.com/pyroscope-io/dotnetdiag v1.1.0
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sirupsen/logrus v1.7.0
github.com/twmb/murmur3 v1.1.5
github.com/wacul/ptr v1.0.0 // indirect
golang.org/x/tools v0.1.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
google.golang.org/protobuf v1.26.0
honnef.co/go/tools v0.0.1-2020.1.6
)
Expand Down
Loading