From 2c52241899de759124f5dcd8f90faf91b12bc085 Mon Sep 17 00:00:00 2001 From: Shoaib Amjad Date: Wed, 18 Oct 2023 23:32:39 +0500 Subject: [PATCH 1/4] Create module django monitoring (sentry) --- .../django_monitoring/monitoring/README.md | 60 ++++++++++++++++++ .../django_monitoring/monitoring/__init__.py | 0 .../django_monitoring/monitoring/apps.py | 6 ++ .../monitoring/sentry_configurations.py | 22 +++++++ .../django_monitoring/pyproject.toml | 3 + .../django_monitoring/setup.py | 18 ++++++ modules/django-monitoring/meta.json | 5 ++ modules/django-monitoring/preview.png | Bin 0 -> 15253 bytes 8 files changed, 114 insertions(+) create mode 100644 modules/django-monitoring/django_monitoring/monitoring/README.md create mode 100644 modules/django-monitoring/django_monitoring/monitoring/__init__.py create mode 100644 modules/django-monitoring/django_monitoring/monitoring/apps.py create mode 100644 modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py create mode 100644 modules/django-monitoring/django_monitoring/pyproject.toml create mode 100644 modules/django-monitoring/django_monitoring/setup.py create mode 100644 modules/django-monitoring/meta.json create mode 100644 modules/django-monitoring/preview.png diff --git a/modules/django-monitoring/django_monitoring/monitoring/README.md b/modules/django-monitoring/django_monitoring/monitoring/README.md new file mode 100644 index 000000000..5fbe8441a --- /dev/null +++ b/modules/django-monitoring/django_monitoring/monitoring/README.md @@ -0,0 +1,60 @@ +## Django Monitoring backend configuration and information + +## Module description + +This backend module enables automatic reporting of errors and exceptions as well as performance monitoring. The users can track and identify any errors or performance issues that occur while your application is in production. + +The following are the scope features of this module: + +- Ability to captures: + - Errors + - Uncaught Exceptions + - Unhandled Rejections + - As well as other types of errors, depending on platform. +- Ability to watch errors logs in Sentry/Issues dashboard. + +## Features + +- [ ] This module includes migrations. +- [x] This module includes environment variables. +- [x] This module requires manual configurations. +- [ ] This module can be configured with module options. + +## Environment variables + +```dotenv +SENTRY_DSN_URL="Your Sentry Project DSN Url" +``` +```settings.py +from modules.django_monitoring.monitoring.sentry_configurations import * +``` + +## 3rd party setup + +For implementation of this module the 3rd party setup is required: + +- Create a [developer account](https://sentry.io/signup/) on Sentry +- By adding your relevant information and clicking on Create Your Account button, your account will be created. +- Choose your project framework and set up Sentry configuration to generate the DSN URL. This URL will be used in your project to receive reports of errors and exceptions, allowing you to effectively manage issues as they occur. +- Go to your project settings, then click on "Client Keys (DSN)" and copy your "SENTRY_DSN_URL" and add in your project. + +![sentry_client.png](..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2FDownloads%2Fsentry_client.png) + + +## Dependencies + +[Sentry](https://github.com/getsentry/sentry-python/blob/master/README.md) + +Dependencies used: + +- [sentry-sdk](https://pypi.org/project/sentry-sdk/) + +## API details + +No APIs detail for this module. + +## Module Specifications + +Here is +the [Module Specification Document](https://docs.google.com/document/d/1BpX1jfGgt3FI0REn6vYOlyg0PUSy-YCnA3mhaoD2BQU/edit?usp=sharing), +which provides more information about the module's actual intentions. diff --git a/modules/django-monitoring/django_monitoring/monitoring/__init__.py b/modules/django-monitoring/django_monitoring/monitoring/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/modules/django-monitoring/django_monitoring/monitoring/apps.py b/modules/django-monitoring/django_monitoring/monitoring/apps.py new file mode 100644 index 000000000..9eb19d38a --- /dev/null +++ b/modules/django-monitoring/django_monitoring/monitoring/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SentryConfig(AppConfig): + name = "modules.django_monitoring.monitoring" + verbose_name = "Monitoring" diff --git a/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py b/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py new file mode 100644 index 000000000..34a00154e --- /dev/null +++ b/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py @@ -0,0 +1,22 @@ +import logging +import os + +import sentry_sdk +from sentry_sdk.integrations.django import DjangoIntegration +from sentry_sdk.integrations.logging import LoggingIntegration + +sentry_sdk.init( + dsn=os.getenv("SENTRY_DSN_URL"), + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + traces_sample_rate=1.0, + send_default_pii=True, + debug=True, + integrations=[ + DjangoIntegration(), + LoggingIntegration( + level=logging.INFO, # Capture info and above as breadcrumbs + event_level=logging.WARNING # Send warnings as events + ) + ], +) diff --git a/modules/django-monitoring/django_monitoring/pyproject.toml b/modules/django-monitoring/django_monitoring/pyproject.toml new file mode 100644 index 000000000..fed528d4a --- /dev/null +++ b/modules/django-monitoring/django_monitoring/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/modules/django-monitoring/django_monitoring/setup.py b/modules/django-monitoring/django_monitoring/setup.py new file mode 100644 index 000000000..0254636c8 --- /dev/null +++ b/modules/django-monitoring/django_monitoring/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup +from setuptools.command.build import build + + +# Override build command +class BuildCommand(build): + def initialize_options(self): + build.initialize_options(self) + self.build_base = "/tmp" + + +setup( + name="cb_django_monitoring", + version="0.1", + packages=["monitoring"], + install_requires=["sentry-sdk[django]"], + cmdclass={"build": BuildCommand}, +) diff --git a/modules/django-monitoring/meta.json b/modules/django-monitoring/meta.json new file mode 100644 index 000000000..fa29e91d0 --- /dev/null +++ b/modules/django-monitoring/meta.json @@ -0,0 +1,5 @@ +{ + "title": "Monitoring (Django)", + "description": "Backend for the Django Monitoring (Sentry) module.", + "root": "/backend/modules" +} diff --git a/modules/django-monitoring/preview.png b/modules/django-monitoring/preview.png new file mode 100644 index 0000000000000000000000000000000000000000..7a813441b9506ea4f35c9cf781e7398deb29be96 GIT binary patch literal 15253 zcmeHNhg(wZ|JMAPrKy#gxhpMGQ_GRLurf6>_e@1BbLSSfSo!8E_sm7PC+-EVQZpxR z+~h<>Btb+`;m7;?JKl3$aIW)k&ckzk)_s4@bH^GP=&-Z$vobI+utJ< z{an2K@l0I+28J69y3d}N1?A$F0>cDIXZ`zR*I;}vpV)`{FJ4`A{M2zVR4Hwa$|^1J zb6M&O_qo?x0alL9yBX{fMOAVy-c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qrly)_# zav}WA;D#K*a()xfG`$5>(0hW!mHtVXj)7Rr?dDm#ceQ7h` zv&;6Wik9eEL@isb+%^H&9p4uBj{~b*Rw3FOXeb?jr7ye3`jw$(ApJ#_m4Y6M!zLM{ zOV7ZHcDNbUJ`;Mvu>RPZ#^ug8JdROAnfhs3kv{WJ)s{UOFG*Lj8#+E~TT0&wHW@j! z?wh4A{Zr#%kAjl+Rnx#5foe(sntf}VSE=s~^5c)k7BxaMAH=0!8I=-tt{yYJi)9R# zz|lUC^s?*QgspxNi!y%2?C>g8K#U`;DRXHCXZok}uiMyTF(KA+U1yF$4C{9DG@?Mp z)!KJ)3OeRpWluWw8~k3Z zj84B;H4Fz9P>M(9tP&Z;`4jq_`>eR35lKNC+TRkj&xgQD`I~#+=k6TR4$o_gmT-TD zyH$7@pZz?qC@s`#s!R&}4p7-%20pBfL@Or=EafNm0|TB)XWAwDIlz9#U(vEDc;Vw= zv~C3xKlPBh2Bt%i1zq;)N1g8;EYaZ_oR;ylDrdR|9h9iDk{{oxp^N@(QMlB(7jzU- zq+2J+L!H&C=yr+K6tLXs*1y6cSr3yU<%0IhnKQLFFb)2VS3bk7ml3g!n+G?T5r8iyUPg&XBni@+sS6@NW9PF8HoHkH852W#j24x5@ z?q_tTYZ15q6fg$X=_zf}<)~WhdfD?pra_FT-8It2zxV%BNdJozVU}T{+P^j1=pD@} zi(X^hzLa_TL>8o+O>nfA@b3@1IB^?_Of)e*dpr?+#t# z_g?pZml*7?(xENu*?&X-S>nH#_%9XyD+>SB!v9d=KYaX;7W_w${^N!3b!nU}BYLN| TLCvoi=!dSB!86!X`;Y$zWg`Se literal 0 HcmV?d00001 From d46f4cf48c556c07807b735df5987f7bb01c4f77 Mon Sep 17 00:00:00 2001 From: cbshoaib <120275623+cbshoaib@users.noreply.github.com> Date: Wed, 18 Oct 2023 23:38:49 +0500 Subject: [PATCH 2/4] Update README.md --- .../django_monitoring/monitoring/README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/django-monitoring/django_monitoring/monitoring/README.md b/modules/django-monitoring/django_monitoring/monitoring/README.md index 5fbe8441a..8cd82d25d 100644 --- a/modules/django-monitoring/django_monitoring/monitoring/README.md +++ b/modules/django-monitoring/django_monitoring/monitoring/README.md @@ -6,12 +6,12 @@ This backend module enables automatic reporting of errors and exceptions as well The following are the scope features of this module: -- Ability to captures: +- Ability to capture: - Errors - Uncaught Exceptions - Unhandled Rejections - - As well as other types of errors, depending on platform. -- Ability to watch errors logs in Sentry/Issues dashboard. + - As well as other types of errors, depending on the platform. +- Ability to watch error logs in Sentry/Issues dashboard. ## Features @@ -31,15 +31,14 @@ from modules.django_monitoring.monitoring.sentry_configurations import * ## 3rd party setup -For implementation of this module the 3rd party setup is required: +For implementation of this module, the 3rd party setup is required: - Create a [developer account](https://sentry.io/signup/) on Sentry -- By adding your relevant information and clicking on Create Your Account button, your account will be created. +- By adding your relevant information and clicking on the Create Your Account button, your account will be created. - Choose your project framework and set up Sentry configuration to generate the DSN URL. This URL will be used in your project to receive reports of errors and exceptions, allowing you to effectively manage issues as they occur. - Go to your project settings, then click on "Client Keys (DSN)" and copy your "SENTRY_DSN_URL" and add in your project. -![sentry_client.png](..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2FDownloads%2Fsentry_client.png) - +![sentry_client](https://github.com/cbshoaib/modules/assets/120275623/cecc310e-6134-450e-8d68-326de3146320) ## Dependencies @@ -51,7 +50,7 @@ Dependencies used: ## API details -No APIs detail for this module. +No API details for this module. ## Module Specifications From da49f980031a409979fef9ad1c004844724c457b Mon Sep 17 00:00:00 2001 From: Shoaib Amjad Date: Thu, 19 Oct 2023 00:58:35 +0500 Subject: [PATCH 3/4] Updated readme and doc string --- .../django_monitoring/monitoring/README.md | 13 +++++++------ .../monitoring/sentry_configurations.py | 12 +++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/django-monitoring/django_monitoring/monitoring/README.md b/modules/django-monitoring/django_monitoring/monitoring/README.md index 8cd82d25d..c96d493aa 100644 --- a/modules/django-monitoring/django_monitoring/monitoring/README.md +++ b/modules/django-monitoring/django_monitoring/monitoring/README.md @@ -6,12 +6,10 @@ This backend module enables automatic reporting of errors and exceptions as well The following are the scope features of this module: -- Ability to capture: - - Errors - - Uncaught Exceptions - - Unhandled Rejections - - As well as other types of errors, depending on the platform. -- Ability to watch error logs in Sentry/Issues dashboard. +- Ability to captures errors, uncaught exceptions, and unhandled rejections. +- Ability to monitors various error types based on the platform. +- Ability to provides real-time error log tracking on Sentry/Issues dashboard. + ## Features @@ -24,6 +22,9 @@ The following are the scope features of this module: ```dotenv SENTRY_DSN_URL="Your Sentry Project DSN Url" +TRACES_SAMPLE_RATE=1.0 +SEND_DEFAULT_PII="True or False" +SENTRY_DEBUG="True or False" ``` ```settings.py from modules.django_monitoring.monitoring.sentry_configurations import * diff --git a/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py b/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py index 34a00154e..ec7da62a8 100644 --- a/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py +++ b/modules/django-monitoring/django_monitoring/monitoring/sentry_configurations.py @@ -9,9 +9,15 @@ dsn=os.getenv("SENTRY_DSN_URL"), # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. - traces_sample_rate=1.0, - send_default_pii=True, - debug=True, + # Recommend adjusting this value in production. + traces_sample_rate=os.getenv("TRACES_SAMPLE_RATE"), + # If you use django.contrib.auth and you've set "send_default_pii=True" so, + # user data (such as current user id, email address, username) will be attached to error events. + send_default_pii=os.getenv("SEND_DEFAULT_PII", False), + # if debug is (True) enabled SDK will attempt to print out useful debugging information, + # if something goes wrong while sending the event. + # Not recommended to turn it on in production. + debug=os.getenv("SENTRY_DEBUG", False), integrations=[ DjangoIntegration(), LoggingIntegration( From 0a96618a4be01cb40f8eeb54f18945c40407b05c Mon Sep 17 00:00:00 2001 From: Shoaib Amjad Date: Wed, 25 Oct 2023 17:04:26 +0500 Subject: [PATCH 4/4] Updated setup.py for adding sentory import in settings.py --- .../django_monitoring/setup.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/django-monitoring/django_monitoring/setup.py b/modules/django-monitoring/django_monitoring/setup.py index 0254636c8..d918b2d83 100644 --- a/modules/django-monitoring/django_monitoring/setup.py +++ b/modules/django-monitoring/django_monitoring/setup.py @@ -1,6 +1,29 @@ +import os +from pathlib import Path + from setuptools import setup from setuptools.command.build import build +try: + base_dir = Path.cwd() + settings_file_path = None + for root, dirs, files in os.walk(base_dir.parent.parent): + if 'settings.py' in files: + settings_file_path = f"{root}/settings.py" + + import_statement = "from modules.django_monitoring.monitoring.sentry_configurations import *\n" + + if settings_file_path: + with open(settings_file_path, 'r') as file: + lines = file.readlines() + index_to_insert = lines.index("from modules.manifest import get_modules\n") + if import_statement not in lines: + lines.insert(index_to_insert, import_statement) + with open(settings_file_path, 'w') as file: + file.write(''.join(lines)) +except (Exception,): + pass + # Override build command class BuildCommand(build):