-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathconfig.py
More file actions
78 lines (52 loc) · 2.18 KB
/
config.py
File metadata and controls
78 lines (52 loc) · 2.18 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""Centralized configuration for the Traceroot backend.
All environment variables are read once at import time via Pydantic Settings.
Services import ``settings`` from this module instead of calling os.getenv().
Environment variables are loaded from .env by entrypoints (rest/main.py,
worker/celery_app.py) before this module is first imported.
"""
from pydantic_settings import BaseSettings, SettingsConfigDict
class ClickHouseSettings(BaseSettings):
"""ClickHouse connection settings.
Env vars: CLICKHOUSE_HOST, CLICKHOUSE_PORT, CLICKHOUSE_NATIVE_PORT,
CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_DATABASE
"""
model_config = SettingsConfigDict(env_prefix="CLICKHOUSE_")
host: str = "localhost"
port: int = 8123
native_port: int = 9000
user: str = "clickhouse"
password: str = "clickhouse"
database: str = "default"
class S3Settings(BaseSettings):
"""S3/MinIO settings for trace data storage.
Env vars: S3_ENDPOINT_URL, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY,
S3_BUCKET_NAME, S3_REGION
"""
model_config = SettingsConfigDict(env_prefix="S3_")
endpoint_url: str | None = None
access_key_id: str | None = None
secret_access_key: str | None = None
bucket_name: str = "traceroot"
region: str = "us-east-1"
class RedisSettings(BaseSettings):
"""Redis settings for Celery broker and result backend.
Env vars: REDIS_URL, REDIS_RESULT_URL
"""
model_config = SettingsConfigDict(env_prefix="REDIS_")
url: str = "redis://localhost:6379/0"
result_url: str = "redis://localhost:6379/1"
class Settings(BaseSettings):
"""Root settings for the Traceroot backend.
Nested settings (clickhouse, s3, redis) each read from their own
prefixed env vars. Top-level fields read from unprefixed env vars.
"""
# CORS
cors_origins: list[str] = ["http://localhost:3000"]
# Internal communication (Python <-> Next.js)
traceroot_ui_url: str = "http://localhost:3000"
internal_api_secret: str = ""
# Service-specific settings
clickhouse: ClickHouseSettings = ClickHouseSettings()
s3: S3Settings = S3Settings()
redis: RedisSettings = RedisSettings()
settings = Settings()