Skip to main content

A flask extension to log route latency

Project description

A flask extension to log route latency

Example

from flask import Flask
from flask_crlatency import RouteLatencyLogger

app = Flask(__name__)
app.config["SECRET_KEY"] ="your_secret_key"
app.config["DEBUG"] = True
app.config["MAX_ROUTE_LATENCY"] = 0.1

latency_logger = RouteLatencyLogger(app)

@app.route("/")
def index():
    return "Hello, World!"

if __name__ == "__main__":
    app.run()

response:

[2023-08-19 10:00:58,654] WARNING in __init__: High latency for route index: 3.001345 seconds
127.0.0.1 - - [19/Aug/2023 10:00:58] "GET / HTTP/1.1" 200 -

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-crlatency-0.0.2.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

flask_crlatency-0.0.2-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page