aboutsummaryrefslogtreecommitdiff
path: root/jb/config.py
blob: 954dfe8929aba4b12867214f32324a69453282b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import logging

from jb.settings import get_settings

settings = get_settings()

if settings.debug:
    LOG_LEVEL = logging.DEBUG
else:
    LOG_LEVEL = logging.WARNING

# The SNS topic that 1) JB Mturk will send notifications to, 2) will make http POSTs
#   back to us (here)
TOPIC_ARN = f"arn:aws:sns:us-east-2:{settings.aws_owner_id}:amt-jb"
SUBSCRIPTION = {
    "SubscriptionArn": settings.aws_subscription_arn,
    "Owner": settings.aws_owner_id,
    "Protocol": "https",
    "Endpoint": f"https://jamesbillings67.com/{settings.sns_path}/",
    "TopicArn": TOPIC_ARN,
}

JB_EVENTS_STREAM = "amt_jb_events"
CONSUMER_GROUP = "amt-jb-0"
# We'll only have 1 consumer atm, change this if we don't
CONSUMER_NAME = "amt-jb-0"

if settings.sentry:
    import sentry_sdk
    from sentry_sdk.integrations.fastapi import FastApiIntegration
    from sentry_sdk.integrations.logging import LoggingIntegration
    from sentry_sdk.integrations.redis import RedisIntegration

    # --- Sentry Configuration ---
    sentry_logging = LoggingIntegration(
        level=logging.INFO,  # Capture info and above as breadcrumbs
        event_level=logging.ERROR,  # Send errors as events
    )
    sentry_sdk.init(
        dsn=str(settings.sentry),
        integrations=[FastApiIntegration(), sentry_logging, RedisIntegration()],
        send_default_pii=True,
        sample_rate=1,
        traces_sample_rate=0.1,
    )