feat(observability): add bounded OTLP signals, causal jobs and SLO rules
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import os
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def secret(name: str) -> str:
|
||||
file = os.environ.get(name + "_FILE")
|
||||
if file:
|
||||
return Path(file).read_text().strip()
|
||||
value = os.environ.get(name)
|
||||
if not value:
|
||||
raise ValueError("Missing required secret setting: " + name)
|
||||
return value
|
||||
|
||||
|
||||
def integer(name: str, default: int, low: int, high: int) -> int:
|
||||
value = int(os.environ.get(name, str(default)))
|
||||
if not low <= value <= high:
|
||||
raise ValueError("Invalid setting: " + name)
|
||||
return value
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Settings:
|
||||
database_url: str = field(repr=False)
|
||||
cache_url: str = field(repr=False)
|
||||
session_ttl: int = 3600
|
||||
pool_size: int = 10
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
return cls(
|
||||
secret("DATABASE_URL"),
|
||||
secret("CACHE_URL"),
|
||||
integer("SESSION_TTL_SECONDS", 3600, 1, 86400),
|
||||
integer("DB_POOL_SIZE", 10, 1, 32),
|
||||
)
|
||||
Reference in New Issue
Block a user