praval.observability.config
Observability Configuration.
Simple global configuration loaded from environment variables.
Functions
Get global observability configuration. |
|
Reset global configuration (mainly for testing). |
Classes
|
Global observability configuration. |
- class praval.observability.config.ObservabilityConfig(enabled=True, sample_rate=1.0, otlp_endpoint=None, storage_path='~/.praval/traces.db')[source]
Bases:
objectGlobal observability configuration.
Configuration is loaded from environment variables: - PRAVAL_OBSERVABILITY: “auto” | “on” | “off” (default: “auto”) - PRAVAL_OTLP_ENDPOINT: OTLP endpoint URL (default: None) - PRAVAL_SAMPLE_RATE: 0.0-1.0 (default: 1.0) - PRAVAL_TRACES_PATH: SQLite database path (default: ~/.praval/traces.db)
- Parameters:
enabled (bool)
sample_rate (float)
otlp_endpoint (str | None)
storage_path (str)
- enabled: bool = True
- sample_rate: float = 1.0
- otlp_endpoint: str | None = None
- storage_path: str = '~/.praval/traces.db'
- classmethod from_env()[source]
Load configuration from environment variables.
- Return type:
- Returns:
ObservabilityConfig instance
- is_enabled()[source]
Check if observability is enabled.
- Return type:
bool- Returns:
True if observability is enabled
- should_sample()[source]
Check if current request should be sampled.
Uses simple random sampling based on sample_rate.
- Return type:
bool- Returns:
True if should sample this request
- __init__(enabled=True, sample_rate=1.0, otlp_endpoint=None, storage_path='~/.praval/traces.db')
- Parameters:
enabled (bool)
sample_rate (float)
otlp_endpoint (str | None)
storage_path (str)
- Return type:
None