diff --git a/isic/settings/_utils.py b/isic/settings/_utils.py index 8d73605d..d0f511e4 100644 --- a/isic/settings/_utils.py +++ b/isic/settings/_utils.py @@ -18,12 +18,7 @@ def string_to_bool(value: str) -> bool: def _get_sentry_performance_sample_rate(*args, **kwargs) -> float: - """ - Determine sample rate of sentry performance. - - Only sample 1% of common requests for performance monitoring, and all staff/admin requests - since they're relatively low volume but high value. Also sample all infrequent tasks. - """ + """Determine sample rate of sentry performance.""" from isic.core.tasks import populate_collection_from_search_task from isic.ingest.tasks import ( extract_zip_task, @@ -49,6 +44,20 @@ def _get_sentry_performance_sample_rate(*args, **kwargs) -> float: path: str = args[0]["wsgi_environ"]["PATH_INFO"] if path.startswith(("/staff", "/admin")): return 1.0 + + # Sample more important endpoints at a higher rate. Note that this can't be done + # with a decorator on the views because of how django-ninja resolves everything + # to one view function. + if any( + path.startswith(prefix) + for prefix in ( + "/api/v2/images", + "/api/v2/quickfind", + "/api/v2/lesions", + "/api/v2/zip-download", + ) + ): + return 0.50 elif args and "celery_job" in args[0]: if args[0]["celery_job"]["task"] in infrequent_tasks: return 1.0