Skip to content

metrics

azure_bootstrap.metrics

Aggregate library metrics for /api/metrics endpoints.

Soft-imports every contributor so apps without certain extras still get a useful response — missing modules just don't add their section.

Functions:

Name Description
build_metrics_snapshot

Aggregate known metrics into a single dict.

build_metrics_snapshot

build_metrics_snapshot() -> dict[str, Any]

Aggregate known metrics into a single dict.

Source code in azure_bootstrap/metrics/__init__.py
def build_metrics_snapshot() -> dict[str, Any]:
    """Aggregate known metrics into a single dict."""
    snap: dict[str, Any] = {
        "latency": latency_snapshot(),
        "alert_counters": counter_snapshot(),
    }
    try:
        from azure_bootstrap.openai import usage_snapshot

        snap["ai_usage"] = usage_snapshot()
    except Exception:
        pass
    try:
        from azure_bootstrap.bootstrap import bootstrap_initialized

        snap["bootstrap_initialized"] = bootstrap_initialized()
    except Exception:
        pass
    try:
        from azure_bootstrap.heartbeat import _last_settle_age_seconds

        snap["last_sb_settle_age_seconds"] = _last_settle_age_seconds()
    except Exception:
        pass
    return snap