Skip to content

Commit

Permalink
PR feedback - revert changes in PrometheusHttpListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Sep 26, 2022
1 parent 7263165 commit 87e95f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// </copyright>

using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -36,18 +35,16 @@ internal sealed class PrometheusHttpListener : IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="PrometheusHttpListener"/> class.
/// </summary>
/// <param name="exporter"><see cref="PrometheusExporter"/>The path to use for the scraping endpoint.</param>
/// <param name="scrapeEndpointPath">The configured HttpListener options.</param>
/// <param name="uriPrefixes">The URI (Uniform Resource Identifier) prefixes to use for the http listener.</param>
public PrometheusHttpListener(PrometheusExporter exporter, string scrapeEndpointPath, IEnumerable<string> uriPrefixes)
/// <param name="exporter"><see cref="PrometheusExporter"/>The exporter instance.</param>
/// <param name="options"><see cref="PrometheusHttpListenerOptions"/>The configured HttpListener options.</param>
public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListenerOptions options)
{
Guard.ThrowIfNull(exporter);
Guard.ThrowIfNullOrWhitespace(scrapeEndpointPath);
Guard.ThrowIfNull(uriPrefixes);
Guard.ThrowIfNull(options);

this.exporter = exporter;

string path = scrapeEndpointPath;
string path = options.ScrapeEndpointPath;

if (!path.StartsWith("/"))
{
Expand All @@ -59,7 +56,7 @@ public PrometheusHttpListener(PrometheusExporter exporter, string scrapeEndpoint
path = $"{path}/";
}

foreach (string uriPrefix in uriPrefixes)
foreach (string uriPrefix in options.UriPrefixes)
{
this.httpListener.Prefixes.Add($"{uriPrefix.TrimEnd('/')}{path}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private static MeterProviderBuilder AddPrometheusHttpListener(

try
{
var listener = new PrometheusHttpListener(exporter, options.ScrapeEndpointPath, options.UriPrefixes);
var listener = new PrometheusHttpListener(exporter, options);
exporter.OnDispose = () => listener.Dispose();
listener.Start();
}
Expand Down

0 comments on commit 87e95f9

Please sign in to comment.