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

Ability to export Prometheus Metrics on a function project #4283

Open
lbargery opened this issue Mar 8, 2023 · 2 comments
Open

Ability to export Prometheus Metrics on a function project #4283

lbargery opened this issue Mar 8, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@lbargery
Copy link

lbargery commented Mar 8, 2023

Feature Request

Is your feature request related to a problem?

My problem is that I'd like to be able to have prometheus scrape metrics from an HTTP endpoint on my functions project. The current middleware won't work for this since that's very server orientated. I imagine I will need to add a HTTP function endpoint to my functions project and write the metrics in. However, because so many of the classes are internal, this isn't possible.

Describe the solution you'd like:

I think this could be solve by either making the classes public (which I appreciate you might not want to do!) or by making an extension method of some form which operates on the HttpRequestData. Something a bit like this though can probably use dependency injection much better than passing all services.

public class Metrics
{
    private readonly IServiceProvider _serviceProvider;

    public Metrics(IServiceProvider serviceProvider)
    {
        _serviceProvider = serviceProvider;
    }

    [Function("/metrics")]
    public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req,
        FunctionContext executionContext)
    {
        return req.WritePrometheusMetrics(_serviceProvider);

    }
}

Describe alternatives you've considered.

I could currently use reflection to hack around this? Not sure if anything else I could do.

Additional Context

Happy to have a go at implementing this myself if the general functionality request is okay.

@lbargery lbargery added the enhancement New feature or request label Mar 8, 2023
@RohitRanjanMS
Copy link

Hi @lbargery, we are actively working on a feature to enable OpenTelemetry support, ETA April/May. Here's our Azure/azure-functions-host#9273.
I would also like to understand your scenario better, are you looking to export ASP.NetCore metrics or your own custom metrics? Please transfer this issue over to the azure-functions-host repo.

@RohitRanjanMS
Copy link

@BigMorty FYI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants