Drf Api Tracking

screenshot of Drf Api Tracking
django

Fork of aschn/drf-tracking so that we can maintain and release newer versions

Overview

The drf-api-tracking library is a robust solution for logging requests in applications built with Django Rest Framework (DRF). It provides developers with an easy-to-integrate model and view mixin that captures detailed information about each request and response cycle. From tracking user interactions to performance metrics, this tool delivers valuable insights that can enhance the overall functionality and reliability of your APIs. Whether you're looking to analyze usage patterns or troubleshoot issues, drf-api-tracking offers a comprehensive approach for monitoring API activity.

Features

  • User Tracking: Logs the authenticated user for each request. If the user is not authenticated, it records as None, helping you understand who is accessing your API.
  • Persistent Username: The username is stored in a static field, ensuring it remains accessible even if the user record is deleted, providing continuity in logs.
  • Detailed Timestamps: Captures the exact date and time the request was made, allowing for precise tracking of API usage over time.
  • Performance Metrics: Records the number of milliseconds spent processing each request, which aids in identifying performance bottlenecks.
  • Request Metadata: Logs the target URI, view, method, and originating IP address, offering a complete picture of each API interaction.
  • Customizable Logging: Developers can define rules for logging through the should_log method, allowing for selective logging based on specific conditions.
  • Flexible Data Handling: Offers options to customize how logs are handled, whether by saving to the database, using in-memory data structures, or integrating with external logging systems.
django
Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It follows the model-view-controller (MVC) architectural pattern, providing an extensive set of built-in tools and conventions to streamline the creation of robust and scalable web applications.