Git Product home page Git Product logo

flask-stats's Introduction

flask-stats

Flask-stats is a simple plugin that allows you to have important information and statistics for the endpoints that you have. It collects all the data and then you can access it through endpoints live. This plug-in allows to monitor simple api without the necessity of any payment, such as new relic

Status: working progress

Instalation

pip install flask-api-stats

A Simple Example

from time import sleep
from flask import Flask
from flask_stats import Stats

s = Stats()

app = Flask(__name__)
s.init_app(app)

@app.route('/')
def hello():
    sleep(10)
    return 'Hello World!'

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

Adding Stats(app) allows to register statistics of the API such as response time or configuration.

In any time, we can enter in /endpoints_stats to see duration of each endpoint

{
    duration: [
        {
            endpoint "/" : {
                avg: 10.009691333770752,
                count: 5,
                max: 10.010810375213623,
                min: 10.007489919662476,
                percentile_25: 10.007489919662476,
                percentile_50: 10.01064133644104,
                percentile_75: 10.010623693466187,
                percentile_90: 10.010810375213623
            }
        },
    ...
    ]
}

Other endpoint is /stats where we can see uptime, gc_stats and other configurations

{
gc_stats: {
    gc.get_debug: 0,
    gc.get_stats: {
        collected: 5455,
        collections: 130,
        uncollectable: 0
    ...
    },
    uptime: 1210.0311439037323,
    uptime_readable: {
        days: 0,
        hours: 0,
        minutes: 20,
        seconds: 10.0311439037323
    }
}

Contact

Please if you have any doubt or found any bug report and issue or send an email to fernando.bugni(a)gmail.com

flask-stats's People

Contributors

fernandobugni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.