LogMetrics provides simplified configuration to log payload for python flask projects.
Pypi Package
https://pypi.org/project/logmetrics-sdk/
Install Dependencies
pip install logmetrics-sdk
Properties
enable_logmetrics= True
enable_frontend_request= True
enable_frontend_response= True
enable_backend= True
enable_backend_request= True
enable_backend_response= True
Usage — Python Flask Projects
from logmetrics_sdk.logmetrics import LogMetrics
@app.route('/todo/api/v1/tasks', methods=['GET'])
@LogMetrics(enable_logmetrics=True,
enable_frontend_request=True,
enable_frontend_response=True,
enable_backend=True,
enable_backend_request=True,
enable_backend_response=True)
def get_tasks():
return jsonify(tasks)
LogMetrics Schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "LogMetrics",
"properties": {
"Node": {
"type": "string",
"description": "Application Host IP Address"
},
"MessageType": {
"type": "string",
"description": "Logmetrics message type",
"value": "LOGMETRICS_MESSAGE"
},
"Duration": {
"type": "integer",
"description": "Response time of the API"
},
"Host": {
"type": "string",
"description": "Application Host Name"
},
"Fault": {
"type": "boolean",
"description": "API Success or Failed status "
},
"Method": {
"type": "string",
"description": "API Method name"
},
"ResponseBody": {
"type": "string",
"description": "API Response Body"
},
"StartDateTime": {
"type": "string",
"description": "API Start Time"
},
"EndDateTime": {
"type": "string",
"description": "API End time"
},
"HttpMethod": {
"type": "string",
"description": "Http Method Type"
},
"RequestBody": {
"type": "string",
"description": "API Request Body"
}
}
}
Sample logmetrics message
{
"Node": "127.0.0.1",
"MessageType": "LOGMETRICS_MESSAGE",
"Duration": 106,
"Host": "hostname",
"Fault": false,
"Method": "/user-service/api/v1/user/{id}",
"ResponseBody": "{\"id\":1,\"name\":\"02adcec2263d2127269fcd769c33f029\",\"age\":\"35135aaa6cc23891b40cb3f378c53a17a1127210ce60e125ccf03efcfdaec458\",\"salary\":\"********\"}",
"StartDateTime": "Tue Nov 26 23:22:54 EST 2019",
"EndDateTime": "Tue Nov 26 23:22:54 EST 2019",
"HttpMethod": "GET",
"RequestBody": ""
}
Release History
1.0.3
- logging rest verb & payload to console.
- feature to enable/disable payload logging
Demo Project
Want to Contribute to LogMetrics framework?
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'Add some feature'
- Push to the branch: git push origin my-new-feature
- Submit a pull request :D
Top comments (0)