Skip to content

Commit 2924a88

Browse files
authored
Upgrading to .net 3.0 and introducing a github action to build + test… (#16)
* Upgrading to .net 3.0 and introducing a github action to build + test the solution * Forgot to add the action (doh) * next iteration of pipeline * next iteration of pipeline * next iteration of pipeline * next iteration of pipeline * next iteration of pipeline * Fixing broken test (no pinned objects existed to measure) * Upping timeouts to see if we can get the tests to pass * Excluding failing test to see if we can get the build to pass * Renaming existing test worfklow + adding new worfklow to publish to nuget on release * Moving .sln file to the root of the project. Including examples in the solution and removed dedicated examples sln file. Included XML comments in the release builds. * Fixing up the examples to use the prometheus-net.AspNetCore package * Fixing up xml comment violations * Fixing up README * Re-targeting .net core 2.2 * Fixing up test workflow
1 parent 3dffcb1 commit 2924a88

File tree

18 files changed

+169
-92
lines changed

18 files changed

+169
-92
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: publish-nuget-packages
2+
3+
on:
4+
release:
5+
types: [published, prereleased]
6+
7+
jobs:
8+
publish-v2:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-dotnet@v1
13+
with:
14+
dotnet-version: '3.0.100'
15+
- run: dotnet pack src/prometheus-net.DotNetRuntime --include-symbols -c "ReleaseV2" --output "build/"
16+
- run: dotnet nuget push "build/prometheus-net.DotNetRuntime.2.*.symbols.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" -n true
17+
18+
19+
publish-v3:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v1
23+
- uses: actions/setup-dotnet@v1
24+
with:
25+
dotnet-version: '3.0.100'
26+
- run: dotnet pack src/prometheus-net.DotNetRuntime --include-symbols -c "ReleaseV3" --output "build/"
27+
- run: dotnet nuget push "build/prometheus-net.DotNetRuntime.3.*.symbols.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s "https://api.nuget.org/v3/index.json" -n true

.github/workflows/run-tests.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: run-tests
2+
3+
on: [push]
4+
5+
jobs:
6+
test-v2:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1
10+
- uses: actions/setup-dotnet@v1
11+
with:
12+
dotnet-version: '3.0.100'
13+
# excluding When_IO_work_is_executed_on_the_thread_pool_then_the_number_of_io_threads_is_measured for now, for some reason we don't seem to be
14+
# generating IO thread events in the github actions environment
15+
- run: dotnet test -c "DebugV2" --filter Name!=When_IO_work_is_executed_on_the_thread_pool_then_the_number_of_io_threads_is_measured
16+
17+
test-v3:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v1
21+
- uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: '3.0.100'
24+
- run: dotnet test -c "DebugV3" --filter Name!=When_IO_work_is_executed_on_the_thread_pool_then_the_number_of_io_threads_is_measured

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ A plugin for the [prometheus-net](https://github.com/prometheus-net/prometheus-n
99

1010
These metrics are essential for understanding the peformance of any non-trivial application. Even if your application is well instrumented, you're only getting half the story- what the runtime is doing completes the picture.
1111

12-
## Status
13-
**This project is currently in beta**- there are a [number of bugs present in the .NET core 2.2 runtime](https://github.com/djluck/prometheus-net.DotNetRuntime/issues?q=is%3Aissue+is%3Aopen+label%3A".net+core+2.2+bug") that can see metrics not being populated or populated with invalid values or over-consumption of memory. Once .NET core 3.0 is released, this project will move out of beta status.
14-
1512
## Installation
16-
**Requires .NET core v2.2+**.
13+
Supports .NET core v2.2+ but **.NET core v3.0+ is recommended**. There are a [number of bugs present in the .NET core 2.2 runtime](https://github.com/djluck/prometheus-net.DotNetRuntime/issues?q=is%3Aissue+is%3Aopen+label%3A".net+core+2.2+bug")
14+
that can impact metric collection or runtime stability.
1715

1816
Add the packge from [nuget](https://www.nuget.org/packages/prometheus-net.DotNetRuntime):
1917
```powershell
20-
# If you're using v2 of prometheus-net
21-
dotnet add package prometheus-net.DotNetRuntime --version 2.2.0-beta
18+
# If you're using v3.* of prometheus-net
19+
dotnet add package prometheus-net.DotNetRuntime
2220
23-
# If you're using v3 of prometheus-net
24-
dotnet add package prometheus-net.DotNetRuntime --version 3.2.0-beta
21+
# If you're using v2.* of prometheus-net
22+
dotnet add package prometheus-net.DotNetRuntime --version 2.2.0
2523
```
2624

2725
And then start the collector:
@@ -31,7 +29,8 @@ IDisposable collector = DotNetRuntimeStatsBuilder.Default().StartCollecting()
3129

3230
You can customize the types of .NET metrics collected via the `Customize` method:
3331
```csharp
34-
IDisposable collector = DotNetRuntimeStatsBuilder.Customize()
32+
IDisposable collector = DotNetRuntimeStatsBuilder
33+
.Customize()
3534
.WithContentionStats()
3635
.WithJitStats()
3736
.WithThreadPoolSchedulingStats()
@@ -79,9 +78,4 @@ reduce the sampling rate.
7978

8079
## Further reading
8180
- The mechanism for listening to runtime events is outlined in the [.NET core 2.2 release notes](https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-2-2#core).
82-
- A partial list of core CLR events is available in the [ETW events documentation](https://docs.microsoft.com/en-us/dotnet/framework/performance/clr-etw-events).
83-
84-
85-
86-
87-
81+
- A partial list of core CLR events is available in the [ETW events documentation](https://docs.microsoft.com/en-us/dotnet/framework/performance/clr-etw-events).
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup Condition=" $(Configuration.EndsWith('V2')) ">
3+
<PromMajorVersion>2</PromMajorVersion>
4+
<DefineConstants>$(DefineConstants);PROMV2</DefineConstants>
5+
</PropertyGroup>
6+
7+
<PropertyGroup Condition=" $(Configuration.EndsWith('V3')) ">
8+
<PromMajorVersion>3</PromMajorVersion>
9+
<DefineConstants>$(DefineConstants);PROMV3</DefineConstants>
10+
</PropertyGroup>
211

312
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6-
<ServerGarbageCollection>false</ServerGarbageCollection>
13+
<PromMajorVersion Condition="$(PromMajorVersion) == ''">3</PromMajorVersion>
14+
<TargetFramework>netcoreapp3.0</TargetFramework>
15+
<Configurations>ReleaseV2;DebugV2;DebugV3;ReleaseV3</Configurations>
16+
</PropertyGroup>
17+
18+
<PropertyGroup Condition=" $(Configuration.StartsWith('Release')) ">
19+
<Optimize Condition=" '$(Optimize)' == '' ">true</Optimize>
720
</PropertyGroup>
821

922
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12-
<PackageReference Include="prometheus-net.DotNetRuntime" Version="3.0.8-beta" />
23+
<ProjectReference Include="..\..\src\prometheus-net.DotNetRuntime\prometheus-net.DotNetRuntime.csproj" />
24+
</ItemGroup>
25+
26+
<ItemGroup Condition="$(PromMajorVersion) == '3'">
27+
<PackageReference Include="prometheus-net.AspNetCore" Version="3.2.1" />
28+
</ItemGroup>
29+
30+
<ItemGroup Condition="$(PromMajorVersion) == '2'">
31+
<PackageReference Include="prometheus-net.AspNetCore" Version="2.1.3" />
1332
</ItemGroup>
1433
</Project>

examples/AspNetCoreExample/Controllers/ValuesController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public async Task<ActionResult<IEnumerable<string>>> Get()
3535
private void CompileMe(Expression<Func<int>> func)
3636
{
3737
func.Compile()();
38-
3938
}
4039
}
4140
}

examples/AspNetCoreExample/Program.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,31 @@ namespace AspNetCoreExample
1515
{
1616
public class Program
1717
{
18-
1918
public static void Main(string[] args)
2019
{
21-
DotNetRuntimeStatsBuilder.Default().WithErrorHandler(e =>
20+
if (Environment.GetEnvironmentVariable("NOMON") == null)
2221
{
23-
Console.WriteLine(e.ToString());
24-
}).StartCollecting();
25-
var metricServer = new MetricServer(12204);
26-
metricServer.Start();
27-
22+
Console.WriteLine("Enabling prometheus-net.DotNetStats...");
23+
DotNetRuntimeStatsBuilder.Customize()
24+
.WithThreadPoolSchedulingStats()
25+
.WithContentionStats()
26+
.WithGcStats()
27+
.WithJitStats()
28+
.WithThreadPoolStats()
29+
.WithErrorHandler(ex => Console.WriteLine("ERROR: " + ex.ToString()))
30+
//.WithDebuggingMetrics(true);
31+
.StartCollecting();
32+
}
33+
2834
CreateWebHostBuilder(args).Build().Run();
2935
}
3036

3137
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
3238
WebHost.CreateDefaultBuilder(args)
39+
.ConfigureKestrel(opts =>
40+
{
41+
opts.AllowSynchronousIO = true;
42+
})
3343
.UseStartup<Startup>();
3444
}
3545
}

examples/AspNetCoreExample/Properties/launchSettings.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
{
22
"$schema": "http://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:48753",
8-
"sslPort": 44373
9-
}
10-
},
113
"profiles": {
12-
"IIS Express": {
13-
"commandName": "IISExpress",
14-
"launchBrowser": true,
15-
"launchUrl": "api/values",
16-
"environmentVariables": {
17-
"ASPNETCORE_ENVIRONMENT": "Development"
18-
}
19-
},
204
"AspNetCoreExample": {
215
"commandName": "Project",
226
"launchBrowser": true,

examples/AspNetCoreExample/Startup.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Microsoft.Extensions.DependencyInjection;
1111
using Microsoft.Extensions.Logging;
1212
using Microsoft.Extensions.Options;
13+
using Prometheus;
1314

1415
namespace AspNetCoreExample
1516
{
@@ -42,7 +43,15 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
4243
}
4344

4445
app.UseHttpsRedirection();
45-
app.UseMvc();
46+
app.UseRouting();
47+
48+
app.UseEndpoints(endpoints =>
49+
{
50+
// Mapping of endpoints goes here:
51+
endpoints.MapControllers();
52+
});
53+
54+
app.UseMetricServer();
4655
}
4756
}
4857
}

examples/Examples.sln

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prometheus-net.DotNetRuntime", "prometheus-net.DotNetRuntime\prometheus-net.DotNetRuntime.csproj", "{A40AD08A-53CB-40F3-A6D8-6FFCEC024289}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prometheus-net.DotNetRuntime", "src\prometheus-net.DotNetRuntime\prometheus-net.DotNetRuntime.csproj", "{A40AD08A-53CB-40F3-A6D8-6FFCEC024289}"
44
EndProject
5-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prometheus-net.DotNetRuntime.Tests", "prometheus-net.DotNetRuntime.Tests\prometheus-net.DotNetRuntime.Tests.csproj", "{7F4E2E72-5745-4312-B238-CD7B731957B0}"
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "prometheus-net.DotNetRuntime.Tests", "src\prometheus-net.DotNetRuntime.Tests\prometheus-net.DotNetRuntime.Tests.csproj", "{7F4E2E72-5745-4312-B238-CD7B731957B0}"
66
EndProject
7-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarks", "Benchmarks\Benchmarks.csproj", "{2883E527-D3BD-4B98-A4A3-3F5924FB851F}"
7+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{31AD912F-A1DC-434A-8C8D-049F4BBD67D4}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreExample", "examples\AspNetCoreExample\AspNetCoreExample.csproj", "{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}"
810
EndProject
911
Global
1012
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -14,14 +16,6 @@ Global
1416
ReleaseV3|Any CPU = ReleaseV3|Any CPU
1517
EndGlobalSection
1618
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.ReleaseV2|Any CPU.ActiveCfg = ReleaseV2|Any CPU
18-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.ReleaseV2|Any CPU.Build.0 = ReleaseV2|Any CPU
19-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.DebugV2|Any CPU.ActiveCfg = DebugV2|Any CPU
20-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.DebugV2|Any CPU.Build.0 = DebugV2|Any CPU
21-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.DebugV3|Any CPU.ActiveCfg = DebugV3|Any CPU
22-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.DebugV3|Any CPU.Build.0 = DebugV3|Any CPU
23-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.ReleaseV3|Any CPU.ActiveCfg = ReleaseV3|Any CPU
24-
{2883E527-D3BD-4B98-A4A3-3F5924FB851F}.ReleaseV3|Any CPU.Build.0 = ReleaseV3|Any CPU
2519
{A40AD08A-53CB-40F3-A6D8-6FFCEC024289}.ReleaseV2|Any CPU.ActiveCfg = ReleaseV2|Any CPU
2620
{A40AD08A-53CB-40F3-A6D8-6FFCEC024289}.ReleaseV2|Any CPU.Build.0 = ReleaseV2|Any CPU
2721
{A40AD08A-53CB-40F3-A6D8-6FFCEC024289}.DebugV2|Any CPU.ActiveCfg = DebugV2|Any CPU
@@ -38,5 +32,16 @@ Global
3832
{7F4E2E72-5745-4312-B238-CD7B731957B0}.DebugV3|Any CPU.Build.0 = DebugV3|Any CPU
3933
{7F4E2E72-5745-4312-B238-CD7B731957B0}.ReleaseV3|Any CPU.ActiveCfg = ReleaseV3|Any CPU
4034
{7F4E2E72-5745-4312-B238-CD7B731957B0}.ReleaseV3|Any CPU.Build.0 = ReleaseV3|Any CPU
35+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.DebugV2|Any CPU.ActiveCfg = DebugV2|Any CPU
36+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.DebugV2|Any CPU.Build.0 = DebugV2|Any CPU
37+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.DebugV3|Any CPU.ActiveCfg = DebugV3|Any CPU
38+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.DebugV3|Any CPU.Build.0 = DebugV3|Any CPU
39+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.ReleaseV2|Any CPU.ActiveCfg = ReleaseV2|Any CPU
40+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.ReleaseV2|Any CPU.Build.0 = ReleaseV2|Any CPU
41+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.ReleaseV3|Any CPU.ActiveCfg = ReleaseV3|Any CPU
42+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636}.ReleaseV3|Any CPU.Build.0 = ReleaseV3|Any CPU
43+
EndGlobalSection
44+
GlobalSection(NestedProjects) = preSolution
45+
{D01E9ED3-E35C-4F44-A5AD-5350E43AA636} = {31AD912F-A1DC-434A-8C8D-049F4BBD67D4}
4146
EndGlobalSection
4247
EndGlobal

0 commit comments

Comments
 (0)