Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /CIRISAI_CIRISAgent /ciris_sdk /resources /telemetry.py
| """ | |
| Telemetry resource for CIRIS v1 API (Pre-Beta). | |
| **WARNING**: This SDK is for the v1 API which is in pre-beta stage. | |
| The API interfaces may change without notice. | |
| """ | |
| from __future__ import annotations | |
| from datetime import datetime | |
| from typing import Any, Dict, List, Optional, Union | |
| from pydantic import BaseModel, ConfigDict, Field | |
| from ..telemetry_models import ( | |
| MetricData, | |
| QueryFilter, | |
| QueryFilters, | |
| ResourceHealth, | |
| ResourceHistoryPoint, | |
| ResourceLimits, | |
| ResourceUsage, | |
| ) | |
| from ..telemetry_responses import ( | |
| IncidentsQueryResult, | |
| InsightsQueryResult, | |
| LogsQueryResult, | |
| MetricsQueryResult, | |
| TelemetryLogsResponse, | |
| TelemetryMetricsResponse, | |
| TelemetryOverviewResponse, | |
| TelemetryTracesResponse, | |
| TracesQueryResult, | |
| ) | |
| from ..transport import Transport | |
| class TelemetryOverview(BaseModel): | |
| """System telemetry overview.""" | |
| uptime_seconds: float = Field(..., description="System uptime") | |
| cognitive_state: str = Field(..., description="Current cognitive state") | |
| messages_processed_24h: int = Field(default=0, description="Messages in last 24h") | |
| healthy_services: int = Field(default=0, description="Number of healthy services") | |
| model_config = ConfigDict(extra="allow") | |
| class TelemetryMetrics(BaseModel): | |
| """Telemetry metrics response.""" | |
| metrics: List[MetricData] = Field(..., description="List of metrics") | |
| model_config = ConfigDict(extra="allow") | |
| class TelemetryMetricDetail(BaseModel): | |
| """Detailed metric information.""" | |
| metric_name: str = Field(..., description="Metric name") | |
| current: float = Field(..., description="Current value") | |
| unit: Optional[str] = Field(None, description="Unit of measurement") | |
| model_config = ConfigDict(extra="allow") | |
| class TelemetryResources(BaseModel): | |
| """Resource telemetry.""" | |
| current: ResourceUsage = Field(..., description="Current usage") | |
| limits: ResourceLimits = Field(..., description="Resource limits") | |
| health: Union[str, ResourceHealth] = Field(..., description="Health status") | |
| model_config = ConfigDict(extra="allow") | |
| class TelemetryResourcesHistory(BaseModel): | |
| """Historical resource data.""" | |
| period: Optional[str] = Field(None, description="Time period") | |
| cpu: List[ResourceHistoryPoint] = Field(..., description="CPU history") | |
| memory: List[ResourceHistoryPoint] = Field(..., description="Memory history") | |
| model_config = ConfigDict(extra="allow") | |
| def from_api_response(cls, data: Dict[str, Any]) -> "TelemetryResourcesHistory": | |
| """Convert API response to model.""" | |
| # Handle SuccessResponse wrapper | |
| if "data" in data and isinstance(data["data"], dict): | |
| data = data["data"] | |
| # Extract period from nested data if needed | |
| period = data.get("period") | |
| if isinstance(period, dict): | |
| # Period is a dict with start, end, hours | |
| if "start" in period and "end" in period: | |
| period = f"{period['start']} to {period['end']}" | |
| elif "hours" in period: | |
| period = f"Last {period['hours']} hours" | |
| else: | |
| period = "Recent" | |
| elif not period: | |
| # Create a period string from available data | |
| if "start" in data and "end" in data: | |
| period = f"{data['start']} to {data['end']}" | |
| elif "hours" in data: | |
| period = f"Last {data['hours']} hours" | |
| else: | |
| period = "Recent" | |
| # Extract CPU and memory data | |
| cpu = data.get("cpu", []) | |
| if isinstance(cpu, dict): | |
| if "data" in cpu: | |
| cpu = cpu["data"] | |
| # else: Keep the whole dict if no data field (no reassignment needed) | |
| memory = data.get("memory", []) | |
| if isinstance(memory, dict): | |
| if "data" in memory: | |
| memory = memory["data"] | |
| # else: Keep the whole dict if no data field (no reassignment needed) | |
| # If cpu/memory are not present, try history field | |
| if not cpu and not memory and "history" in data: | |
| history = data["history"] | |
| cpu = [] | |
| memory = [] | |
| for entry in history: | |
| timestamp = entry.get("timestamp") | |
| if "cpu_percent" in entry: | |
| cpu.append( | |
| ResourceHistoryPoint( | |
| timestamp=datetime.fromisoformat(timestamp) if isinstance(timestamp, str) else timestamp, | |
| value=entry["cpu_percent"], | |
| unit="percent", | |
| ) | |
| ) | |
| if "memory_mb" in entry: | |
| memory.append( | |
| ResourceHistoryPoint( | |
| timestamp=datetime.fromisoformat(timestamp) if isinstance(timestamp, str) else timestamp, | |
| value=entry["memory_mb"], | |
| unit="MB", | |
| ) | |
| ) | |
| return cls(period=period, cpu=cpu, memory=memory) | |
| class TelemetryResource: | |
| def __init__(self, transport: Transport) -> None: | |
| self._transport = transport | |
| async def get_overview(self) -> TelemetryOverviewResponse: | |
| """ | |
| Get system metrics summary. | |
| Returns comprehensive overview combining telemetry, visibility, incidents, and resource usage. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/overview") | |
| assert data is not None | |
| return TelemetryOverviewResponse(**data) | |
| async def get_metrics(self) -> TelemetryMetricsResponse: | |
| """ | |
| Get detailed metrics. | |
| Returns detailed metrics with trends and breakdowns by service. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/metrics") | |
| assert data is not None | |
| return TelemetryMetricsResponse(**data) | |
| async def get_traces( | |
| self, limit: int = 10, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None | |
| ) -> TelemetryTracesResponse: | |
| """ | |
| Get reasoning traces. | |
| Returns reasoning traces showing agent thought processes and decision-making. | |
| """ | |
| params: Dict[str, str] = {"limit": str(limit)} | |
| if start_time: | |
| params["start_time"] = start_time.isoformat() | |
| if end_time: | |
| params["end_time"] = end_time.isoformat() | |
| data = await self._transport.request("GET", "/v1/telemetry/traces", params=params) | |
| assert data is not None | |
| return TelemetryTracesResponse(**data) | |
| async def get_logs( | |
| self, | |
| start_time: Optional[datetime] = None, | |
| end_time: Optional[datetime] = None, | |
| level: Optional[str] = None, | |
| service: Optional[str] = None, | |
| limit: int = 100, | |
| ) -> TelemetryLogsResponse: | |
| """ | |
| Get system logs. | |
| Returns system logs from all services with filtering capabilities. | |
| """ | |
| params: Dict[str, str] = {"limit": str(limit)} | |
| if start_time: | |
| params["start_time"] = start_time.isoformat() | |
| if end_time: | |
| params["end_time"] = end_time.isoformat() | |
| if level: | |
| params["level"] = level | |
| if service: | |
| params["service"] = service | |
| data = await self._transport.request("GET", "/v1/telemetry/logs", params=params) | |
| assert data is not None | |
| return TelemetryLogsResponse(**data) | |
| async def query( | |
| self, | |
| query_type: str, | |
| filters: Optional[QueryFilters] = None, | |
| aggregations: Optional[List[str]] = None, | |
| start_time: Optional[datetime] = None, | |
| end_time: Optional[datetime] = None, | |
| limit: int = 100, | |
| ) -> Union[MetricsQueryResult, TracesQueryResult, LogsQueryResult, IncidentsQueryResult, InsightsQueryResult]: | |
| """ | |
| Execute custom telemetry queries. | |
| Query types: metrics, traces, logs, incidents, insights | |
| Requires ADMIN role. | |
| """ | |
| # Convert filters to dict format for API | |
| filters_dict: Dict[str, Any] = {} | |
| if filters: | |
| filters_dict = { | |
| "filters": [{"field": f.field, "operator": f.operator, "value": f.value} for f in filters.filters], | |
| "logic": filters.logic, | |
| } | |
| payload: Dict[str, Any] = {"query_type": query_type, "filters": filters_dict, "limit": limit} | |
| if aggregations: | |
| payload["aggregations"] = aggregations | |
| if start_time: | |
| payload["start_time"] = start_time.isoformat() | |
| if end_time: | |
| payload["end_time"] = end_time.isoformat() | |
| data = await self._transport.request("POST", "/v1/telemetry/query", json=payload) | |
| assert data is not None | |
| # Return appropriate response type based on query_type | |
| if query_type == "metrics": | |
| return MetricsQueryResult(**data) | |
| elif query_type == "traces": | |
| return TracesQueryResult(**data) | |
| elif query_type == "logs": | |
| return LogsQueryResult(**data) | |
| elif query_type == "incidents": | |
| return IncidentsQueryResult(**data) | |
| elif query_type == "insights": | |
| return InsightsQueryResult(**data) | |
| else: | |
| # For unknown query types, return the most generic result | |
| return MetricsQueryResult(**data) | |
| # Legacy compatibility methods (will be deprecated) | |
| async def get_observability_overview(self) -> TelemetryOverviewResponse: | |
| """ | |
| DEPRECATED: Use get_overview() instead. | |
| Get unified observability overview. | |
| """ | |
| return await self.get_overview() | |
| async def get_observability_metrics(self) -> TelemetryMetricsResponse: | |
| """ | |
| DEPRECATED: Use get_metrics() instead. | |
| Get detailed system metrics. | |
| """ | |
| return await self.get_metrics() | |
| async def get_observability_traces( | |
| self, limit: int = 10, start_time: Optional[datetime] = None, end_time: Optional[datetime] = None | |
| ) -> TelemetryTracesResponse: | |
| """ | |
| DEPRECATED: Use get_traces() instead. | |
| Get reasoning traces. | |
| """ | |
| return await self.get_traces(limit=limit, start_time=start_time, end_time=end_time) | |
| async def get_observability_logs( | |
| self, | |
| start_time: Optional[datetime] = None, | |
| end_time: Optional[datetime] = None, | |
| level: Optional[str] = None, | |
| service: Optional[str] = None, | |
| limit: int = 100, | |
| ) -> TelemetryLogsResponse: | |
| """ | |
| DEPRECATED: Use get_logs() instead. | |
| Get system logs. | |
| """ | |
| return await self.get_logs(start_time=start_time, end_time=end_time, level=level, service=service, limit=limit) | |
| async def query_observability( | |
| self, | |
| query_type: str, | |
| filters: Optional[Dict[str, Any]] = None, | |
| aggregations: Optional[List[str]] = None, | |
| start_time: Optional[datetime] = None, | |
| end_time: Optional[datetime] = None, | |
| limit: int = 100, | |
| ) -> Union[MetricsQueryResult, TracesQueryResult, LogsQueryResult, IncidentsQueryResult, InsightsQueryResult]: | |
| """ | |
| DEPRECATED: Use query() instead. | |
| Execute custom observability queries. | |
| """ | |
| # Convert dict filters to QueryFilters if provided | |
| query_filters = None | |
| if filters: | |
| filter_list = [] | |
| for field, value in filters.items(): | |
| # Simple conversion - assumes equality operator | |
| filter_list.append(QueryFilter(field=field, operator="eq", value=value)) | |
| query_filters = QueryFilters(filters=filter_list) | |
| return await self.query( | |
| query_type=query_type, | |
| filters=query_filters, | |
| aggregations=aggregations, | |
| start_time=start_time, | |
| end_time=end_time, | |
| limit=limit, | |
| ) | |
| # Aliases for backward compatibility with tests | |
| async def overview(self) -> TelemetryOverview: | |
| """Alias for get_overview().""" | |
| data = await self.get_overview() | |
| # Convert response model to simpler model | |
| return TelemetryOverview( | |
| uptime_seconds=data.uptime_seconds, | |
| cognitive_state=data.cognitive_state, | |
| messages_processed_24h=data.messages_processed_24h, | |
| healthy_services=data.healthy_services, | |
| ) | |
| async def metrics(self) -> TelemetryMetrics: | |
| """Alias for get_metrics().""" | |
| data = await self.get_metrics() | |
| # Convert detailed metrics to simple metric data list | |
| metric_list = [] | |
| for metric in data.metrics: | |
| for point in metric.recent_data: | |
| metric_list.append(point) | |
| return TelemetryMetrics(metrics=metric_list) | |
| async def metric_detail(self, metric_name: str) -> TelemetryMetricDetail: | |
| """Get detailed information about a specific metric.""" | |
| data = await self._transport.request("GET", f"/v1/telemetry/metrics/{metric_name}") | |
| assert data is not None | |
| # Handle both direct response and data wrapped response | |
| if "metric_name" not in data and "name" in data: | |
| data["metric_name"] = data["name"] | |
| if "current" not in data and "current_value" in data: | |
| data["current"] = data["current_value"] | |
| return TelemetryMetricDetail(**data) | |
| async def resources(self) -> TelemetryResources: | |
| """Get resource usage telemetry.""" | |
| data = await self._transport.request("GET", "/v1/telemetry/resources") | |
| assert data is not None | |
| # Parse the response data into proper models | |
| current = ResourceUsage(**data.get("current", {})) | |
| limits = ResourceLimits(**data.get("limits", {})) | |
| health_data = data.get("health", "unknown") | |
| if isinstance(health_data, dict): | |
| health = ResourceHealth(**health_data) | |
| else: | |
| health = health_data | |
| return TelemetryResources(current=current, limits=limits, health=health) | |
| async def resources_history(self, hours: int = 24) -> TelemetryResourcesHistory: | |
| """Get historical resource usage.""" | |
| params = {"hours": str(hours)} | |
| data = await self._transport.request("GET", "/v1/telemetry/resources/history", params=params) | |
| assert data is not None | |
| return TelemetryResourcesHistory.from_api_response(data) | |
| # Additional telemetry endpoints for comprehensive monitoring | |
| async def get_service_registry(self) -> Dict[str, Any]: | |
| """ | |
| Get service registry details including providers, circuit breakers, and capabilities. | |
| Returns detailed information about all registered services. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/service-registry") | |
| assert data is not None | |
| return data | |
| async def get_llm_usage(self) -> Dict[str, Any]: | |
| """ | |
| Get LLM usage metrics including tokens, costs, and provider statistics. | |
| Returns comprehensive LLM usage data by model and provider. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/llm/usage") | |
| assert data is not None | |
| return data | |
| async def get_circuit_breakers(self) -> Dict[str, Any]: | |
| """ | |
| Get circuit breaker status for all services. | |
| Returns state, failure counts, and recovery information. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/circuit-breakers") | |
| assert data is not None | |
| return data | |
| async def get_security_incidents(self, hours: int = 24) -> Dict[str, Any]: | |
| """ | |
| Get security incidents from the last N hours. | |
| Args: | |
| hours: Number of hours to look back (default 24) | |
| Returns security incidents and threat analysis. | |
| """ | |
| params: Dict[str, str] = {"hours": str(hours)} | |
| data = await self._transport.request("GET", "/v1/telemetry/security/incidents", params=params) | |
| assert data is not None | |
| return data | |
| async def get_handlers(self) -> Dict[str, Any]: | |
| """ | |
| Get handler metrics including invocations, durations, and errors. | |
| Returns performance metrics for all message handlers. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/handlers") | |
| assert data is not None | |
| return data | |
| async def get_errors(self, hours: int = 1) -> Dict[str, Any]: | |
| """ | |
| Get recent errors with stack traces and resolution status. | |
| Args: | |
| hours: Number of hours to look back (default 1) | |
| Returns error details and diagnostics. | |
| """ | |
| params: Dict[str, str] = {"hours": str(hours)} | |
| data = await self._transport.request("GET", "/v1/telemetry/errors", params=params) | |
| assert data is not None | |
| return data | |
| async def get_trace(self, trace_id: str) -> Dict[str, Any]: | |
| """ | |
| Get detailed trace information for a specific trace ID. | |
| Args: | |
| trace_id: The trace identifier | |
| Returns complete trace with all spans and timings. | |
| """ | |
| data = await self._transport.request("GET", f"/v1/telemetry/traces/{trace_id}") | |
| assert data is not None | |
| return data | |
| async def get_rate_limits(self) -> Dict[str, Any]: | |
| """ | |
| Get current rate limit status and quotas. | |
| Returns rate limits, current usage, and reset times. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/rate-limits") | |
| assert data is not None | |
| return data | |
| async def get_tsdb_status(self) -> Dict[str, Any]: | |
| """ | |
| Get time-series database consolidation status. | |
| Returns consolidation schedule, compression ratios, and storage metrics. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/tsdb/status") | |
| assert data is not None | |
| return data | |
| async def get_discord_status(self) -> Dict[str, Any]: | |
| """ | |
| Get Discord connection status and metrics. | |
| Returns connection health, latency, and message processing stats. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/discord/status") | |
| assert data is not None | |
| return data | |
| async def get_aggregates_hourly(self, hours: int = 24) -> Dict[str, Any]: | |
| """ | |
| Get hourly aggregated metrics for the last N hours. | |
| Args: | |
| hours: Number of hours to retrieve (default 24) | |
| Returns hourly summaries of all key metrics. | |
| """ | |
| params: Dict[str, str] = {"hours": str(hours)} | |
| data = await self._transport.request("GET", "/v1/telemetry/aggregates/hourly", params=params) | |
| assert data is not None | |
| return data | |
| async def get_summary_daily(self) -> Dict[str, Any]: | |
| """ | |
| Get daily summary of system metrics and performance. | |
| Returns comprehensive daily statistics. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/summary/daily") | |
| assert data is not None | |
| return data | |
| async def export_telemetry( | |
| self, format: str = "json", start: Optional[datetime] = None, end: Optional[datetime] = None | |
| ) -> Union[Dict[str, Any], str]: | |
| """ | |
| Export telemetry data in specified format. | |
| Args: | |
| format: Export format (json, csv, prometheus) | |
| start: Start time for export | |
| end: End time for export | |
| Returns exported data in requested format. | |
| """ | |
| params: Dict[str, str] = {"format": format} | |
| if start: | |
| params["start"] = start.isoformat() | |
| if end: | |
| params["end"] = end.isoformat() | |
| data = await self._transport.request("GET", "/v1/telemetry/export", params=params) | |
| assert data is not None | |
| return data | |
| async def get_telemetry_history(self, days: int = 7, metric: str = "llm_requests") -> Dict[str, Any]: | |
| """ | |
| Get historical telemetry data for specific metrics. | |
| Args: | |
| days: Number of days of history (default 7) | |
| metric: Metric name to retrieve | |
| Returns historical data points for the specified metric. | |
| """ | |
| params: Dict[str, str] = {"days": str(days), "metric": metric} | |
| data = await self._transport.request("GET", "/v1/telemetry/history", params=params) | |
| assert data is not None | |
| return data | |
| async def get_backups(self) -> Dict[str, Any]: | |
| """ | |
| Get telemetry backup status and history. | |
| Returns backup schedule, last backup time, and restoration points. | |
| """ | |
| data = await self._transport.request("GET", "/v1/telemetry/backups") | |
| assert data is not None | |
| return data | |
| async def get_prometheus_metrics(self) -> str: | |
| """ | |
| Get metrics in Prometheus format for monitoring integration. | |
| Returns metrics in Prometheus exposition format. | |
| """ | |
| data = await self._transport.request("GET", "/v1/metrics", raw_response=True) | |
| assert isinstance(data, str) | |
| return data | |
| # NEW: Unified telemetry endpoint for easy access to ALL metrics | |
| async def get_unified_telemetry( | |
| self, view: str = "summary", category: Optional[str] = None, format: str = "json", live: bool = False | |
| ) -> Union[Dict[str, Any], str]: | |
| """ | |
| Get ALL system metrics through the unified telemetry endpoint. | |
| This is the RECOMMENDED method for accessing telemetry data as it provides | |
| parallel collection from all 22 services with smart caching. | |
| Args: | |
| view: Type of view to return | |
| - "summary": Executive dashboard with key metrics only | |
| - "health": Quick health check | |
| - "operational": Operations-focused metrics | |
| - "performance": Performance metrics and latencies | |
| - "reliability": Uptime and error rates | |
| - "detailed": Complete data from all services | |
| category: Filter by service category (optional) | |
| - "buses": Message bus metrics | |
| - "graph": Graph service metrics | |
| - "infrastructure": Infrastructure metrics | |
| - "governance": Governance service metrics | |
| - "runtime": Runtime service metrics | |
| - "adapters": Adapter metrics | |
| - "components": Core component metrics | |
| - "all": All categories (default) | |
| format: Output format | |
| - "json": Standard JSON (default) | |
| - "prometheus": Prometheus exposition format | |
| - "graphite": Graphite format | |
| live: Force live collection (bypass 30-second cache) | |
| Returns: | |
| Telemetry data in requested format. For JSON format, returns dict with: | |
| - system_healthy: Overall health status | |
| - services_online: Number of online services | |
| - services_total: Total number of services | |
| - overall_error_rate: System-wide error rate | |
| - overall_uptime_seconds: System uptime | |
| - performance: Performance metrics (if applicable to view) | |
| - alerts: Active alerts | |
| - warnings: Active warnings | |
| - [category-specific data based on view and category] | |
| Examples: | |
| # Get executive summary | |
| summary = await client.telemetry.get_unified_telemetry() | |
| # Get detailed operational view with live data | |
| ops = await client.telemetry.get_unified_telemetry( | |
| view="operational", | |
| live=True | |
| ) | |
| # Get bus metrics only | |
| buses = await client.telemetry.get_unified_telemetry( | |
| view="detailed", | |
| category="buses" | |
| ) | |
| # Export for Prometheus | |
| prom = await client.telemetry.get_unified_telemetry( | |
| format="prometheus" | |
| ) | |
| """ | |
| params: Dict[str, str] = {"view": view, "format": format, "live": str(live).lower()} | |
| if category: | |
| params["category"] = category | |
| # For non-JSON formats, return raw response | |
| if format != "json": | |
| raw_data = await self._transport.request("GET", "/v1/telemetry/unified", params=params, raw_response=True) | |
| assert isinstance(raw_data, str) | |
| return raw_data | |
| # For JSON, return parsed dict | |
| data = await self._transport.request("GET", "/v1/telemetry/unified", params=params) | |
| assert data is not None | |
| return data | |
| async def get_all_metrics(self) -> Dict[str, Any]: | |
| """ | |
| Convenience method to get ALL metrics in detailed view. | |
| This returns complete telemetry data from all 22 services including: | |
| - All 6 message buses | |
| - All 6 graph services | |
| - All 7 infrastructure services | |
| - All 4 governance services | |
| - All 3 runtime services | |
| - All adapter metrics | |
| - All component metrics | |
| Returns: | |
| Complete telemetry data with 436+ implemented metrics | |
| Example: | |
| all_metrics = await client.telemetry.get_all_metrics() | |
| print(f"System healthy: {all_metrics['system_healthy']}") | |
| print(f"LLM requests: {all_metrics['buses']['llm_bus']['request_count']}") | |
| """ | |
| result = await self.get_unified_telemetry(view="detailed", live=True) | |
| assert isinstance(result, dict) | |
| return result | |
| async def get_metric_by_path(self, metric_path: str) -> Any: | |
| """ | |
| Get a specific metric value by its path. | |
| Args: | |
| metric_path: Dot-separated path to metric | |
| e.g., "buses.llm_bus.request_count" | |
| "infrastructure.resource_monitor.cpu_percent" | |
| "runtime.llm.tokens_used" | |
| Returns: | |
| The metric value at the specified path | |
| Example: | |
| cpu = await client.telemetry.get_metric_by_path( | |
| "infrastructure.resource_monitor.cpu_percent" | |
| ) | |
| print(f"CPU usage: {cpu}%") | |
| """ | |
| # Get all metrics | |
| data = await self.get_unified_telemetry(view="detailed") | |
| # Navigate to the metric | |
| parts = metric_path.split(".") | |
| current = data | |
| for part in parts: | |
| if isinstance(current, dict) and part in current: | |
| current = current[part] | |
| else: | |
| raise KeyError(f"Metric not found: {metric_path}") | |
| return current | |
| async def check_system_health(self) -> Dict[str, Any]: | |
| """ | |
| Quick health check of the entire system. | |
| Returns: | |
| Health status with: | |
| - healthy: Overall system health (bool) | |
| - services: Online/total services | |
| - alerts: Any active alerts | |
| - warnings: Any warnings | |
| Example: | |
| health = await client.telemetry.check_system_health() | |
| if not health['healthy']: | |
| print(f"System unhealthy! Alerts: {health['alerts']}") | |
| """ | |
| result = await self.get_unified_telemetry(view="health", live=True) | |
| assert isinstance(result, dict) | |
| return result | |
Xet Storage Details
- Size:
- 27.5 kB
- Xet hash:
- e27fbb41a1c43a5f92af8c81e8ebee1abb52eb3951ac6d1d9a0cdd9fb41409f1
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.