{"id":13502110,"url":"https://github.com/closeio/flask-tracking","last_synced_at":"2025-03-29T10:32:46.092Z","repository":{"id":5171290,"uuid":"6343718","full_name":"closeio/flask-tracking","owner":"closeio","description":"Tracking app for Flask that logs HTTP request and response information in a capped MongoDB collection ","archived":true,"fork":false,"pushed_at":"2019-09-04T09:30:41.000Z","size":19,"stargazers_count":41,"open_issues_count":0,"forks_count":10,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-10-31T21:35:39.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"elastic/elasticsearch","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/closeio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-22T22:58:48.000Z","updated_at":"2024-02-27T18:36:30.000Z","dependencies_parsed_at":"2022-07-06T11:14:55.541Z","dependency_job_id":null,"html_url":"https://github.com/closeio/flask-tracking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fflask-tracking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fflask-tracking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fflask-tracking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/closeio%2Fflask-tracking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/closeio","download_url":"https://codeload.github.com/closeio/flask-tracking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174207,"owners_count":20735406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:02.195Z","updated_at":"2025-03-29T10:32:45.757Z","avatar_url":"https://github.com/closeio.png","language":"Python","readme":"flask-tracking\n==============\n\nflask-tracking is a tracking app for Flask that logs HTTP request and response information in a capped MongoDB collection. For each request, the execution time is stored, making it easy to identify slow requests. flask-tracking supports [Flask-Login](http://packages.python.org/Flask-Login/) to store the currently logged in user and requires [MongoEngine](http://mongoengine.org/) to store the tracking information.\n\n## Installation\n\nIn your main application file, install the tracking app as follows:\n\n```\nfrom flask_tracking import Tracking\nTracking(app)\n```\n\nMake sure to set up the tracking app as early as possible to ensure accurate logging of the response and execution time. If you're using [Flask-gzip](https://github.com/closeio/Flask-gzip), install the tracking middleware afterwards to avoid logging compressed responses.\n\nFrom now on, all requests are stored in the tracking collection.\n\n## Configuration\n\n- `TRACKING_EXCLUDE`: A list of regular expressions of paths that you want to exclude from being tracked.\n\n    Example:\n```\nTRACKING_EXCLUDE = [\n    '^/favicon.ico$',\n    '^/static/',\n    '^/_debug_toolbar/',\n]\n```\n\n- `TRACKING_EXCLUDE_BODY`: A list of regular expressions of paths where you don't want to track the request and response body. This is useful if specific paths receive or return sensitive data.\n\n    Example:\n```\nTRACKING_EXCLUDE_BODY = [\n    '^/auth/login/$'\n]\n```\n\n- `TRACKING_MAX_BODY_LENGTH`: The maximum size in bytes of the request and response body that should be stored.\n\n## Examples\n\nThe following query shows all requests that took longer than one second to execute.\n\n```\nfrom flask_tracking.documents import Tracking\nTracking.objects.filter(execution_time__gte=1000)\n```\n\nThe following query shows all requests that were served between 23:40 and 23:45 UTC on October 22th, 2012:\n\n```\nfrom flask_tracking.documents import Tracking\nTracking.objects.filter(date_created__gte='2012-10-22 23:40:00', date_created__lte='2012-10-22 23:45:00')\n```\n\n## Storing custom data\n\nSometimes it is useful to store custom data in the tracking table for a given request. To do that, simply assign your data to `request._tracking_data`. Example:\n\n```\nfrom flask import request\ndef my_view():\n    request._tracking_data = {'action: 'view', 'my_stuff': [1, 2, 3]}\n    return render()\n```\n\nCustom data is stored in a `DynamicField` called `custom_data` and can therefore contain any information.\n","funding_links":[],"categories":["Python","介绍"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloseio%2Fflask-tracking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloseio%2Fflask-tracking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloseio%2Fflask-tracking/lists"}