Python Integration

Installation

Install the RocketGraph SDK using pip:

pip install rocketgraph-sdk

Quick Start

Add the following code to your Python application:

from rocketgraph import RocketGraph

rocket = RocketGraph(
    api_key="your-api-key",
    project_id="your-project-id"
)

# Start monitoring
rocket.start()

Framework Integration

Django

# settings.py
MIDDLEWARE = [
    'rocketgraph.django.RocketGraphMiddleware',
    # ... other middleware
]

ROCKETGRAPH = {
    'api_key': 'your-api-key',
    'project_id': 'your-project-id'
}

Flask

from flask import Flask
from rocketgraph.flask import RocketGraph

app = Flask(__name__)
rocket = RocketGraph(app, api_key="your-api-key", project_id="your-project-id")

Features

  • Exception tracking
  • Performance monitoring
  • Custom event tracking
  • Request/Response monitoring
  • Database query tracking

Examples

Custom Event Tracking

rocket.track('user_action', {
    'action': 'login',
    'user_id': '123',
    'timestamp': datetime.now()
})

Error Tracking

try:
    # Your code here
except Exception as e:
    rocket.capture_exception(e)
    raise

Performance Monitoring

@rocket.trace('database_query')
def execute_query():
    # Your database query here
    pass