Skip to content

Commit 9c7a8d8

Browse files
committed
Cleanup code
1 parent afbc32e commit 9c7a8d8

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

src/Prometheus.Client.MetricServer/MetricHandler.cs renamed to src/Prometheus.Client.MetricServer/BaseMetricServer.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33

44
namespace Prometheus.Client.MetricServer
55
{
6-
public abstract class MetricHandler
6+
/// <summary>
7+
/// Base Abstract MetricSever
8+
/// </summary>
9+
public abstract class BaseMetricServer
710
{
11+
/// <summary>
12+
/// CollectorRegistry
13+
/// </summary>
814
protected readonly ICollectorRegistry Registry;
915

10-
protected MetricHandler(IEnumerable<IOnDemandCollector> standardCollectors = null,
16+
/// <summary>
17+
/// Constructor
18+
/// </summary>
19+
protected BaseMetricServer(IEnumerable<IOnDemandCollector> standardCollectors = null,
1120
ICollectorRegistry registry = null)
1221
{
1322
Registry = registry ?? CollectorRegistry.Instance;
@@ -19,6 +28,5 @@ protected MetricHandler(IEnumerable<IOnDemandCollector> standardCollectors = nul
1928

2029
CollectorRegistry.Instance.RegisterOnDemandCollectors(standardCollectors);
2130
}
22-
2331
}
24-
}
32+
}

src/Prometheus.Client.MetricServer/IMetricServer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace Prometheus.Client.MetricServer
22
{
3+
/// <summary>
4+
/// MetricSever
5+
/// </summary>
36
public interface IMetricServer
47
{
58
/// <summary>

src/Prometheus.Client.MetricServer/MetricServer.HttpListener.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,40 @@
66

77
namespace Prometheus.Client.MetricServer
88
{
9-
public class MetricServer : MetricHandler, IMetricServer
9+
/// <summary>
10+
/// MetricSever based of HttpListener
11+
/// </summary>
12+
public class MetricServer : BaseMetricServer, IMetricServer
1013
{
1114
private readonly HttpListener _httpListener = new HttpListener();
1215

16+
/// <summary>
17+
/// Constructor
18+
/// </summary>
1319
public MetricServer(int port, bool useHttps = false)
1420
: this("+", port, Consts.DefaultUrl, null, null, useHttps)
1521
{
1622
}
1723

24+
/// <summary>
25+
/// Constructor
26+
/// </summary>
1827
public MetricServer(string host, int port, bool useHttps = false)
1928
: this(host, port, Consts.DefaultUrl, null, null, useHttps)
2029
{
21-
2230
}
2331

32+
/// <summary>
33+
/// Constructor
34+
/// </summary>
2435
public MetricServer(string host, int port, string url, bool useHttps = false)
2536
: this(host, port, url, null, null, useHttps)
2637
{
2738
}
2839

40+
/// <summary>
41+
/// Constructor
42+
/// </summary>
2943
public MetricServer(string hostname, int port, string url, IEnumerable<IOnDemandCollector> standardCollectors = null, ICollectorRegistry registry = null, bool useHttps = false)
3044
: base(standardCollectors, registry)
3145
{
@@ -57,7 +71,6 @@ public void Start()
5771
}
5872

5973
response.Close();
60-
6174
}, null);
6275
}
6376

src/Prometheus.Client.MetricServer/MetricServer.Kestrel.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,43 @@
1212

1313
namespace Prometheus.Client.MetricServer
1414
{
15-
public class MetricServer : MetricHandler, IMetricServer
15+
16+
/// <summary>
17+
/// MetricSever based of Kestrel
18+
/// </summary>
19+
public class MetricServer : BaseMetricServer, IMetricServer
1620
{
1721
private readonly X509Certificate2 _certificate;
1822
private readonly string _hostAddress;
1923
private IWebHost _host;
2024

25+
/// <summary>
26+
/// Constructor
27+
/// </summary>
2128
public MetricServer(int port, bool useHttps = false)
2229
: this("+", port, Consts.DefaultUrl, null, null, null, useHttps)
2330
{
2431
}
2532

33+
/// <summary>
34+
/// Constructor
35+
/// </summary>
2636
public MetricServer(string host, int port, bool useHttps = false)
2737
: this(host, port, Consts.DefaultUrl, null, null, null, useHttps)
2838
{
29-
3039
}
3140

41+
/// <summary>
42+
/// Constructor
43+
/// </summary>
3244
public MetricServer(string host, int port, string url, bool useHttps = false)
3345
: this(host, port, url, null, null, null, useHttps)
3446
{
3547
}
3648

49+
/// <summary>
50+
/// Constructor
51+
/// </summary>
3752
public MetricServer(string hostname, int port, string url, IEnumerable<IOnDemandCollector> standardCollectors = null, ICollectorRegistry registry = null, X509Certificate2 certificate = null, bool useHttps = false)
3853
: base(standardCollectors, registry)
3954
{
@@ -46,6 +61,9 @@ public MetricServer(string hostname, int port, string url, IEnumerable<IOnDemand
4661
}
4762

4863

64+
/// <summary>
65+
/// Server is Running?
66+
/// </summary>
4967
public bool IsRunning => _host != null;
5068

5169
/// <inheritdoc />

src/Prometheus.Client.MetricServer/Prometheus.Client.MetricServer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
1616
<RepositoryType>git</RepositoryType>
1717
<RepositoryUrl>https://github.com/phnx47/Prometheus.MetricServer</RepositoryUrl>
18+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
19+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1820
</PropertyGroup>
1921

2022
<ItemGroup>

0 commit comments

Comments
 (0)