File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,14 @@ public MetricServer(MetricServerOptions options)
4242 _options . CollectorRegistryInstance ??= Metrics . DefaultCollectorRegistry ;
4343
4444 if ( _options . UseDefaultCollectors )
45- _options . CollectorRegistryInstance . UseDefaultCollectors ( ) ;
45+ {
46+ #pragma warning disable CS0618
47+ if ( options . AddLegacyMetrics )
48+ options . CollectorRegistryInstance . UseDefaultCollectors ( options . MetricPrefixName , options . AddLegacyMetrics ) ;
49+ else
50+ options . CollectorRegistryInstance . UseDefaultCollectors ( options . MetricPrefixName ) ;
51+ #pragma warning restore CS0618
52+ }
4653 }
4754
4855 /// <inheritdoc />
Original file line number Diff line number Diff line change 1+ using System ;
12using System . Security . Cryptography . X509Certificates ;
23using System . Text ;
34using Prometheus . Client . Collectors ;
@@ -43,5 +44,25 @@ public class MetricServerOptions
4344 /// Charset of text response.
4445 /// </summary>
4546 public Encoding ResponseEncoding { get ; set ; }
47+
48+ /// <summary>
49+ /// Metric prefix for Default collectors
50+ /// </summary>
51+ public string MetricPrefixName { get ; set ; } = "" ;
52+
53+ /// <summary>
54+ /// Add legacy metrics to Default collectors
55+ /// </summary>
56+ /// <remarks>
57+ /// Some metrics renamed since v5, <c>AddLegacyMetrics</c> will add old and new name<br />
58+ /// <para>
59+ /// process_virtual_bytes -> process_virtual_memory_bytes<br />
60+ /// process_private_bytes -> process_private_memory_bytes<br />
61+ /// process_working_set -> process_working_set_bytes<br />
62+ /// dotnet_totalmemory -> dotnet_total_memory_bytes
63+ /// </para>
64+ /// </remarks>
65+ [ Obsolete ( "'AddLegacyMetrics' will be removed in future versions" ) ]
66+ public bool AddLegacyMetrics { get ; set ; }
4667 }
4768}
You can’t perform that action at this time.
0 commit comments