Skip to content

Commit b84c785

Browse files
committed
style: cleanup code by rider
1 parent 7b874dc commit b84c785

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
using System.Threading.Tasks;
2-
31
namespace Prometheus.Client.MetricServer
42
{
53
/// <summary>
64
/// MetricSever
75
/// </summary>
86
public interface IMetricServer
97
{
8+
/// <summary>
9+
/// Server is Running?
10+
/// </summary>
11+
bool IsRunning { get; }
12+
1013
/// <summary>
1114
/// Start server
1215
/// </summary>
@@ -16,10 +19,5 @@ public interface IMetricServer
1619
/// Stop server
1720
/// </summary>
1821
void Stop();
19-
20-
/// <summary>
21-
/// Server is Running?
22-
/// </summary>
23-
bool IsRunning { get; }
2422
}
2523
}

src/Prometheus.Client.MetricServer/MetricServer.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ public class MetricServer : IMetricServer
2020
private IWebHost _host;
2121

2222
/// <summary>
23-
/// Constructor
23+
/// Constructor
2424
/// </summary>
2525
/// <param name="options">Http server configuration options</param>
2626
public MetricServer(MetricServerOptions options)
27-
:this(null, options)
27+
: this(null, options)
2828
{
2929
}
3030

3131
/// <summary>
32-
/// Constructor
32+
/// Constructor
3333
/// </summary>
3434
/// <param name="registry">Collector registry </param>
3535
/// <param name="options">Http server configuration options</param>
@@ -89,9 +89,9 @@ public void Stop()
8989
internal class Startup : IStartup
9090
{
9191
private const string _contentType = "text/plain; version=0.0.4";
92+
private readonly string _mapPath;
9293

9394
private readonly ICollectorRegistry _registry;
94-
private readonly string _mapPath;
9595

9696
public Startup(ICollectorRegistry registry, string mapPath)
9797
{
@@ -118,10 +118,8 @@ public void Configure(IApplicationBuilder app)
118118
var response = context.Response;
119119
response.ContentType = _contentType;
120120

121-
using (var outputStream = response.Body)
122-
{
123-
await ScrapeHandler.ProcessAsync(_registry, outputStream);
124-
}
121+
using var outputStream = response.Body;
122+
await ScrapeHandler.ProcessAsync(_registry, outputStream);
125123
});
126124
});
127125
}

src/Prometheus.Client.MetricServer/MetricServerOptions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
namespace Prometheus.Client.MetricServer
44
{
55
/// <summary>
6-
/// Metric Server Options
6+
/// Metric Server Options
77
/// </summary>
88
public class MetricServerOptions
99
{
1010
/// <summary>
11-
/// Host name
11+
/// Host name
1212
/// </summary>
1313
public string Host { get; set; } = "*";
1414

1515
/// <summary>
16-
/// Port number to listen
16+
/// Port number to listen
1717
/// </summary>
1818
public int Port { get; set; }
1919

2020
/// <summary>
21-
/// Endpoint path
21+
/// Endpoint path
2222
/// </summary>
2323
public string MapPath { get; set; } = "/metrics";
2424

2525
/// <summary>
26-
/// Https certificate
26+
/// Https certificate
2727
/// </summary>
2828
public X509Certificate2 Certificate { get; set; }
2929
}

tests/Prometheus.Client.MetricServer.Tests/MetricServerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public void Start_Stop_IsRunning()
3131
[Fact]
3232
public async Task Base_MapPath()
3333
{
34-
var metricServer = new MetricServer(new MetricServerOptions { Port = _port});
34+
var metricServer = new MetricServer(new MetricServerOptions { Port = _port });
3535
try
3636
{
3737
metricServer.Start();
3838
var counter = Metrics.DefaultFactory.CreateCounter("test_counter", "help");
3939
counter.Inc();
4040
using var httpClient = new HttpClient();
41-
var response = await httpClient.GetStringAsync($"http://localhost:{_port}/metrics");
41+
string response = await httpClient.GetStringAsync($"http://localhost:{_port}/metrics");
4242
Assert.False(string.IsNullOrEmpty(response));
4343
}
4444
catch (Exception ex)
@@ -62,7 +62,7 @@ public async Task MapPath_WithEndSlash()
6262
var counter = Metrics.DefaultFactory.CreateCounter("test_counter", "help");
6363
counter.Inc();
6464
using var httpClient = new HttpClient();
65-
var response = await httpClient.GetStringAsync($"http://localhost:{_port}/test/");
65+
string response = await httpClient.GetStringAsync($"http://localhost:{_port}/test/");
6666
Assert.False(string.IsNullOrEmpty(response));
6767
}
6868
catch (Exception ex)
@@ -97,7 +97,7 @@ public async Task MapPath(string mapPath)
9797
var counter = Metrics.DefaultFactory.CreateCounter("test_counter", "help");
9898
counter.Inc();
9999
using var httpClient = new HttpClient();
100-
var response = await httpClient.GetStringAsync($"http://localhost:{_port}" + mapPath);
100+
string response = await httpClient.GetStringAsync($"http://localhost:{_port}" + mapPath);
101101
Assert.False(string.IsNullOrEmpty(response));
102102
}
103103
catch (Exception ex)
@@ -127,7 +127,7 @@ public async Task FindMetric()
127127
counter.Inc();
128128

129129
using var httpClient = new HttpClient();
130-
var response = await httpClient.GetStringAsync($"http://localhost:{_port}/metrics");
130+
string response = await httpClient.GetStringAsync($"http://localhost:{_port}/metrics");
131131
Assert.Contains(metricName, response);
132132
}
133133
catch (Exception ex)

0 commit comments

Comments
 (0)