Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nit internal fixes for PrometheusExporter #3525

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private static MeterProviderBuilder AddPrometheusExporter(MeterProviderBuilder b
{
configure?.Invoke(options);

var exporter = new PrometheusExporter(scrapeEndpointPath: options.ScrapeEndpointPath, scrapeResponseCacheDurationMilliseconds: options.ScrapeResponseCacheDurationMilliseconds);
var exporter = new PrometheusExporter(scrapeResponseCacheDurationMilliseconds: options.ScrapeResponseCacheDurationMilliseconds);
var reader = new BaseExportingMetricReader(exporter)
{
TemporalityPreference = MetricReaderTemporalityPreference.Cumulative,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ internal sealed class PrometheusExporter : BaseExporter<Metric>, IPullMetricExpo
/// <summary>
/// Initializes a new instance of the <see cref="PrometheusExporter"/> class.
/// </summary>
/// <param name="scrapeEndpointPath">Scraping endpoint.</param>
/// <param name="scrapeResponseCacheDurationMilliseconds">
/// The cache duration in milliseconds for scrape responses. Default value: 0.
/// </param>
public PrometheusExporter(string scrapeEndpointPath = null, int scrapeResponseCacheDurationMilliseconds = 0)
public PrometheusExporter(int scrapeResponseCacheDurationMilliseconds = 0)
{
Guard.ThrowIfOutOfRange(scrapeResponseCacheDurationMilliseconds, min: 0);

this.ScrapeEndpointPath = scrapeEndpointPath ?? "/metrics";
this.ScrapeResponseCacheDurationMilliseconds = scrapeResponseCacheDurationMilliseconds;
this.CollectionManager = new PrometheusCollectionManager(this);
}
Expand All @@ -67,8 +65,6 @@ internal Func<Batch<Metric>, ExportResult> OnExport

internal int ScrapeResponseCacheDurationMilliseconds { get; }

internal string ScrapeEndpointPath { get; }

/// <inheritdoc/>
public override ExportResult Export(in Batch<Metric> metrics)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public PrometheusHttpListener(PrometheusExporter exporter, PrometheusHttpListene

this.exporter = exporter;

string path = this.exporter.ScrapeEndpointPath;
string path = options.ScrapeEndpointPath;

if (!path.StartsWith("/"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private static MeterProviderBuilder AddPrometheusHttpListener(
{
configure?.Invoke(options);

var exporter = new PrometheusExporter(scrapeEndpointPath: options.ScrapeEndpointPath);
var exporter = new PrometheusExporter();

var reader = new BaseExportingMetricReader(exporter)
{
Expand Down