Skip to content

Commit 779d957

Browse files
authored
Merge pull request #40 from prom-client-net/feat/update-prom-client
feat: update prom-client
2 parents d1b1d73 + 6001da2 commit 779d957

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/Prometheus.Client.AspNetCore.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Description>ASP.NET Core middleware for the Prometheus.Client</Description>
4-
<VersionPrefix>4.6.0</VersionPrefix>
4+
<VersionPrefix>4.7.0</VersionPrefix>
55
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
66
<PackageId>Prometheus.Client.AspNetCore</PackageId>
77
<RepositoryUrl>https://github.com/prom-client-net/prom-client-aspnetcore</RepositoryUrl>
@@ -12,7 +12,7 @@
1212
<None Include="../icon.png" Visible="false" Pack="true" PackagePath="" />
1313
</ItemGroup>
1414
<ItemGroup>
15-
<PackageReference Include="Prometheus.Client" Version="[4.5.3,5.0.0)" />
15+
<PackageReference Include="Prometheus.Client" Version="[5.0.0,6.0.0)" />
1616
</ItemGroup>
1717
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0' OR '$(TargetFramework)' == 'net6.0'">
1818
<FrameworkReference Include="Microsoft.AspNetCore.App" />

src/PrometheusExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder a
4040
throw new ArgumentException($"MapPath '{options.MapPath}' should start with '/'");
4141

4242
if (options.UseDefaultCollectors)
43-
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName);
43+
{
44+
#pragma warning disable CS0618
45+
if (options.AddLegacyMetrics)
46+
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName, options.AddLegacyMetrics);
47+
else
48+
options.CollectorRegistryInstance.UseDefaultCollectors(options.MetricPrefixName);
49+
#pragma warning restore CS0618
50+
}
4451

4552
var contentType = "text/plain; version=0.0.4";
4653

src/PrometheusOptions.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Text;
23
using Prometheus.Client.Collectors;
34

@@ -14,7 +15,7 @@ public class PrometheusOptions
1415
public string MapPath { get; set; } = "/metrics";
1516

1617
/// <summary>
17-
/// When specified only allow access to metrics on this port, otherwise return 404, default = null.
18+
/// When specified only allow access to metrics on this port, otherwise return 404
1819
/// </summary>
1920
public int? Port { get; set; }
2021

@@ -37,5 +38,20 @@ public class PrometheusOptions
3738
/// Metric prefix for Default collectors
3839
/// </summary>
3940
public string MetricPrefixName { get; set; } = "";
41+
42+
/// <summary>
43+
/// Add legacy metrics to Default collectors
44+
/// </summary>
45+
/// <remarks>
46+
/// Some metrics renamed since v5, <c>AddLegacyMetrics</c> will add old and new name<br />
47+
/// <para>
48+
/// process_virtual_bytes -> process_virtual_memory_bytes<br />
49+
/// process_private_bytes -> process_private_memory_bytes<br />
50+
/// process_working_set -> process_working_set_bytes<br />
51+
/// dotnet_totalmemory -> dotnet_total_memory_bytes
52+
/// </para>
53+
/// </remarks>
54+
[Obsolete("'AddLegacyMetrics' will be removed in future versions")]
55+
public bool AddLegacyMetrics { get; set; }
4056
}
4157
}

0 commit comments

Comments
 (0)