Skip to main content

A lightweight Flask middleware that captures and reports errors to Apollo, a centralized error tracking system.

Project description

Apollo Tracker

Apollo Tracker is a lightweight Flask middleware for tracking and reporting errors to Apollo, an internal error tracking system similar to Sentry.

Features

  • 🛠 Automatic Error Tracking: Captures and reports all unhandled exceptions.
  • 🚀 Flask Integration: Works seamlessly with Flask applications.
  • 📡 Send Errors to Apollo: Forwards error logs to an Apollo backend.
  • 🔍 Includes Request Metadata: Logs IP address, user agent, endpoint, and method.
  • 📦 Simple Installation: Just pip install apollo-tracker.

Installation

You can install apollo-tracker using pip:

pip install apollo-tracker

Usage

1. Setup ApolloTracker in Your Flask App

To start tracking errors in your Flask app, follow these steps:

  1. Import the ApolloTracker class:

    from apollo_tracker import ApolloTracker
    
  2. Initialize the tracker with your service name:

    tracker = ApolloTracker(service_name="my-flask-service")
    
  3. Register the error handler:

    tracker.register_error_handler(app)
    

2. Example Flask App Setup

from flask import Flask
from apollo_tracker import ApolloTracker  # import the tracker class

app = Flask(__name__)

# Initialize ApolloTracker with your service name
tracker = ApolloTracker(service_name="my_project_id")

# Register the error handler to track errors globally
tracker.register_error_handler(app)

@app.route('/')
def home():
    # Simulate an error
    1 / 0  # This will raise a ZeroDivisionError

if __name__ == "__main__":
    app.run(debug=True)

3. Error Handling

  • The ApolloTracker class automatically captures unhandled exceptions in your Flask app.
  • When an error occurs, it sends detailed information (like the error type, message, stack trace, request path, and user agent) to the Apollo server.

Configuration

The APOLLO_URL is defined by default in the ApolloTracker class as:

APOLLO_URL = "https://apollo.tornixtech.com/api/errors"

You don't need to change this unless necessary, as the class will automatically use this URL to send error logs.


This should integrate smoothly with your existing README.md and provide clear setup instructions for users. Let me know if you need any other adjustments!

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

apollo_tracker-0.1.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

apollo_tracker-0.1.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file apollo_tracker-0.1.2.tar.gz.

File metadata

  • Download URL: apollo_tracker-0.1.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for apollo_tracker-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ebe2c23969596c6b79f0dd70fe61821db164689ed2f4dbc7d81c339f1485372d
MD5 225475e6e5f3b12d7dd537f901347d07
BLAKE2b-256 3772f08aa5a785983e6cfbb321285626e2d4396e148c4cfc9b8ab44826d3556c

See more details on using hashes here.

File details

Details for the file apollo_tracker-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: apollo_tracker-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for apollo_tracker-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7e6c2422d3dd1d159a7bbc5a6b41997982aefdfdccd4d55853d170d9ef59f4ce
MD5 a51cea5a06b630fea4e9814d9e8489a3
BLAKE2b-256 5088323172d43b9d80535071b0abc361afeb84648a1b01fca1d84951c9ef6218

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