Skip to content

Sherlock AI

A Python package for performance monitoring and logging utilities that helps you track execution times and debug your applications with ease.

Overview

Sherlock AI provides a comprehensive suite of tools for monitoring, logging, and analyzing Python applications. Whether you're building APIs, data pipelines, or any Python application, Sherlock AI helps you understand performance characteristics, track errors, and maintain code quality.

Key Features

  • ๐ŸŽฏ Performance Decorators: Easy-to-use decorators for tracking function execution times
  • ๐Ÿง  Memory Monitoring: Track Python memory usage with detailed heap and tracemalloc integration
  • ๐Ÿ“Š Resource Monitoring: Monitor CPU, memory, I/O, and network usage during function execution
  • โฑ๏ธ Context Managers: Monitor code block execution with simple context managers
  • ๐Ÿ”ง Advanced Configuration System: Complete control over logging with dataclass-based configuration
  • โšก Simplified Configuration: Auto-expanding file paths - just specify base names instead of full paths
  • ๐ŸŽ›๏ธ Configuration Presets: Pre-built setups for development, production, and testing environments
  • ๐Ÿ”„ Async/Sync Support: Works seamlessly with both synchronous and asynchronous functions
  • ๐Ÿ“ˆ Request Tracking: Built-in request ID tracking for distributed systems
  • ๐Ÿ“ Flexible Log Management: Enable/disable log files, custom directories, and rotation settings
  • ๐Ÿท๏ธ Logger Name Constants: Easy access to available logger names with autocomplete support
  • ๐Ÿ” Logger Discovery: Programmatically discover available loggers in your application
  • ๐Ÿ› Development-Friendly: Optimized for FastAPI auto-reload and development environments
  • ๐ŸŽจ Modular Architecture: Clean, focused modules for different monitoring aspects
  • ๐Ÿ—๏ธ Class-Based Architecture: Advanced SherlockAI class for instance-based logging management
  • ๐Ÿ”„ Runtime Reconfiguration: Change logging settings without application restart
  • ๐Ÿงน Resource Management: Automatic cleanup and context manager support
  • ๐Ÿ” Logging Introspection: Query current logging configuration and statistics
  • ๐Ÿ“‹ JSON Format Support: Choose between standard log format or structured JSON output for better parsing and analysis
  • ๐Ÿ” Code Analysis: Automatic detection and refactoring of hardcoded values using AST parsing and LLM suggestions
  • ๐Ÿ—„๏ธ MongoDB Integration: Automatic error insights storage with MongoDB support
  • ๐ŸŒ API Client Integration: HTTP-based data ingestion to centralized backend services
  • ๐Ÿšจ Error Analysis: AI-powered error analysis with automatic probable cause detection
  • ๐Ÿ’ก Performance Insights: AI-powered performance analysis that intelligently extracts user-defined function source code
  • ๐Ÿ”„ Auto-Instrumentation: Zero-code setup for popular frameworks like FastAPI, automatically instrumenting routes with monitoring decorators

Quick Start

Installation

pip install sherlock-ai

Basic Usage

from sherlock_ai import sherlock_ai, get_logger, log_performance
import time

# Initialize logging (call once at application startup)
sherlock_ai()

# Get a logger for your module
logger = get_logger(__name__)

@log_performance
def my_function():
    time.sleep(1)
    logger.info("Processing completed")
    return "result"

# This will log: PERFORMANCE | my_module.my_function | SUCCESS | 1.003s
result = my_function()

What's Next?

  • Installation


    Install Sherlock AI and learn about requirements

  • Quick Start


    Get up and running in minutes with basic examples

  • Features


    Explore performance, memory, and resource monitoring

  • Configuration


    Learn how to configure Sherlock AI for your needs

  • Examples


    Real-world examples and integration patterns

  • API Reference


    Complete API documentation and reference

Use Cases

  • API Performance Monitoring: Track response times for your web APIs
  • Memory Leak Detection: Monitor memory usage patterns to identify potential leaks
  • Resource Optimization: Analyze CPU, memory, and I/O usage
  • Database Query Optimization: Monitor slow database operations
  • Microservices Debugging: Trace execution times across service boundaries
  • Production Monitoring: Get insights into application performance characteristics
  • Error Analysis & Debugging: AI-powered error analysis with automatic storage
  • Code Quality Improvement: Automatically detect and refactor hardcoded values

Authors

Pranaw Mishra - pranawmishra73@gmail.com

License

This project is licensed under the MIT License - see the LICENSE file for details.