Skip to content

Better Dev Experience for UseOpenTelemetryPrometheusScrapingEndpoint() Extension Method #3267

@hannahchan

Description

@hannahchan

In the Prometheus exporter, the current .UseOpenTelemetryPrometheusScrapingEndpoint() extension method under the hood branches the middleware pipeline by using the .Map() and .MapWhen() methods. It may be more appropriate to rename this method to .MapOpenTelemetryPrometheusScrapingEndpoint() or just MapPrometheusScrapingEndpoint().

In addition, it might better to update the signature of that method from;

public static IApplicationBuilder UseOpenTelemetryPrometheusScrapingEndpoint(this IApplicationBuilder app, string path)

to;

public static IEndpointConventionBuilder MapPrometheusScrapingEndpoint(this IEndpointRouteBuilder builder, string path)

These changes would make the extension method more consistent with other Endpoint Enabled middleware that branch the middleware pipeline such as the ASP.NET Core HealthCheck middleware .MapHealthChecks() extension method or even the out of the box .MapControllers() method. Returning an IEndpointConventionBuilder would allow the caller to configure the endpoint further. For example;

app.MapPrometheusScrapingEndpoint("/metrics").RequireHost("*:9090");

I'm happy to make the changes myself and submit a PR if someone is willing to accept my contribution. As long as there is an agreement that this is important enough to get fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions