tessl install tessl/pypi-aioredis@2.0.0asyncio (PEP 3156) Redis support
Agent Success
Agent success rate when using this tile
98%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.01x
Baseline
Agent success rate without this tile
97%
Build a Redis health monitoring system that tracks server metrics, manages client connections, and analyzes performance data.
@generates
Implement a health check function that gathers comprehensive server status information:
Implement a configuration inspection function that:
Implement a client tracking function that:
Implement a performance analysis function that:
import asyncio
from typing import Dict, List, Any, Optional, Tuple
async def health_check(redis_client) -> Dict[str, Any]:
"""
Gather comprehensive server health metrics.
Args:
redis_client: An aioredis Redis client instance
Returns:
Dictionary containing:
- server_info: Server information dict with memory, clients, uptime
- db_size: Number of keys in current database
- server_time: Tuple of (seconds, microseconds)
"""
pass
async def inspect_configuration(redis_client) -> Dict[str, Dict[str, str]]:
"""
Retrieve and organize Redis configuration parameters.
Args:
redis_client: An aioredis Redis client instance
Returns:
Dictionary containing:
- memory_config: Memory-related configuration parameters
- timeout_config: Timeout-related configuration parameters
"""
pass
async def track_clients(redis_client, client_type: Optional[str] = None) -> Dict[str, Any]:
"""
Track and analyze connected Redis clients.
Args:
redis_client: An aioredis Redis client instance
client_type: Optional filter by type ('normal', 'master', 'replica', 'pubsub')
Returns:
Dictionary containing:
- client_list: List of client information dictionaries
- total_clients: Total count of connected clients
"""
pass
async def analyze_performance(redis_client, slowlog_count: int = 10) -> Dict[str, Any]:
"""
Analyze Redis performance metrics and slowlog data.
Args:
redis_client: An aioredis Redis client instance
slowlog_count: Number of slowlog entries to retrieve (default: 10)
Returns:
Dictionary containing:
- slowlog_entries: List of slowlog entry dictionaries
- slowlog_length: Total count of slowlog entries
- stats: Statistics dict with commands_processed, ops_per_sec,
keyspace_hits, keyspace_misses
"""
passProvides async Redis client support for Python.