Skip to content

ccproxy.config.observability

ccproxy.config.observability

Observability configuration settings.

ObservabilitySettings

Bases: BaseModel

Observability configuration settings.

needs_storage_backend property

needs_storage_backend

Check if any feature requires storage backend initialization.

any_endpoint_enabled property

any_endpoint_enabled

Check if any observability endpoint is enabled.

metrics_enabled property

metrics_enabled

Backward compatibility: True if any metrics feature is enabled.

duckdb_enabled property

duckdb_enabled

Backward compatibility: True if DuckDB storage backend is selected.

enabled property

enabled

Check if observability is enabled (backward compatibility property).

check_feature_dependencies

check_feature_dependencies()

Validate feature dependencies to prevent invalid configurations.

Source code in ccproxy/config/observability.py
@model_validator(mode="after")
def check_feature_dependencies(self) -> ObservabilitySettings:
    """Validate feature dependencies to prevent invalid configurations."""
    # Dashboard requires logs endpoints (functional dependency)
    if self.dashboard_enabled and not self.logs_endpoints_enabled:
        raise ValueError(
            "Cannot enable 'dashboard_enabled' without 'logs_endpoints_enabled'. "
            "Dashboard needs logs API to function."
        )

    # Logs endpoints require storage to query from
    if self.logs_endpoints_enabled and self.log_storage_backend == "none":
        raise ValueError(
            "Cannot enable 'logs_endpoints_enabled' when 'log_storage_backend' is 'none'. "
            "Logs endpoints need storage backend to query data."
        )

    # Log collection requires storage to write to
    if self.logs_collection_enabled and self.log_storage_backend == "none":
        raise ValueError(
            "Cannot enable 'logs_collection_enabled' when 'log_storage_backend' is 'none'. "
            "Collection needs storage backend to persist data."
        )

    return self

validate_stats_printing_format classmethod

validate_stats_printing_format(v)

Validate and normalize stats printing format.

Source code in ccproxy/config/observability.py
@field_validator("stats_printing_format")
@classmethod
def validate_stats_printing_format(cls, v: str) -> str:
    """Validate and normalize stats printing format."""
    lower_v = v.lower()
    valid_formats = ["console", "rich", "log", "json"]
    if lower_v not in valid_formats:
        raise ValueError(
            f"Invalid stats printing format: {v}. Must be one of {valid_formats}"
        )
    return lower_v

validate_logging_format classmethod

validate_logging_format(v)

Validate and normalize logging format.

Source code in ccproxy/config/observability.py
@field_validator("logging_format")
@classmethod
def validate_logging_format(cls, v: str) -> str:
    """Validate and normalize logging format."""
    lower_v = v.lower()
    valid_formats = ["auto", "rich", "json", "plain"]
    if lower_v not in valid_formats:
        raise ValueError(
            f"Invalid logging format: {v}. Must be one of {valid_formats}"
        )
    return lower_v