{"id":18447481,"url":"https://github.com/revsys/django-tracer","last_synced_at":"2025-04-08T00:32:07.977Z","repository":{"id":57422406,"uuid":"62672765","full_name":"revsys/django-tracer","owner":"revsys","description":"Generate a UUID on all Django requests for traceability","archived":false,"fork":false,"pushed_at":"2018-07-31T16:24:54.000Z","size":48,"stargazers_count":15,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-16T07:36:40.149Z","etag":null,"topics":["django","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/revsys.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-05T22:05:50.000Z","updated_at":"2024-05-09T02:24:43.000Z","dependencies_parsed_at":"2022-09-13T15:12:46.164Z","dependency_job_id":null,"html_url":"https://github.com/revsys/django-tracer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Fdjango-tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revsys","download_url":"https://codeload.github.com/revsys/django-tracer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755440,"owners_count":20990617,"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":["django","python3"],"created_at":"2024-11-06T07:13:27.673Z","updated_at":"2025-04-08T00:32:04.936Z","avatar_url":"https://github.com/revsys.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-tracer\n========================\n[![Build Status](https://travis-ci.org/revsys/django-tracer.svg?branch=master)](https://travis-ci.org/revsys/django-tracer)\n\nGenerate a UUID for all requests to Django to be used in logging and error reporting for traceability. \n\n# Why? \n\nWhy would you want to use this silly little thing? Well in a containerized, orchestrated, microservice world with centralized logging it's often hard to figure out where things have gone wrong.  \n\nThis little middleware adds a UUID to the normal Django request object which you can use to add to add to things like: \n\n- All of your log messages\n- Error reports to Sentry/Rollbar/etc\n- Pass along to other internal services\n\nAlong with generating and attaching a UUID to each request, the middleware also automatically adds the UUID to the response headers as `X-Request-ID` so anyone consuming your responses, say as an API, can use that as a reference point for reporting errors back to you. \n\n# Installation\n\nFirst you need to install it via pip: \n\n```shell\npip install django-tracer\n```\n\nThen just add `tracer` to `INSTALLED_APPS` in your settings. \n\nThen add `tracer.middleware.RequestID` to the top of your `MIDDLEWARE` settings. \n\n# Usage with standard logging\n\n```python\nimport logging\n\nfrom django.http import HttpResponse\n\nlogger = logging.getLogger(__name__)\n\ndef some_view(request):\n    \"\"\" simple log example \"\"\"\n    logger.info(\"Whee!\", extra={'request_id': request.id})\n    return HttpResponse(\"example content\")\n```\n\n## Other ways to use this Request ID\n\nThere are several other places you may consider wanting to use the ID to improve traceability: \n\n- Pass it as an argument to any Celery tasks you generate so there is a clear path between the incoming request and the tasks that were generated from it\n- Pass it as a header or argument to other internal APIs or services \n- Attach it to a bound [structlog](http://www.structlog.org/) object so it is always included in your log output\n\n# Thanks! \n\nSpecial thanks to [Rolf Håvard Blindheim](https://github.com/rhblind) for graciously turning over the name `django-tracer` to us to be able to use it for this project. \n\n## Need help?\n\n[REVSYS](http://www.revsys.com?utm_medium=github\u0026utm_source=django-tracer) can help with your Python, Django, and infrastructure projects. If you have a question about this project, please open a GitHub issue. If you love us and want to keep track of our goings-on, here's where you can find us online:\n\n\u003ca href=\"https://revsys.com?utm_medium=github\u0026utm_source=django-tracer\"\u003e\u003cimg src=\"https://pbs.twimg.com/profile_images/915928618840285185/sUdRGIn1_400x400.jpg\" height=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/revsys\"\u003e\u003cimg src=\"https://cdn1.iconfinder.com/data/icons/new_twitter_icon/256/bird_twitter_new_simple.png\" height=\"43\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.facebook.com/revsysllc/\"\u003e\u003cimg src=\"https://cdn3.iconfinder.com/data/icons/picons-social/57/06-facebook-512.png\" height=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/revsys/\"\u003e\u003cimg src=\"https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png\" height=\"53\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://gitlab.com/revsys\"\u003e\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/GitLab_Logo.svg/2000px-GitLab_Logo.svg.png\" height=\"44\" /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Fdjango-tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevsys%2Fdjango-tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Fdjango-tracer/lists"}