Skip to main content

A soft landing for your Django crashes - Error tracking SDK for Django applications

Project description

🛟 Crashpad - A Soft Landing for Your Django Crashes

Error tracking SDK for Django and Django REST Framework applications. When your code crashes, Crashpad catches it gracefully.

✨ Features

  • 🎯 Zero Configuration: One line to set up, no middleware needed
  • 🔍 Full Context Capture: Automatically captures request info, user details, and code snapshots
  • 🚀 Django & DRF Support: Works seamlessly with both Django and Django REST Framework
  • 🧵 Thread-Safe: Uses thread-local storage for reliable request tracking
  • 📸 Code Snapshots: Shows the exact lines of code where errors occurred
  • 🔄 Reversed Stack Traces: Error message first, most recent call first - easier to read
  • 🤮 Debug Mode: Save errors locally with the hilarious logs🤮 directory

📦 Installation

pip install crashpad

🚀 Quick Start

Django Setup

In your Django settings.py:

import crashpad

# Initialize with your API key URL - that's it!
crashpad.init(key="http://your-api-server.com/YOUR_PROJECT_KEY")

Django REST Framework Setup

Same simple setup for DRF:

import crashpad

# Initialize Crashpad
crashpad.init(key="http://your-api-server.com/YOUR_PROJECT_KEY")

That's it! No middleware, no additional configuration needed. Crashpad automatically captures all errors using Django signals.

📊 What Gets Tracked

When an error occurs, Crashpad automatically captures:

  • Error details: Exception type, message, and reversed stack trace (error first!)
  • Code snapshot: The exact lines of code around where the error occurred
  • Request information:
    • HTTP method (GET, POST, PUT, DELETE, etc.)
    • Full URL path
    • Authenticated user or "anonymous"
  • File location: Filename, function name, and line number
  • Timestamp: Exact time when the error occurred

🎯 Example

Here's a complete example with Django settings:

# settings.py

import crashpad

# Initialize Crashpad - one line!
crashpad.init(key="http://127.0.0.1:9000/your-project-key")

# Your regular Django/DRF settings continue...
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'rest_framework',
    # ... your apps
]

REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 100,
}

🔧 How It Works

  1. Signal-Based Integration: Connects to Django's got_request_exception signal
  2. Automatic Request Capture: Uses a logging filter to extract request information
  3. Thread-Local Storage: Safely stores request context during error handling
  4. No Middleware Required: Works automatically without middleware configuration
  5. Universal Coverage: Captures errors from views, DRF endpoints, background tasks, and logging calls
  6. Smart Extraction: Safely extracts HTTP method, URL, and user information
  7. Flexible Deployment: Send to API in production, save locally in debug mode

🐛 Debug Mode

Want to see errors saved locally? Enable debug mode:

import crashpad

crashpad.DEBUG = True
crashpad.init(key="http://your-api-server.com/YOUR_PROJECT_KEY")

Errors will be saved to a logs🤮 directory as JSON files. Yes, the emoji is intentional! 🤮

📋 Requirements

  • Python 3.6+
  • Django 3.2+
  • Django REST Framework (optional, for DRF integration)

📄 License

MIT License - see LICENSE file for details

🤝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

🎯 Why "Crashpad"?

Because when your code takes a dive, it deserves a soft landing! 🛟


Made with ❤️ for Django developers who believe error tracking shouldn't be complicated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crashpad-0.1.0b0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crashpad-0.1.0b0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file crashpad-0.1.0b0.tar.gz.

File metadata

  • Download URL: crashpad-0.1.0b0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for crashpad-0.1.0b0.tar.gz
Algorithm Hash digest
SHA256 3cb1b0f3e2268142695735e9575edc5ada9e53535d047f039ab0ac697c764ade
MD5 f3738d27954baf3dba6d76d019c66bb6
BLAKE2b-256 29c1e10bc25571ad97ab5766567fece01adb8a13295ef76d82992d4f6414e263

See more details on using hashes here.

File details

Details for the file crashpad-0.1.0b0-py3-none-any.whl.

File metadata

  • Download URL: crashpad-0.1.0b0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.6

File hashes

Hashes for crashpad-0.1.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 96ba76f0ad978f13c1660bf2d82da1c8db408bdc746acd95dbfe8f5958c57196
MD5 bb92a54c84b9be96996cc2d1b690d22e
BLAKE2b-256 b01c21db8a4e21b0eb65cdc24d554d715000c05eae201d5e68f17c978e0bc119

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page