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

http_requests_total is only available as a default metric #15

Closed
jpslopes opened this issue Oct 30, 2020 · 3 comments
Closed

http_requests_total is only available as a default metric #15

jpslopes opened this issue Oct 30, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jpslopes
Copy link

Hello, I noticed that the default metrics contain the metric http_requests_total. As this metric is only defined inside the method default, it was necessary to create it as a custom metric:

def http_requests_total(metric_namespace='', metric_subsystem='') -> Callable[[Info], None]:
    total = Counter(
        name="http_requests_total",
        documentation="Total number of requests by method, status and handler.",
        labelnames=(
            "method",
            "status",
            "handler",
        ),
        namespace=metric_namespace,
        subsystem=metric_subsystem,
    )

    def instrumentation(info: Info) -> None:
        total.labels(info.method, info.modified_status, info.modified_handler).inc()

    return instrumentation

It would be great to have this metric available as a method like latency and response_size.

Thanks!

@trallnag
Copy link
Owner

trallnag commented Oct 30, 2020

Hey @jpslopes, yes I think this is a good improvement. Will integrate it this weekend. Thanks for raising it

@trallnag trallnag self-assigned this Oct 30, 2020
@trallnag trallnag added the enhancement New feature or request label Oct 30, 2020
@trallnag
Copy link
Owner

trallnag commented Nov 1, 2020

Implemented in 5.5.0.

Docs https://trallnag.github.io/prometheus-fastapi-instrumentator/metrics.html#prometheus_fastapi_instrumentator.metrics.requests

@trallnag trallnag closed this as completed Nov 1, 2020
@jpslopes
Copy link
Author

jpslopes commented Nov 2, 2020

Thanks for implementing it.

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