famedly / axum-opentelemetry-middleware

A small middleware allowing users to view request timings/count using prometheus.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Axum Opentelemetry Middleware

A middleware for axum that allows users to get insight into which endpoints are being hit how often for how long as well as registering their own metrics.

Currently it only supports outputting metrics to prometheus. For usage please reference the docs or the examples folder.

By default the following metrics are tracked:

  • http.requests.duration.seconds (labels: endpoint, method, status): the (internal) request duration for all tracked endpoints
  • http.requests.total (labels: endpoint, method, status): the amount of requests for all tracked endpoints
  • http.mismatched.requests.total (labels: none): the amount of attempted requests that didn't hit a registered endpoint

Lints

We have plenty of lints in lints.toml that we use. Cargo currently does not natively support an extra file for lints, so we use cargo-lints. To check everything with our lints, run this locally:

cargo lints clippy --workspace --all-targets

and this in your IDE:

cargo lints clippy --workspace --all-targets --message-format=json

A few lints are commented out in lints.toml. This is because they should not be enabled by default, because e.g. they have false positives. However, they can be very useful sometimes.

Pre-commit usage

  1. If not installed, install with your package manager, or pip install --user pre-commit
  2. Run pre-commit autoupdate to update the pre-commit config to use the newest template
  3. Run pre-commit install to install the pre-commit hooks to your local environment

Famedly

This project is part of the source code of Famedly.

We think that software for healthcare should be open source, so we publish most parts of our source code at github.com/famedly.

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

For licensing information of this project, have a look at the LICENSE file within the repository.

If you compile the open source software that we make available to develop your own mobile, desktop or embeddable application, and cause that application to connect to our servers for any purposes, you have to agree to our Terms of Service. In short, if you choose to connect to our servers, certain restrictions apply as follows:

  • You agree not to change the way the open source software connects and interacts with our servers
  • You agree not to weaken any of the security features of the open source software
  • You agree not to use the open source software to gather data
  • You agree not to use our servers to store data for purposes other than the intended and original functionality of the Software
  • You acknowledge that you are solely responsible for any and all updates to your software

No license is granted to the Famedly trademark and its associated logos, all of which will continue to be owned exclusively by Famedly GmbH. Any use of the Famedly trademark and/or its associated logos is expressly prohibited without the express prior written consent of Famedly GmbH.

For more information take a look at Famedly.com or contact us by info@famedly.com

About

A small middleware allowing users to view request timings/count using prometheus.

License:Apache License 2.0


Languages

Language:Rust 100.0%