Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions daiv/daiv/settings/components/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@

SENTRY_DSN = get_docker_secret("SENTRY_DSN")
SENTRY_DEBUG = config("SENTRY_DEBUG", cast=bool, default=False)
SENTRY_ENABLE_TRACING = config("SENTRY_ENABLE_TRACING", cast=bool, default=False)
SENTRY_ENABLE_LOGS = config("SENTRY_ENABLE_LOGS", cast=bool, default=False)
SENTRY_TRACES_SAMPLE_RATE = config("SENTRY_TRACES_SAMPLE_RATE", cast=float, default=0.0)
SENTRY_PROFILES_SAMPLE_RATE = config("SENTRY_PROFILES_SAMPLE_RATE", cast=float, default=0.0)
SENTRY_SEND_DEFAULT_PII = config("SENTRY_SEND_DEFAULT_PII", cast=bool, default=False)

if SENTRY_DSN:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.redis import RedisIntegration

sentry_sdk.init(
ignore_errors=[DisallowedHost, KeyboardInterrupt],
dsn=SENTRY_DSN,
release=__version__,
environment=ENVIRONMENT,
debug=SENTRY_DEBUG,
enable_tracing=SENTRY_ENABLE_TRACING,
profiles_sample_rate=1.0 if SENTRY_ENABLE_TRACING else 0.0,
enable_logs=SENTRY_ENABLE_LOGS,
traces_sample_rate=SENTRY_TRACES_SAMPLE_RATE,
profiles_sample_rate=SENTRY_PROFILES_SAMPLE_RATE,
send_default_pii=SENTRY_SEND_DEFAULT_PII,
server_name=config("NODE_HOSTNAME", default=None),
integrations=[DjangoIntegration(), LoggingIntegration(), RedisIntegration()],
)

if SERVICE_NAME := config("SERVICE_NAME", default=None):
Expand Down
5 changes: 4 additions & 1 deletion docs/configuration/env-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ Variables marked with:
|-------------------------|------------------------------------|:--------------:|-----------------|
| `SENTRY_DSN` :material-lock: | Sentry DSN | *(none)* | |
| `SENTRY_DEBUG` | Enable Sentry debug mode | `False` | `True` |
| `SENTRY_ENABLE_TRACING` | Enable Sentry tracing | `False` | `True` |
| `SENTRY_ENABLE_LOGS` | Enable Sentry logs | `False` | `True` |
| `SENTRY_TRACES_SAMPLE_RATE` | Sentry traces sample rate | `0.0` | `1.0` |
| `SENTRY_PROFILES_SAMPLE_RATE` | Sentry profiles sample rate | `0.0` | `1.0` |
| `SENTRY_SEND_DEFAULT_PII` | Enable Sentry default PII | `False` | `True` |
| `NODE_HOSTNAME` | Node hostname for Sentry | *(none)* | |
| `SERVICE_NAME` | Service name for Sentry | *(none)* | |

Expand Down