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

Added MetricsUrl for HttpMetricsMiddleware #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -10,11 +10,16 @@ public sealed class HttpMiddlewareExporterOptions
public HttpRequestDurationOptions RequestDuration { get; set; } = new HttpRequestDurationOptions();

/// <summary>
/// Whether to capture metrics for queries to the /metrics endpoint (where metrics are exported by default). Defaults to false.
/// This matches against URLs starting with the /metrics string specifically - if you use a custom metrics endpoint, this will not match.
/// Whether to capture metrics for queries to the MetricsUrl endpoint. Defaults to false.
/// </summary>
public bool CaptureMetricsUrl { get; set; }

/// <summary>
/// The Url used for the CaptureMetricsUrl property.
/// This defaults to /metrics where metrics are exported by default
/// </summary>
public string MetricsUrl { get; set; } = "/metrics";

/// <summary>
/// Configures all the different types of metrics to use reduced status code cardinality (using 2xx instead of 200, 201 etc).
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion Prometheus.AspNetCore/HttpMetricsMiddlewareExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ApplyConfiguration(IApplicationBuilder builder)
if (options.CaptureMetricsUrl)
ApplyConfiguration(app);
else
app.UseWhen(context => context.Request.Path != "/metrics", ApplyConfiguration);
app.UseWhen(context => context.Request.Path != options.MetricsUrl, ApplyConfiguration);

return app;
}
Expand Down