{ "info": { "author": "Kiwi.com platform", "author_email": "platform@kiwi.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# structlog-sentry\n\n| What | Where |\n| ------------- | --------------------------------------------- |\n| Documentation | |\n| Maintainer | @kiwicom/platform |\n\nBased on \n\n## Installation\n\nInstall the package with [pip](https://pip.pypa.io/):\n\n```\npip install structlog-sentry\n```\n\n## Usage\n\nThis module is intended to be used with `structlog` like this:\n\n```python\nimport sentry_sdk\nimport structlog\nfrom structlog_sentry import SentryProcessor\n\n\nsentry_sdk.init() # pass dsn in argument or via SENTRY_DSN env variable\n\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name, # optional, but before SentryProcessor()\n structlog.stdlib.add_log_level, # required before SentryProcessor()\n SentryProcessor(level=logging.ERROR),\n ],\n logger_factory=...,\n wrapper_class=...,\n)\n\n\nlog = structlog.get_logger()\n```\n\nDo not forget to add the `structlog.stdlib.add_log_level` and optionally the\n`structlog.stdlib.add_logger_name` processors before `SentryProcessor`. The\n`SentryProcessor` class takes the following arguments:\n\n- `level` - events of this or higher levels will be reported to Sentry,\n default is `WARNING`\n- `active` - default is `True`, setting to `False` disables the processor\n\nNow exceptions are automatically captured by Sentry with `log.error()`:\n\n```python\ntry:\n 1/0\nexcept ZeroDivisionError:\n log.error()\n\ntry:\n resp = requests.get(f\"https://api.example.com/users/{user_id}/\")\n resp.raise_for_status()\nexcept RequestException:\n log.error(\"request error\", user_id=user_id)\n```\n\nThis won't automatically collect `sys.exc_info()` along with the message, if you want\nto enable this behavior, just pass `exc_info=True`.\n\nWhen you want to use structlog's built-in\n[`format_exc_info`](http://www.structlog.org/en/stable/api.html#structlog.processors.format_exc_info)\nprocessor, make that the `SentryProcessor` comes *before* `format_exc_info`!\nOtherwise, the `SentryProcessor` won't have an `exc_info` to work with, because\nit's removed from the event by `format_exc_info`.\n\nLogging calls with no `sys.exc_info()` are also automatically captured by Sentry:\n\n```python\nlog.info(\"info message\", scope=\"accounts\")\nlog.warning(\"warning message\", scope=\"invoices\")\nlog.error(\"error message\", scope=\"products\")\n```\n\nIf you do not want to forward logs into Sentry, just pass the `sentry_skip=True`\noptional argument to logger methods, like this:\n\n```python\nlog.error(sentry_skip=True)\n```\n\n### Sentry Tags\n\nYou can set some or all of key/value pairs of structlog `event_dict` as sentry `tags`:\n\n```python\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name,\n structlog.stdlib.add_log_level,\n SentryProcessor(level=logging.ERROR, tag_keys=[\"city\", \"timezone\"]),\n ],...\n)\n\nlog.error(\"error message\", city=\"Tehran\", timezone=\"UTC+3:30\", movie_title=\"Some title\")\n```\n\nthis will report the error and the sentry event will have **city** and **timezone** tags.\nIf you want to have all event data as tags, create the `SentryProcessor` with `tag_keys=\"__all__\"`.\n\n```python\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name,\n structlog.stdlib.add_log_level,\n SentryProcessor(level=logging.ERROR, tag_keys=\"__all__\"),\n ],...\n)\n```\n\n### Skip Extra\n\nBy default `SentryProcessor` will send `event_dict` key/value pairs as extra info to the sentry.\nSometimes you may want to skip this, specially when sending the `event_dict` as sentry tags:\n\n```python\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name,\n structlog.stdlib.add_log_level,\n SentryProcessor(level=logging.ERROR, as_extra=False, tag_keys=\"__all__\"),\n ],...\n)\n```\n\n### Ignore specific loggers\n\nIf you want to ignore specific loggers from being processed by the `SentryProcessor` just pass\na list of loggers when instantiating the processor:\n\n```python\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name,\n structlog.stdlib.add_log_level,\n SentryProcessor(level=logging.ERROR, ignore_loggers=[\"some.logger\"]),\n ],...\n)\n```\n\n### Logging as JSON\n\nIf you want to configure `structlog` to format the output as **JSON**\n(maybe for [elk-stack](https://www.elastic.co/elk-stack)) you have to use `SentryJsonProcessor` to prevent\nduplication of an event reported to sentry.\n\n```python\nfrom structlog_sentry import SentryJsonProcessor\n\nstructlog.configure(\n processors=[\n structlog.stdlib.add_logger_name, # required before SentryJsonProcessor()\n structlog.stdlib.add_log_level,\n SentryJsonProcessor(level=logging.ERROR, tag_keys=\"__all__\"),\n structlog.processors.JSONRenderer()\n ],...\n)\n```\n\nThis processor tells sentry to *ignore* the logger and captures the events manually.\n\n## Testing\n\nTo run all tests:\n\n```\ntox\n```\n\n## Contributing\n\nCreate a merge request and tag @kiwicom/platform for review.\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kiwicom/structlog-sentry", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "structlog-sentry", "package_url": "https://pypi.org/project/structlog-sentry/", "platform": "", "project_url": "https://pypi.org/project/structlog-sentry/", "project_urls": { "Homepage": "https://github.com/kiwicom/structlog-sentry", "Repository": "https://github.com/kiwicom/structlog-sentry" }, "release_url": "https://pypi.org/project/structlog-sentry/1.4.0/", "requires_dist": [ "sentry-sdk" ], "requires_python": ">=3.6,<4.0", "summary": "Sentry integration for structlog", "version": "1.4.0", "yanked": false, "yanked_reason": null }, "last_serial": 9706449, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "b93d67571a6eaf7dedfeabb1288683d3", "sha256": "afad0d2474597ac17d138f93d104992bc28f54be7a3084c3305a40f3169ebe5c" }, "downloads": -1, "filename": "structlog_sentry-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b93d67571a6eaf7dedfeabb1288683d3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4718, "upload_time": "2019-04-30T13:39:42", "upload_time_iso_8601": "2019-04-30T13:39:42.529262Z", "url": "https://files.pythonhosted.org/packages/08/7c/735dc23feaf9af306338dfb56139cae17213284ad1ae84f48dd632cbbcfb/structlog_sentry-1.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1005bee23ad6a72b1ff2729e1d1835bc", "sha256": "20667e086d2a66b9cd54c750d6945c5c7b7fe9d3eef53b2a25e9b74d02dcc0a9" }, "downloads": -1, "filename": "structlog-sentry-1.0.0.tar.gz", "has_sig": false, "md5_digest": "1005bee23ad6a72b1ff2729e1d1835bc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3533, "upload_time": "2019-04-30T13:39:53", "upload_time_iso_8601": "2019-04-30T13:39:53.463365Z", "url": "https://files.pythonhosted.org/packages/cc/ef/af944c6511a912d9cf847270c48ed8c48eca758a9d9460a1f26ab0acdff0/structlog-sentry-1.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "351535bc48057894a7f5d63e28313230", "sha256": "0e45b7f3ca1597da42e7c8f685e55be7cdd8e6411ee8a5f71881b2ade1a7e9c5" }, "downloads": -1, "filename": "structlog-sentry-1.1.0.tar.gz", "has_sig": false, "md5_digest": "351535bc48057894a7f5d63e28313230", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5420, "upload_time": "2019-07-25T06:33:38", "upload_time_iso_8601": "2019-07-25T06:33:38.999247Z", "url": "https://files.pythonhosted.org/packages/ee/9c/75d7ea408ce1456610f96fc72fb691271d54bd33197bbf09a9300c3b120d/structlog-sentry-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "d5d6a65f6a977aa9a43e6b14c5e40ad0", "sha256": "2dc807b8b9d75551fa202120a757e003806c3218f8cf218c754f80379c1bc65c" }, "downloads": -1, "filename": "structlog-sentry-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d5d6a65f6a977aa9a43e6b14c5e40ad0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5700, "upload_time": "2019-10-23T07:08:29", "upload_time_iso_8601": "2019-10-23T07:08:29.262021Z", "url": "https://files.pythonhosted.org/packages/3b/d5/55141c1fce7ff19e0f538a6fe5555cdd921b115c2b66f3622dea344646e6/structlog-sentry-1.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "9d601e2956e148014e77f539fad893ba", "sha256": "4cd6bd0f8933eefac470503e12b1b7e304fb653d0186d754d99870d9cf64db1c" }, "downloads": -1, "filename": "structlog-sentry-1.2.1.tar.gz", "has_sig": false, "md5_digest": "9d601e2956e148014e77f539fad893ba", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 5959, "upload_time": "2019-11-12T17:25:32", "upload_time_iso_8601": "2019-11-12T17:25:32.537046Z", "url": "https://files.pythonhosted.org/packages/17/f5/22d6b80999e05c993326f59fa88e5fa26eeb623e0e0fb04c53d6e6618e6a/structlog-sentry-1.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.2": [ { "comment_text": "", "digests": { "md5": "89c298bd383005918e47463f8986cb84", "sha256": "5afe21bf7bfa27284345198415ac6c88941d4aef345a523ae990c94a4f6890aa" }, "downloads": -1, "filename": "structlog_sentry-1.2.2-py3-none-any.whl", "has_sig": false, "md5_digest": "89c298bd383005918e47463f8986cb84", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 7621, "upload_time": "2020-03-06T13:22:56", "upload_time_iso_8601": "2020-03-06T13:22:56.493691Z", "url": "https://files.pythonhosted.org/packages/e6/6e/b9a2151d6762be4c6a289341827730dac0c441b83a65f7de9e88dab18641/structlog_sentry-1.2.2-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3c64c75c33e78133051bc341b057e9a7", "sha256": "a990acddbc0a089c8e04ef290c36050147ce99b8f234bb8b9d198a4a7651a6b0" }, "downloads": -1, "filename": "structlog-sentry-1.2.2.tar.gz", "has_sig": false, "md5_digest": "3c64c75c33e78133051bc341b057e9a7", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 6472, "upload_time": "2020-03-06T13:23:01", "upload_time_iso_8601": "2020-03-06T13:23:01.646783Z", "url": "https://files.pythonhosted.org/packages/5f/d2/9b429fb5ef82a8ea9d24438dcea02aca0354507ea65d45563023e0b65b7b/structlog-sentry-1.2.2.tar.gz", "yanked": false, "yanked_reason": null } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "d7a212646d2f6f7dc7bb42c0cbba0fe3", "sha256": "8d5879c4d615c5f3df13b7b082475481b148749b4717366c7d3aae4ab877d3ad" }, "downloads": -1, "filename": "structlog_sentry-1.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d7a212646d2f6f7dc7bb42c0cbba0fe3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 9598, "upload_time": "2021-03-02T06:59:16", "upload_time_iso_8601": "2021-03-02T06:59:16.861052Z", "url": "https://files.pythonhosted.org/packages/67/26/00090dab05de322f158796db203850dd7ee202e265ae6d8635c0463d0431/structlog_sentry-1.3.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "f2b39d4f87b1ccbff417feabfa1d7e01", "sha256": "8204e01667301c7b8e20193d7dc369ed89e2c9364d67b614a36cbdffab2fdbe3" }, "downloads": -1, "filename": "structlog-sentry-1.3.0.tar.gz", "has_sig": false, "md5_digest": "f2b39d4f87b1ccbff417feabfa1d7e01", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 6747, "upload_time": "2021-03-02T06:59:15", "upload_time_iso_8601": "2021-03-02T06:59:15.364710Z", "url": "https://files.pythonhosted.org/packages/eb/75/2a7ad31a001190627009b2a25727fee0daa9b1b265552c097544fbe4b761/structlog-sentry-1.3.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "d4dd086823bb2bf7df34cdf9ae017ad6", "sha256": "04627538e13bb0719a8806353279d40c1d1afb3eb2053817820754b9a08814a7" }, "downloads": -1, "filename": "structlog_sentry-1.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d4dd086823bb2bf7df34cdf9ae017ad6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 9268, "upload_time": "2021-03-08T19:49:37", "upload_time_iso_8601": "2021-03-08T19:49:37.372523Z", "url": "https://files.pythonhosted.org/packages/ca/a7/04c3289f8fdc5e51918b8aab43a41e7699a3b18c5dab371c7c34c9eba758/structlog_sentry-1.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "533ad0914e5dc3e5daa4d25a89d38ed8", "sha256": "5fc6cfab71b858d71433e68cc5af79a396e72015003931507e340b3687ebb0a8" }, "downloads": -1, "filename": "structlog-sentry-1.4.0.tar.gz", "has_sig": false, "md5_digest": "533ad0914e5dc3e5daa4d25a89d38ed8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 6573, "upload_time": "2021-03-08T19:49:35", "upload_time_iso_8601": "2021-03-08T19:49:35.646898Z", "url": "https://files.pythonhosted.org/packages/92/32/74b16a1972180453bcd90f57a4285c68ad0101127a499f5425c3492b4cd5/structlog-sentry-1.4.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d4dd086823bb2bf7df34cdf9ae017ad6", "sha256": "04627538e13bb0719a8806353279d40c1d1afb3eb2053817820754b9a08814a7" }, "downloads": -1, "filename": "structlog_sentry-1.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d4dd086823bb2bf7df34cdf9ae017ad6", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 9268, "upload_time": "2021-03-08T19:49:37", "upload_time_iso_8601": "2021-03-08T19:49:37.372523Z", "url": "https://files.pythonhosted.org/packages/ca/a7/04c3289f8fdc5e51918b8aab43a41e7699a3b18c5dab371c7c34c9eba758/structlog_sentry-1.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "533ad0914e5dc3e5daa4d25a89d38ed8", "sha256": "5fc6cfab71b858d71433e68cc5af79a396e72015003931507e340b3687ebb0a8" }, "downloads": -1, "filename": "structlog-sentry-1.4.0.tar.gz", "has_sig": false, "md5_digest": "533ad0914e5dc3e5daa4d25a89d38ed8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 6573, "upload_time": "2021-03-08T19:49:35", "upload_time_iso_8601": "2021-03-08T19:49:35.646898Z", "url": "https://files.pythonhosted.org/packages/92/32/74b16a1972180453bcd90f57a4285c68ad0101127a499f5425c3492b4cd5/structlog-sentry-1.4.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }