Skip to content

Commit 9068e71

Browse files
committed
delete AddLegacyMetrics
1 parent 7bb47b0 commit 9068e71

File tree

3 files changed

+3
-77
lines changed

3 files changed

+3
-77
lines changed

src/MetricServer.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,17 @@ public MetricServer()
3131
/// </summary>
3232
public MetricServer(MetricServerOptions options)
3333
{
34-
if (options == null)
35-
throw new ArgumentNullException(nameof(options));
34+
ArgumentNullException.ThrowIfNull(options);
3635

37-
if (!options.MapPath.StartsWith("/"))
36+
if (!options.MapPath.StartsWith('/'))
3837
options.MapPath = "/" + options.MapPath;
3938

4039
_options = options;
4140

4241
_options.CollectorRegistry ??= Metrics.DefaultCollectorRegistry;
4342

4443
if (_options.UseDefaultCollectors)
45-
{
46-
#pragma warning disable CS0618
47-
if (options.AddLegacyMetrics)
48-
options.CollectorRegistry.UseDefaultCollectors(options.MetricPrefixName, options.AddLegacyMetrics);
49-
else
50-
options.CollectorRegistry.UseDefaultCollectors(options.MetricPrefixName);
51-
#pragma warning restore CS0618
52-
}
44+
options.CollectorRegistry.UseDefaultCollectors(options.MetricPrefixName);
5345
}
5446

5547
/// <inheritdoc />

src/MetricServerOptions.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,4 @@ public class MetricServerOptions
4949
/// Metric prefix for Default collectors
5050
/// </summary>
5151
public string MetricPrefixName { get; set; } = string.Empty;
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; }
6752
}

tests/MetricServerTests.cs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -186,57 +186,6 @@ public async Task CustomCounter_FindMetric()
186186
}
187187
}
188188

189-
[Fact]
190-
public async Task AddLegacyMetrics_False_FindMetrics()
191-
{
192-
try
193-
{
194-
_metricServer.Start();
195-
using var httpClient = new HttpClient();
196-
string response = await httpClient.GetStringAsync($"http://localhost:{fixture.Port}{Defaults.MapPath}", TestContext.Current.CancellationToken);
197-
Assert.Contains("process_private_memory_bytes", response);
198-
Assert.Contains("dotnet_total_memory_bytes", response);
199-
Assert.DoesNotContain("process_private_bytes", response);
200-
Assert.DoesNotContain("dotnet_totalmemory", response);
201-
}
202-
catch (Exception ex)
203-
{
204-
testOutputHelper.WriteLine(ex.ToString());
205-
throw;
206-
}
207-
finally
208-
{
209-
_metricServer.Stop();
210-
}
211-
}
212-
213-
[Fact]
214-
public async Task AddLegacyMetrics_True_FindMetrics()
215-
{
216-
_metricServer = new MetricServer(new MetricServerOptions
217-
{ Port = fixture.Port, CollectorRegistry = new CollectorRegistry(), AddLegacyMetrics = true });
218-
219-
try
220-
{
221-
_metricServer.Start();
222-
using var httpClient = new HttpClient();
223-
string response = await httpClient.GetStringAsync($"http://localhost:{fixture.Port}{Defaults.MapPath}", TestContext.Current.CancellationToken);
224-
Assert.Contains("process_private_memory_bytes", response);
225-
Assert.Contains("dotnet_total_memory_bytes", response);
226-
Assert.Contains("process_private_bytes", response);
227-
Assert.Contains("dotnet_totalmemory", response);
228-
}
229-
catch (Exception ex)
230-
{
231-
testOutputHelper.WriteLine(ex.ToString());
232-
throw;
233-
}
234-
finally
235-
{
236-
_metricServer.Stop();
237-
}
238-
}
239-
240189
[Fact]
241190
public async Task WrongUrl_NotFound()
242191
{

0 commit comments

Comments
 (0)