File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
src/Prometheus.Client.AspNetCore Expand file tree Collapse file tree 3 files changed +12
-6
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.4 .0</VersionPrefix >
4+ <VersionPrefix >4.5 .0</VersionPrefix >
55 <TargetFrameworks >netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks >
66 <AssemblyName >Prometheus.Client.AspNetCore</AssemblyName >
77 <PackageId >Prometheus.Client.AspNetCore</PackageId >
2929 </None >
3030 </ItemGroup >
3131 <ItemGroup >
32- <PackageReference Include =" Prometheus.Client" Version =" [4.4.0,5.0.0) " />
32+ <PackageReference Include =" Prometheus.Client" Version =" 4.5.1 " />
3333 </ItemGroup >
3434 <ItemGroup Condition =" '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net5.0'" >
3535 <FrameworkReference Include =" Microsoft.AspNetCore.App" />
Original file line number Diff line number Diff line change @@ -23,9 +23,10 @@ public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder a
2323 /// </summary>
2424 public static IApplicationBuilder UsePrometheusServer ( this IApplicationBuilder app , Action < PrometheusOptions > setupOptions )
2525 {
26- var options = new PrometheusOptions ( ) ;
27- options . CollectorRegistryInstance
28- = ( ICollectorRegistry ) app . ApplicationServices . GetService ( typeof ( ICollectorRegistry ) ) ?? Metrics . DefaultCollectorRegistry ;
26+ var options = new PrometheusOptions
27+ {
28+ CollectorRegistryInstance = ( ICollectorRegistry ) app . ApplicationServices . GetService ( typeof ( ICollectorRegistry ) ) ?? Metrics . DefaultCollectorRegistry
29+ } ;
2930
3031 setupOptions ? . Invoke ( options ) ;
3132
@@ -39,7 +40,7 @@ public static IApplicationBuilder UsePrometheusServer(this IApplicationBuilder a
3940 throw new ArgumentException ( $ "MapPath '{ options . MapPath } ' should start with '/'") ;
4041
4142 if ( options . UseDefaultCollectors )
42- options . CollectorRegistryInstance . UseDefaultCollectors ( ) ;
43+ options . CollectorRegistryInstance . UseDefaultCollectors ( options . MetricPrefixName ) ;
4344
4445 var contentType = "text/plain; version=0.0.4" ;
4546
Original file line number Diff line number Diff line change @@ -32,5 +32,10 @@ public class PrometheusOptions
3232 /// Charset of text response.
3333 /// </summary>
3434 public Encoding ResponseEncoding { get ; set ; }
35+
36+ /// <summary>
37+ /// Metric prefix for Default collectors
38+ /// </summary>
39+ public string MetricPrefixName { get ; set ; } = "" ;
3540 }
3641}
You can’t perform that action at this time.
0 commit comments