diff --git a/app/__init__.py b/app/__init__.py index a68ab05..45e9279 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -11,6 +11,8 @@ from app.api.metrics.views import metrics_bp from app.api.utils import start_scheduled_jobs from app.logging import logger +import sentry_sdk +from sentry_sdk.integrations.flask import FlaskIntegration load_dotenv() @@ -50,10 +52,25 @@ def configure_pyroscope(): logger.info('Pyroscope Configured') +def traces_sampler(sampling_context): + # Customize your sampling logic here if needed + # return a number between 0 and 1 or a boolean + return 1.0 + + +def configure_sentry(): + sentry_sdk.init( + dsn=os.getenv("SENTRY_DSN_REPORTS"), + integrations=[FlaskIntegration()], + traces_sample_rate=1.0, + traces_sampler=traces_sampler # Optional if you want dynamic sampling + ) def startup(): configure_pyroscope() + configure_sentry() + logger.info('Sentry Configured') logger.info('Starting Scheduled Jobs') start_scheduled_jobs() logger.info('Scheduled Jobs Started') diff --git a/app/api/metrics/a11yscore/calculate.py b/app/api/metrics/a11yscore/calculate.py index 0efb0e6..e3a9e3e 100644 --- a/app/api/metrics/a11yscore/calculate.py +++ b/app/api/metrics/a11yscore/calculate.py @@ -42,3 +42,4 @@ def impact_a11yscores(impact,score_data): return score return None + diff --git a/requirements.txt b/requirements.txt index f37e078..d4d9393 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,6 +36,7 @@ pytz==2023.3 PyYAML==6.0 requests==2.31.0 rich==13.4.2 +sentry-sdk==1.29.2 six==1.16.0 sniffio==1.3.0 SQLAlchemy==2.0.17