Skip to content

Commit

Permalink
adds 'ignore' section in readme.md and bumped version to 1.4 (#61)
Browse files Browse the repository at this point in the history
* adds routes ignoring implementation  #59

* adds logging

* adds missing ignore configuration for mongodb env

* adds 'ignore' section in readme.md and bumped version to 1.4
  • Loading branch information
muatik authored Feb 17, 2017
1 parent f75c3b8 commit 384b842
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 14 deletions.
41 changes: 30 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Flask-profiler


**version: 1.3** [![Build Status](https://travis-ci.org/muatik/flask-profiler.svg?branch=master)](https://travis-ci.org/muatik/flask-profiler)
**version: 1.4** [![Build Status](https://travis-ci.org/muatik/flask-profiler.svg?branch=master)](https://travis-ci.org/muatik/flask-profiler)

##### Flask-profiler measures endpoints defined in your flask application; and provides you fine-grained report through a web interface.

It gives answer to these questions:
It gives answers to these questions:
* Where are the bottlenecks in my application?
* Which endpoints are the slowest in my application?
* Which are the most frequently called endpoints?
Expand Down Expand Up @@ -57,7 +57,10 @@ app.config["flask_profiler"] = {
"enabled": True,
"username": "admin",
"password": "admin"
}
},
"ignore": [
"^/static/.*"
]
}


Expand All @@ -75,6 +78,10 @@ def updateProduct(id):
def listProducts():
return "suppose I send you product list..."

@app.route('/static/something/', methods=['GET'])
def listProducts():
return "this should not be tracked..."

# In order to active flask-profiler, you have to pass flask
# app as an argument to flask-profiler.
# All the endpoints declared so far will be tracked by flask-profiler.
Expand Down Expand Up @@ -113,13 +120,13 @@ curl http://127.0.0.1:5000/product/123
curl -X PUT -d arg1=val1 http://127.0.0.1:5000/product/123
```

If everything is okay, Flask-profiler will measure these requests. You can see the result heading to http://127.0.0.1:5000/flask-profiler/ or get results as json http://127.0.0.1:5000/flask-profiler/api/measurements?sort=elapsed,desc
If everything is okay, Flask-profiler will measure these requests. You can see the result heading to http://127.0.0.1:5000/flask-profiler/ or get results as JSON http://127.0.0.1:5000/flask-profiler/api/measurements?sort=elapsed,desc

## Using with different database system
Currently **Sqlite** and **Mongodb** database systems are supported. However, it is easy to support other database systems. If you would like to have others, please go to contribution documentation. (It is really easy.)
Currently, **SQLite** and **MongoDB** database systems are supported. However, it is easy to support other database systems. If you would like to have others, please go to contribution documentation. (It is really easy.)

### Sqlite
In order to use Sqlite, just specify it as the value of `storage.engine` directive as follows.
### SQLite
In order to use SQLite, just specify it as the value of `storage.engine` directive as follows.

```json
app.config["flask_profiler"] = {
Expand All @@ -133,11 +140,11 @@ Below the other options are listed.

| Filter key | Description | Default |
|----------|-------------|------|
| storage.FILE | sqlite database file name | flask_profiler.sql|
| storage.FILE | SQLite database file name | flask_profiler.sql|
| storage.TABLE | table name in which profiling data will reside | measurements |

### Mongodb
In order to use Mongodb, just specify it as the value of `storage.engine` directive as follows.
### MongoDB
In order to use MongoDB, just specify it as the value of `storage.engine` directive as follows.

```json
app.config["flask_profiler"] = {
Expand Down Expand Up @@ -190,14 +197,26 @@ app.config["flask_profiler"] = {
If sampling function is not present, all requests will be sampled.

### Changing flask-profiler endpoint root
By default we can access flask-profiler at <your-app>/flask-profiler
By default, we can access flask-profiler at <your-app>/flask-profiler

```python
app.config["flask_profiler"] = {
"endpointRoot": "secret-flask-profiler"
}
```

### Ignored endpoints
Flask-profiler will try to track every endpoint defined so far when init_app() is invoked. If you want to exclude some of the endpoints, you can define matching regex for them as follows:

```python
app.config["flask_profiler"] = {
"ignore": [
"^/static/.*",
"/api/users/\w+/password"
]
}
```


## Contributing

Expand Down
4 changes: 2 additions & 2 deletions flask_profiler/flask_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def is_ignored(name, conf):


def measure(f, name, method, context=None):
logger.debug("{} is being processed.".format(name))
logger.debug("{0} is being processed.".format(name))
if is_ignored(name, CONF):
logger.debug("{} is ignored.".format(name))
logger.debug("{0} is ignored.".format(name))
return f

@functools.wraps(f)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

setup(
name='flask_profiler',
version='1.3',
version='1.4',
url='https://github.com/muatik/flask-profiler',
license=open('LICENSE').read(),
author='Mustafa Atik',
Expand Down

0 comments on commit 384b842

Please sign in to comment.