or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

breadcrumb-system.mdcontext-management.mdcore-client.mddata-processing.mdframework-integrations.mdindex.mdlogging-integration.mdtransport-layer.md
tile.json

tessl/pypi-raven

Legacy Python client for Sentry error monitoring service with framework integration and exception tracking capabilities.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/raven@6.10.x

To install, run

npx @tessl/cli install tessl/pypi-raven@6.10.0

index.mddocs/

Raven

Raven is the official legacy Python client for Sentry, providing comprehensive error tracking and exception monitoring for Python applications. It automatically captures and reports unhandled exceptions, supports extensive framework integrations, and provides detailed diagnostic information for debugging and monitoring production applications.

Package Information

  • Package Name: raven
  • Language: Python
  • Installation: pip install raven
  • Python Versions: 2.6–2.7 & 3.3–3.7, PyPy, Google App Engine

Core Imports

from raven import Client

Common imports for specific integrations:

from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler
from raven.contrib.django.client import DjangoClient
from raven.contrib.flask import Sentry

Basic Usage

from raven import Client

# Initialize client with your Sentry DSN
client = Client('https://public_key:secret_key@sentry.io/project_id')

# Capture an exception
try:
    1/0
except ZeroDivisionError:
    client.captureException()

# Capture a message
client.captureMessage('Something went wrong!')

# Add context information
client.user_context({'id': 123, 'email': 'user@example.com'})
client.tags_context({'version': '1.0', 'environment': 'production'})
client.extra_context({'request_id': 'abc123'})

# Capture with context
try:
    process_payment()
except Exception:
    client.captureException()

Architecture

Raven uses a modular architecture with several key components:

  • Client: Core class managing event capture, processing, and transmission
  • Transport Layer: Handles HTTP communication with Sentry servers (sync/async)
  • Event Processing: Captures different event types (exceptions, messages, queries)
  • Data Processing: Sanitizes and transforms data before transmission
  • Context Management: Thread-local storage for user data, tags, and breadcrumbs
  • Framework Integrations: Drop-in support for Django, Flask, and other frameworks

Capabilities

Core Client

The main Client class provides the primary interface for capturing and sending events to Sentry, with comprehensive configuration options and context management.

class Client:
    def __init__(self, dsn=None, raise_send_errors=False, transport=None,
                 install_sys_hook=True, install_logging_hook=True,
                 hook_libraries=None, enable_breadcrumbs=True, 
                 _random_seed=None, **options): ...
    def captureException(self, exc_info=None, **kwargs): ...
    def captureMessage(self, message, **kwargs): ...
    def captureQuery(self, query, params=(), engine=None, **kwargs): ...
    def captureBreadcrumb(self, **kwargs): ...

Core Client

Framework Integrations

Comprehensive integrations with popular Python web frameworks including Django, Flask, Bottle, Celery, and others, providing automatic error capture and framework-specific context.

# Django
class DjangoClient(Client): ...

# Flask
class Sentry:
    def __init__(self, app=None, **kwargs): ...
    def init_app(self, app, **kwargs): ...

Framework Integrations

Logging Integration

Native Python logging integration with configurable handlers that automatically capture log records as Sentry events, supporting filtering and custom formatting.

class SentryHandler(logging.Handler):
    def __init__(self, client=None, **kwargs): ...
    def emit(self, record): ...

def setup_logging(handler, exclude=None): ...

Logging Integration

Transport Layer

Multiple transport implementations for different environments and performance requirements, including synchronous, threaded, and async framework-specific transports.

class HTTPTransport: ...
class ThreadedHTTPTransport: ...
class RequestsHTTPTransport: ...
class ThreadedRequestsHTTPTransport: ...
class GeventedHTTPTransport: ...
class TwistedHTTPTransport: ...
class TornadoHTTPTransport: ...
class EventletHTTPTransport: ...

Transport Layer

Data Processing

Customizable data processors for sanitizing sensitive information, transforming data structures, and controlling what information is sent to Sentry.

class SanitizePasswordsProcessor: ...
class SanitizeKeysProcessor: ...
class RemovePostDataProcessor: ...
class RemoveStackLocalsProcessor: ...

Data Processing

Context Management

Thread-local context management for maintaining user information, tags, extra data, and breadcrumbs throughout the application lifecycle.

class Context:
    def activate(self, sticky=False): ...
    def merge(self, data, activate=True): ...
    def clear(self, deactivate=None): ...

Context Management

Breadcrumb System

Automatic and manual breadcrumb collection for tracking user actions and application state leading up to errors, with customizable recording and filtering.

class BreadcrumbBuffer:
    def record(self, timestamp=None, level=None, message=None, **kwargs): ...
    def clear(self): ...

def record(**kwargs): ...
def install_logging_hook(): ...

Breadcrumb System

Types

class ClientState:
    ONLINE = 1
    ERROR = 0
    
    def should_try(self): ...

class DummyClient(Client):
    """No-op client that discards all messages"""
    def send(self, **kwargs): ...