https://github.com/gghez/flask_applicationinsights
Microsoft Azure Application Insights extension for Flask
https://github.com/gghez/flask_applicationinsights
api applicationinsights azure flask microsoft python rest
Last synced: 5 months ago
JSON representation
Microsoft Azure Application Insights extension for Flask
- Host: GitHub
- URL: https://github.com/gghez/flask_applicationinsights
- Owner: gghez
- License: mit
- Created: 2018-08-24T20:00:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T20:21:35.000Z (about 3 years ago)
- Last Synced: 2025-03-18T18:03:57.163Z (over 1 year ago)
- Topics: api, applicationinsights, azure, flask, microsoft, python, rest
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flask_applicationinsights
Flask extension for Microsoft Azure Application Insights.
Make your Flask application able to send tracking information to an Application Insights Azure component.
[](https://travis-ci.org/gghez/flask_applicationinsights)
[](https://codecov.io/gh/gghez/flask_applicationinsights)
## 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.
```python
from flask import Flask
from flask_applicationinsights import ApplicationInsights
app = Flask(__name__)
insight = ApplicationInsights(instrumentation_key='')
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.
```python
...
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.