Skip to main content

Flask-Breathalyzer

https://api.travis-ci.org/mindflayer/flask-breathalyzer.png?branch=master https://coveralls.io/repos/mindflayer/flask-breathalyzer/badge.png?branch=master

A Flask module pushing exceptions to Datadog

https://raw.githubusercontent.com/mindflayer/flask-breathalyzer/master/Flask-Breathalyzer.png

Features

  • Pushing exceptions to Datadog;

  • Blacklist for headers or data as list of XPATH style strings (you may have some headers you do not want to publish for privacy, or maybe some body fields you do not need to display - e.g.: a base64 blob).

Installation

Using pip:

$ pip install flask_breathalyzer[datadog]

Issues

When opening an Issue, please add few lines of code as failing test, or -better- open its relative Pull request adding this test to our test suite.

Quick example

Let’s create a new virtualenv with all we need:

$ virtualenv example
$ source example/bin/activate
$ pip install pytest flask_breathalyzer[datadog]

As second step, we create a test example.py file as the following one:

from flask import Flask
import datadog

from flask_breathalyzer import Breathalyzer


def test_example():

    app = Flask(__name__)

    @app.route("/")
    def boom():
        1/0

    # from http://docs.datadoghq.com/api/
    options = {
        'api_key': 'your-datadog-api-key',
        'app_key': 'your-datadog-app-key'
    }

    ba = Breathalyzer(app, **options)
    response = test_client.get('/')
    assert response.status == '500 INTERNAL SERVER ERROR'
    assert b'<title>500 Internal Server Error</title>' in response.data
    assert response.mimetype == 'text/html'
    assert isinstance(ba.last_event_id, int)  # your exception is now on Datadog with this ID

Let’s fire our example test:

$ py.test example.py

Metadata

Release files for Flask-Breathalyzer 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Breathalyzer 0.2.2
File Size Uploaded
Flask-Breathalyzer-0.2.2.tar.gz 6.4 kB Details

Release files / Flask-Breathalyzer-0.2.2.tar.gz

Download URL Flask-Breathalyzer-0.2.2.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
469a8c11f0162c99dc8dda5a2682682684be3e2328ffdb0a1f1fce136b192082
BLAKE2b-256 checksum
How to use checksums
d2dc7c456bc2ca43299c148c7f0fb9639c1105026169faea2d6e420178e6adb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.2 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page