Skip to content

Profiling

provide.foundation.errors.profiling

TODO: Add module docstring.

Classes

ExporterError

ExporterError(
    message: str,
    *,
    exporter_name: str | None = None,
    endpoint: str | None = None,
    retry_count: int | None = None,
    **kwargs: Any
)

Bases: ProfilingError

Raised when metric export operations fail.

Parameters:

Name Type Description Default
message str

Export error message.

required
exporter_name str | None

Optional name of the exporter that failed.

None
endpoint str | None

Optional endpoint URL that failed.

None
retry_count int | None

Optional number of retries attempted.

None
**kwargs Any

Additional context passed to ProfilingError.

{}

Examples:

>>> raise ExporterError("Failed to connect to Prometheus")
>>> raise ExporterError("Export timeout", exporter_name="datadog", retry_count=3)
Source code in provide/foundation/errors/profiling.py
def __init__(
    self,
    message: str,
    *,
    exporter_name: str | None = None,
    endpoint: str | None = None,
    retry_count: int | None = None,
    **kwargs: Any,
) -> None:
    if exporter_name:
        kwargs.setdefault("context", {})["exporter.name"] = exporter_name
    if endpoint:
        kwargs.setdefault("context", {})["exporter.endpoint"] = endpoint
    if retry_count is not None:
        kwargs.setdefault("context", {})["exporter.retry_count"] = retry_count
    super().__init__(message, **kwargs)

MetricsError

MetricsError(
    message: str,
    *,
    metric_name: str | None = None,
    metric_value: Any = None,
    **kwargs: Any
)

Bases: ProfilingError

Raised when metrics collection operations fail.

Parameters:

Name Type Description Default
message str

Metrics error message.

required
metric_name str | None

Optional name of the metric that failed.

None
metric_value Any

Optional value that caused the error.

None
**kwargs Any

Additional context passed to ProfilingError.

{}

Examples:

>>> raise MetricsError("Invalid metric value")
>>> raise MetricsError("Metric overflow", metric_name="latency_ms")
Source code in provide/foundation/errors/profiling.py
def __init__(
    self,
    message: str,
    *,
    metric_name: str | None = None,
    metric_value: Any = None,
    **kwargs: Any,
) -> None:
    if metric_name:
        kwargs.setdefault("context", {})["metrics.name"] = metric_name
    if metric_value is not None:
        kwargs.setdefault("context", {})["metrics.value"] = metric_value
    super().__init__(message, **kwargs)

ProfilingError

ProfilingError(
    message: str,
    *,
    component: str | None = None,
    sample_rate: float | None = None,
    **kwargs: Any
)

Bases: FoundationError

Raised when profiling operations fail.

Parameters:

Name Type Description Default
message str

Error message describing the profiling issue.

required
component str | None

Optional profiling component that caused the error.

None
sample_rate float | None

Optional sample rate when the error occurred.

None
**kwargs Any

Additional context passed to FoundationError.

{}

Examples:

>>> raise ProfilingError("Profiling initialization failed")
>>> raise ProfilingError("Invalid sample rate", sample_rate=1.5)
Source code in provide/foundation/errors/profiling.py
def __init__(
    self,
    message: str,
    *,
    component: str | None = None,
    sample_rate: float | None = None,
    **kwargs: Any,
) -> None:
    if component:
        kwargs.setdefault("context", {})["profiling.component"] = component
    if sample_rate is not None:
        kwargs.setdefault("context", {})["profiling.sample_rate"] = sample_rate
    super().__init__(message, **kwargs)

SamplingError

SamplingError(
    message: str,
    *,
    sample_rate: float | None = None,
    samples_processed: int | None = None,
    **kwargs: Any
)

Bases: ProfilingError

Raised when sampling operations fail.

Parameters:

Name Type Description Default
message str

Sampling error message.

required
sample_rate float | None

The sample rate that caused the error.

None
samples_processed int | None

Optional number of samples processed.

None
**kwargs Any

Additional context passed to ProfilingError.

{}

Examples:

>>> raise SamplingError("Invalid sample rate", sample_rate=1.5)
>>> raise SamplingError("Sampling buffer overflow", samples_processed=1000)
Source code in provide/foundation/errors/profiling.py
def __init__(
    self,
    message: str,
    *,
    sample_rate: float | None = None,
    samples_processed: int | None = None,
    **kwargs: Any,
) -> None:
    if sample_rate is not None:
        kwargs.setdefault("context", {})["sampling.rate"] = sample_rate
    if samples_processed is not None:
        kwargs.setdefault("context", {})["sampling.processed"] = samples_processed
    super().__init__(message, **kwargs)