cyberdelia / metrology

A library to easily measure what's going on in your python.
https://metrology.readthedocs.org
MIT License
308 stars 25 forks source link

Provide integration with WSGI or Flask #18

Open diyan opened 10 years ago

diyan commented 10 years ago

Hello again,

I'm developing Flask extension that collects some metrics from the Flask app.

Flask extension that collects metrics using Metrology and push them to Graphite - https://gist.github.com/diyan/8829149

It's supposed to have some meaningful defaults which could be changes in app settings.

Right now code is alpha quality and works only for my use-cases but I've decided to share it on an early phase.

Would be glad to get any feedback on this (negative is fine).

Also I'm considering split this code into two pieses (but not entirely sure that it's a good idea):

This extension sends following metrics to Graphite:

metrology.<hostname>.<process_name>.flask.http_code_2xx.one_minute_rate
metrology.<hostname>.<process_name>.flask.http_code_3xx.one_minute_rate
metrology.<hostname>.<process_name>.flask.http_code_4xx.one_minute_rate
metrology.<hostname>.<process_name>.flask.http_code_5xx.one_minute_rate
metrology.<hostname>.<process_name>.flask.endpoins.<module_name>__<function_name>.one_minute_rate
metrology.<hostname>.<process_name>.flask.endpoins.<module_name>__<function_name>.percentile_95th
metrology.<hostname>.<process_name>.flask.endpoins.<module_name>__<function_name>.count

Known issues:

cyberdelia commented 10 years ago

Love the idea, but would prefer if it wasn't tied to a framework, so I like the WSGI middleware even better!