diff --git a/admin/application.py b/admin/application.py index 726dee19f..e6460d33a 100644 --- a/admin/application.py +++ b/admin/application.py @@ -13,6 +13,9 @@ integrations=[FlaskIntegration()] ) +with sentry_sdk.configure_scope() as scope: + scope.set_tag("cf_app", os.environ.get('CF_APP_NAME')) + PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_ROOT, 'app', 'static') STATIC_URL = 'static/' diff --git a/admin/manifest-dev.yml b/admin/manifest-dev.yml index 90141bd74..7ac9d8890 100644 --- a/admin/manifest-dev.yml +++ b/admin/manifest-dev.yml @@ -14,10 +14,11 @@ defaults: &defaults command: make run-gunicorn applications: - - name: notify + - name: notify-((stg)) <<: *defaults env: <<: *defaults_env ADMIN_BASE_URL: https://notify-((stg)).apps.y.cld.gov.au DOCS_BASE_URL: https://notify-docs-((stg)).apps.y.cld.gov.au API_HOST_NAME: https://notify-api-((stg)).apps.y.cld.gov.au + CF_APP_NAME: notify-((stg)) diff --git a/admin/manifest.yml b/admin/manifest.yml index aeba897da..c702d001d 100644 --- a/admin/manifest.yml +++ b/admin/manifest.yml @@ -21,3 +21,4 @@ applications: <<: *defaults_env ADMIN_BASE_URL: https://notify.gov.au API_HOST_NAME: https://rest-api.notify.gov.au + CF_APP_NAME: notify diff --git a/api/application.py b/api/application.py index 1ca4a6100..296f46c61 100644 --- a/api/application.py +++ b/api/application.py @@ -14,6 +14,9 @@ integrations=[FlaskIntegration()] ) +with sentry_sdk.configure_scope() as scope: + scope.set_tag("cf_app", os.environ.get('CF_APP_NAME')) + application = Flask('app') create_app(application) diff --git a/api/manifest-dev.yml b/api/manifest-dev.yml index d19d9c7c5..d9898e297 100644 --- a/api/manifest-dev.yml +++ b/api/manifest-dev.yml @@ -26,14 +26,20 @@ applications: - name: notify-api-((stg)) <<: *defaults command: make run-production + env: + CF_APP_NAME: notify-api-((stg)) - name: notify-celery-worker-((stg)) <<: *defaults health-check-type: process no-route: true command: make run-celery-worker + env: + CF_APP_NAME: notify-celery-worker-((stg)) - name: notify-celery-beat-((stg)) <<: *defaults memory: 256M health-check-type: process no-route: true command: make run-celery-beat + env: + CF_APP_NAME: notify-celery-beat-((stg)) diff --git a/api/manifest.yml b/api/manifest.yml index 88cbbe468..1034f4791 100644 --- a/api/manifest.yml +++ b/api/manifest.yml @@ -26,14 +26,20 @@ applications: routes: - route: rest-api.notify.gov.au - route: notify-api.apps.b.cld.gov.au + env: + CF_APP_NAME: notify-api - name: notify-celery-worker <<: *defaults health-check-type: process no-route: true command: make run-celery-worker + env: + CF_APP_NAME: notify-celery-worker - name: notify-celery-beat <<: *defaults memory: 256M health-check-type: process no-route: true command: make run-celery-beat + env: + CF_APP_NAME: notify-celery-beat diff --git a/api/run_celery.py b/api/run_celery.py index 523af75ef..66d89c190 100644 --- a/api/run_celery.py +++ b/api/run_celery.py @@ -16,6 +16,7 @@ with sentry_sdk.configure_scope() as scope: scope.set_tag("celery_cmd", os.environ['NOTIFY_CELERY_CMD']) + scope.set_tag("cf_app", os.environ.get('CF_APP_NAME')) application = Flask('delivery') create_app(application) diff --git a/api/tests/app/celery/test_scheduled_tasks.py b/api/tests/app/celery/test_scheduled_tasks.py index 665075191..97361c913 100644 --- a/api/tests/app/celery/test_scheduled_tasks.py +++ b/api/tests/app/celery/test_scheduled_tasks.py @@ -393,16 +393,15 @@ def __getattr__(self, name): def test_switch_providers_on_slow_delivery_should_not_throw_if_providers_updated_at_is_none( notify_api, mocker, capsys): - with capsys.disabled(): - mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_provider', return_value=[]) - mocker.patch('app.celery.scheduled_tasks.get_current_provider', - return_value=Getter(identifier="123", updated_at=None)) - - with set_config_values(notify_api, { - 'FUNCTIONAL_TEST_PROVIDER_SERVICE_ID': '7954469d-8c6d-43dc-b8f7-86be2d69f5f3', - 'FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID': '331a63e6-f1aa-4588-ad3f-96c268788ae7' - }): - switch_current_sms_provider_on_slow_delivery() + mocker.patch('app.celery.scheduled_tasks.is_delivery_slow_for_provider', return_value=[]) + mocker.patch('app.celery.scheduled_tasks.get_current_provider', + return_value=Getter(identifier="123", updated_at=None)) + + with set_config_values(notify_api, { + 'FUNCTIONAL_TEST_PROVIDER_SERVICE_ID': '7954469d-8c6d-43dc-b8f7-86be2d69f5f3', + 'FUNCTIONAL_TEST_PROVIDER_SMS_TEMPLATE_ID': '331a63e6-f1aa-4588-ad3f-96c268788ae7' + }): + switch_current_sms_provider_on_slow_delivery() @pytest.mark.skip(reason="We currently do not support sms fallback functionality")