Skip to content

Commit 9a01123

Browse files
committed
improve summary comments
1 parent 9068e71 commit 9a01123

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

src/IMetricServer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
namespace Prometheus.Client.MetricServer;
22

33
/// <summary>
4-
/// MetricSever
4+
/// Interface for the metrics server.
55
/// </summary>
66
public interface IMetricServer
77
{
88
/// <summary>
9-
/// Server is Running?
9+
/// Get a value indicating whether the server is currently running.
1010
/// </summary>
1111
bool IsRunning { get; }
1212

1313
/// <summary>
14-
/// Start server
14+
/// Start the metrics server.
1515
/// </summary>
1616
void Start();
1717

1818
/// <summary>
19-
/// Stop server
19+
/// Stop the metrics server.
2020
/// </summary>
2121
void Stop();
2222
}

src/MetricServer.cs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,46 @@
99

1010
namespace Prometheus.Client.MetricServer;
1111

12-
/// <inheritdoc cref="IMetricServer" />
1312
/// <summary>
14-
/// MetricSever based of Kestrel
13+
/// Kestrel-based implementation of the metrics server.
1514
/// </summary>
1615
public class MetricServer : IMetricServer
1716
{
1817
private readonly MetricServerOptions _options;
1918
private IWebHost _host;
2019

2120
/// <summary>
22-
/// Constructor
21+
/// Initialize a new instance of the <see cref="MetricServer"/> class with default options.
2322
/// </summary>
2423
public MetricServer()
2524
: this(new MetricServerOptions())
2625
{
2726
}
2827

2928
/// <summary>
30-
/// Constructor
29+
/// Initialize a new instance of the <see cref="MetricServer"/> class with the specified options.
3130
/// </summary>
31+
/// <param name="options">The server configuration options.</param>
3232
public MetricServer(MetricServerOptions options)
3333
{
3434
ArgumentNullException.ThrowIfNull(options);
35-
3635
if (!options.MapPath.StartsWith('/'))
3736
options.MapPath = "/" + options.MapPath;
38-
3937
_options = options;
40-
4138
_options.CollectorRegistry ??= Metrics.DefaultCollectorRegistry;
42-
4339
if (_options.UseDefaultCollectors)
4440
options.CollectorRegistry.UseDefaultCollectors(options.MetricPrefixName);
4541
}
4642

47-
/// <inheritdoc />
4843
public bool IsRunning => _host != null;
4944

50-
/// <inheritdoc />
5145
public void Start()
5246
{
5347
if (IsRunning)
5448
return;
55-
5649
var configBuilder = new ConfigurationBuilder();
5750
configBuilder.Properties["parent"] = this;
5851
var config = configBuilder.Build();
59-
6052
_host = new WebHostBuilder()
6153
.UseConfiguration(config)
6254
.UseKestrel(options =>
@@ -68,16 +60,13 @@ public void Start()
6860
.ConfigureServices(services => { services.AddSingleton<IStartup>(new Startup(_options)); })
6961
.UseSetting(WebHostDefaults.ApplicationKey, typeof(Startup).GetTypeInfo().Assembly.FullName)
7062
.Build();
71-
7263
_host.Start();
7364
}
7465

75-
/// <inheritdoc />
7666
public void Stop()
7767
{
7868
if (!IsRunning)
7969
return;
80-
8170
_host.Dispose();
8271
_host = null;
8372
}
@@ -101,14 +90,12 @@ public void Configure(IApplicationBuilder app)
10190
var contentType = _options.ResponseEncoding != null
10291
? $"{Defaults.ContentType}; charset={_options.ResponseEncoding.BodyName}"
10392
: Defaults.ContentType;
104-
10593
app.Map(_options.MapPath, coreapp =>
10694
{
10795
coreapp.Run(async context =>
10896
{
10997
var response = context.Response;
11098
response.ContentType = contentType;
111-
11299
await using var outputStream = response.Body;
113100
await ScrapeHandler.ProcessAsync(_options.CollectorRegistry, outputStream);
114101
});

src/MetricServerOptions.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
1-
using System;
21
using System.Security.Cryptography.X509Certificates;
32
using System.Text;
43
using Prometheus.Client.Collectors;
54

65
namespace Prometheus.Client.MetricServer;
76

87
/// <summary>
9-
/// Metric Server Options
8+
/// Configuration options for the metrics server.
109
/// </summary>
1110
public class MetricServerOptions
1211
{
1312
/// <summary>
14-
/// Host name
13+
/// The hostname to bind the server to. Default is "*".
1514
/// </summary>
1615
public string Host { get; set; } = "*";
1716

1817
/// <summary>
19-
/// Port number to listen
18+
/// The port number to listen on. Default is 5000.
2019
/// </summary>
2120
public int Port { get; set; } = 5000;
2221

2322
/// <summary>
24-
/// Endpoint path
23+
/// The endpoint path for metrics. Default is "/metrics".
2524
/// </summary>
2625
public string MapPath { get; set; } = Defaults.MapPath;
2726

2827
/// <summary>
29-
/// Https certificate
28+
/// The HTTPS certificate.
3029
/// </summary>
3130
public X509Certificate2 Certificate { get; set; }
3231

3332
/// <summary>
34-
/// Collector Registry instance
33+
/// The <see cref="ICollectorRegistry"/> instance to use for metric collection.
3534
/// </summary>
3635
public ICollectorRegistry CollectorRegistry { get; set; }
3736

3837
/// <summary>
39-
/// Use default collectors(dotnet and process stats)
38+
/// Whether to register default collectors. Default is <c>true</c>.
4039
/// </summary>
4140
public bool UseDefaultCollectors { get; set; } = true;
4241

4342
/// <summary>
44-
/// Charset of text response.
43+
/// The text encoding for response content.
4544
/// </summary>
4645
public Encoding ResponseEncoding { get; set; }
4746

4847
/// <summary>
49-
/// Metric prefix for Default collectors
48+
/// Metric name prefix for default collectors.
5049
/// </summary>
5150
public string MetricPrefixName { get; set; } = string.Empty;
5251
}

0 commit comments

Comments
 (0)