Skip to main content

RED-Metrics-Tracker

Simple RED Metrics tracker able to instrument flask views using prometheus metrics.

Install

With pip, of course:

pip install red-metrics-tracker

Instrumenting

Tracking all methods and exceptions for all requests on a view:

app = flask.Flask(__name__)

@app.route("/endpoint")
@FlaskRedMetricsTracker.track()
def do_things():
     ...
     return "OK"

Limiting metrics tracking to specific methods:

@app.route("/endpoint", methods=["POST", "GET", "PUT", "DELETE"])
@FlaskRedMetricsTracker.track(methods=["POST", "DELETE"])
def do_things():
     ...
     return "OK"

Limiting to specific exceptions:

@app.route("/endpoint/<condition>")
@FlaskRedMetricsTracker.track(exceptions=MySpecialException)
def do_things():
     ...
     if condition == "throw":
        raise MySpecialException
     return "OK"

Filters may be combined, of course:

@app.route("/endpoint/<condition>", methods=["POST", "GET", "DELETE"])
@FlaskRedMetricsTracker.track(methods=["GET", "POST"]exceptions=MySpecialException)
def do_things():
     ...
     if condition == "throw":
        raise MySpecialException
     return "OK"

Exposition

Feel free to use prometheus_client to run an http_server serving a /metrics endpoint at its configured port.

For the people who’d like the /metrics endpoint to be part of their flask app, there’s a blueprint for that:

import flask
from red import metrics_blueprint

app = flask.Flask(__name__)
app.register_blueprint(metrics_blueprint)

Metrics are now available at you app’s url under the /metrics endpoint.

Metadata

Release files for RED-Metrics-Tracker 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RED-Metrics-Tracker 0.1.1
File Size Uploaded Provenance Actions
RED-Metrics-Tracker-0.1.1.tar.gz 6.8 kB Without provenance Details for RED-Metrics-Tracker-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RED-Metrics-Tracker 0.1.1
File Interpreter ABI Platform Actions
RED_Metrics_Tracker-0.1.1-py3-none-any.whl Python 3 none any Details for RED_Metrics_Tracker-0.1.1-py3-none-any.whl

Total release size: 20.0 kB

Release files / RED-Metrics-Tracker-0.1.1.tar.gz

Download URL RED-Metrics-Tracker-0.1.1.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
faf64bb7099770c6da811a74b2d9f7aa60590cfa2085bffa53c2b3632861e68c
BLAKE2b-256 checksum
How to use checksums
e5d9b59b72ded63b310ddea758a5e4e3d051bfa1f4434320dd73ccbb5342f980
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Release files / RED_Metrics_Tracker-0.1.1-py3-none-any.whl

Download URL RED_Metrics_Tracker-0.1.1-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c2c2053885f925bb85cce761aacdb5faf3a4e235871c425cf4404ec256ed063
BLAKE2b-256 checksum
How to use checksums
52b8c9da6299de5f2f492c459d01896dc319d3baec0a52fe9d9e79948caaeaf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.22.0

Security for RED-Metrics-Tracker 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page