Microsoft Azure Application Insights integration for Flask.
Project description
flask_applicationinsights
Flask extension for Microsoft Azure Application Insights.
Make your Flask application able to send tracking information to an Application Insights Azure component.
Dependencies
- flask>=1.0.2
- applicationinsights==0.11.6
If you are encountering locale issues with application insights, please check this hack: https://github.com/Azure/azure-cli-shell/issues/63
Usage
Retrieve package from pypi:
pip install flask_applicationinsights
Instrumentation key can be provided programmatically as well as by environment variable or flask configuration key. Key name is
APPINSIGHTS_INSTRUMENTATION_KEY
.
Basic
Will track all requests (succeeded or failed) to your application insight referenced by its instrumentation key.
from flask import Flask
from flask_applicationinsights import ApplicationInsights
app = Flask(__name__)
insight = ApplicationInsights(instrumentation_key='<yours>')
insight.init_app(app)
@app.route('/')
def index():
return 'HIT'
app.run()
Advanced
You can also add custom properties or measurements to each tracked request by using special decorators.
...
insight = ApplicationInsights(...)
...
@insight.properties
def custom_properties(req: Request, resp: Response):
return {
'req_pragma': req.headers.get('Pragma'),
'resp_charset': resp.charset
}
Contribution
Not open yet due to initial WIP.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for Flask-ApplicationInsights-0.2.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10ce04a8143c9b1d25a5513bfc1d98fbfcf1b2657bbaa266609d1e29f41e1c81 |
|
MD5 | 483285160f55147f9ddd622b3b8efcb0 |
|
BLAKE2b-256 | f0a0bee79e2984027c7fecd4a2ee3204073bb8a42ef84b370f486f89585473d7 |