-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are known bugs in 7.0, compatability issues across target fxs, as well as some strange/dangerous default behaviors This release aligns to 8.x for prometheus-net as well as .net 8 and chooses defaults that make sense for web apps
- Loading branch information
1 parent
9fade3c
commit 0a9730e
Showing
12 changed files
with
119 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 20 additions & 4 deletions
24
src/Spiffy.Monitoring.Prometheus/PrometheusConfigurationApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
using System; | ||
|
||
namespace Spiffy.Monitoring.Prometheus | ||
{ | ||
public class PrometheusConfigurationApi | ||
{ | ||
#if NET6_0_OR_GREATER | ||
internal bool SuppressMeters { get; private set; } = true; | ||
internal bool SuppressDebugMetrics { get; private set; } = true; | ||
|
||
public PrometheusConfigurationApi() | ||
{ | ||
RuntimeStats = global::Prometheus.DotNetRuntime.DotNetRuntimeStatsBuilder.Customize(); | ||
} | ||
|
||
public global::Prometheus.DotNetRuntime.DotNetRuntimeStatsBuilder.Builder RuntimeStats { get; private set; } | ||
#endif | ||
|
||
[Obsolete("Prometheus.DotNetRuntime is poorly maintained and has been removed from options for this library. Consider removing, or otherwise move configuration to a different location", true)] | ||
public object RuntimeStats { get ; } = null; | ||
|
||
public PrometheusConfigurationApi EnableMeters() | ||
{ | ||
SuppressMeters = false; | ||
return this; | ||
} | ||
|
||
public PrometheusConfigurationApi EnableDebugMetrics() | ||
{ | ||
SuppressDebugMetrics = false; | ||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
src/Spiffy.Monitoring.Prometheus/Spiffy.Monitoring.Prometheus.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Prometheus; | ||
using Spiffy.Monitoring; | ||
using Spiffy.Monitoring.Console; | ||
using Spiffy.Monitoring.Prometheus; | ||
|
||
Configuration.Initialize(spiffy => | ||
{ | ||
spiffy.Providers | ||
.Console() | ||
.Prometheus(); | ||
}); | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
var app = builder.Build(); | ||
app.UseRouting(); | ||
|
||
app.MapGet("/", () => "Hello World!"); | ||
|
||
app.UseEndpoints(endpoints => { | ||
Check warning on line 20 in tests/TestWebApp/Program.cs GitHub Actions / build
|
||
endpoints.MapMetrics(); | ||
}); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5124", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Spiffy.Monitoring.Prometheus\Spiffy.Monitoring.Prometheus.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="prometheus-net.AspNetCore" Version="8.2.*" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters