File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 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 >
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" />
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1+ using System ;
12using System . Text ;
23using 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}
You can’t perform that action at this time.
0 commit comments