Skip to content

Commit e2cbb26

Browse files
committed
Hook up log level to LOG_LEVEL, bump down sentry's profile rates to match Appointment, and setup release strings for sentry.
1 parent 0ca8bc2 commit e2cbb26

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
SECRET_KEY=insecure-secret-key
55
LOGIN_CODE_SECRET=insecure-login-secret-key
66

7+
LOG_LEVEL=DEBUG
78
APP_ENV=dev
89
APP_DEBUG=True
910
PUBLIC_BASE_URL=http://localhost:8087

.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SECRET_KEY=insecure-secret-key
22
LOGIN_CODE_SECRET=insecure-login-secret-key
33

4+
LOG_LEVEL=DEBUG
45
APP_ENV=test
56
PUBLIC_BASE_URL=http://localhost:8087
67

pulumi/config.prod.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
3+
### Special variables used throughout this file
4+
.log_level: &VAR_LOG_LEVEL {name: "LOG_LEVEL", "value": "INFO"}
5+
26
resources:
37

48
domains:
@@ -462,6 +466,7 @@ resources:
462466
value: '44379263732755'
463467
- name: VERIFY_PRIVATE_LINK_SSL
464468
value: 'False'
469+
- *VAR_LOG_LEVEL
465470

466471

467472
accounts-celery:
@@ -643,6 +648,7 @@ resources:
643648
value: '44379263732755'
644649
- name: VERIFY_PRIVATE_LINK_SSL
645650
value: 'False'
651+
- *VAR_LOG_LEVEL
646652

647653
tb:autoscale:EcsServiceAutoscaler:
648654
accounts:

pulumi/config.stage.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
.imap_host: &VAR_IMAP_HOST {name: "IMAP_HOST", value: "mail.stage-thundermail.com"}
2525
.imap_port: &VAR_IMAP_PORT {name: "IMAP_PORT", value: "993"}
2626
.imap_tls: &VAR_IMAP_TLS {name: "IMAP_TLS", value: "True"}
27+
.log_level: &VAR_LOG_LEVEL {name: "LOG_LEVEL", "value": "DEBUG"}
2728
.keycloak_url_api: &VAR_KEYCLOAK_URL_API {name: "KEYCLOAK_URL_API", value: "https://auth-stage.tb.pro/admin/realms/tbpro/"}
2829
.keycloak_admin_url_token: &VAR_KEYCLOAK_ADMIN_URL_TOKEN {name: "KEYCLOAK_ADMIN_URL_TOKEN", value: "https://auth-stage.tb.pro/realms/master/protocol/openid-connect/token/"}
2930
.jmap_host: &VAR_JMAP_HOST {name: "JMAP_HOST", value: "mail.stage-thundermail.com"}
@@ -379,6 +380,7 @@ resources:
379380
- *VAR_ZENDESK_FORM_ID
380381
- *VAR_ZENDESK_FORM_BROWSER_FIELD_ID
381382
- *VAR_ZENDESK_FORM_OS_FIELD_ID
383+
- *VAR_LOG_LEVEL
382384
- name: TBA_CELERY
383385
value: "yes"
384386
- name: TBA_FLOWER
@@ -449,6 +451,7 @@ resources:
449451
- *VAR_ZENDESK_FORM_ID
450452
- *VAR_ZENDESK_FORM_BROWSER_FIELD_ID
451453
- *VAR_ZENDESK_FORM_OS_FIELD_ID
454+
- *VAR_LOG_LEVEL
452455
- name: TBA_CELERY
453456
value: "no"
454457
- name: TBA_FLOWER
@@ -846,6 +849,7 @@ resources:
846849
value: '46642417675539'
847850
- name: VERIFY_PRIVATE_LINK_SSL
848851
value: 'False'
852+
- *VAR_LOG_LEVEL
849853

850854
tb:autoscale:EcsServiceAutoscaler:
851855
accounts:

src/thunderbird_accounts/settings.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import sys
1515
from pathlib import Path
16+
from importlib.metadata import version
1617

1718
from dotenv import load_dotenv
1819
import sentry_sdk
@@ -41,6 +42,8 @@
4142

4243
IS_DOCS = APP_ENV == 'docs'
4344
IS_DEV = APP_ENV == 'dev'
45+
IS_STAGE = APP_ENV == 'stage'
46+
IS_PROD = APP_ENV == 'prod'
4447

4548
# Only allow DEBUG on dev or test envs.
4649
DEBUG: bool = os.getenv('APP_DEBUG') == 'True' and (IS_DEV or APP_ENV == 'test')
@@ -67,10 +70,11 @@ def before_send(event: Event, hint: Hint) -> Event | None:
6770
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
6871
send_default_pii=False,
6972
traces_sample_rate=1.0,
70-
profiles_sample_rate=1.0,
73+
profiles_sample_rate=0.66 if IS_PROD else 0.25, # Match Appointment's profile sample rate
7174
environment=APP_ENV,
7275
before_send=before_send,
7376
attach_stacktrace=True,
77+
release=version('thunderbird_accounts'),
7478
)
7579

7680
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@@ -314,7 +318,7 @@ def before_send(event: Event, hint: Hint) -> Event | None:
314318
},
315319
'root': {
316320
'handlers': ['console'],
317-
'level': 'DEBUG',
321+
'level': os.getenv('LOG_LEVEL', 'INFO'),
318322
},
319323
'loggers': {
320324
# Reduce spam logs

0 commit comments

Comments
 (0)