This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

canary is a small library for recording and shipping exceptions from Python to logstash via ZeroMQ.

Example Usage

Assuming logstash is running and bound to a 0mq socket at tcp://0.0.0.0:2120:

$ cat logstash.conf
input {
    zeromq {
        type => 'python-exception'
        mode => 'server'
        topology => 'pushpull'
        address => 'tcp://0.0.0.0:2120'
        charset => 'UTF-8'
    }
}
output {
    debug => true
}

…to report exceptions thrown by your WSGI application, wrap your WSGI app with canary.middleware.LogStashMiddleware:

from logging.config import dictConfig as load_logging_config
from wsgiref.simple_server import make_server
from wsgiref.util import setup_testing_defaults

from canary.middleware import LogStashMiddleware


def app(environ, start_response):
    setup_testing_defaults(environ)
    assert True is False

if __name__ == '__main__':
    load_logging_config({
        'version': 1,
        'loggers': {'canary': {'level': 'ERROR', 'handlers': ['zeromq']}},
        'handlers': {
            'zeromq': {
                'level': 'ERROR',
                'class': 'canary.handler.ZeroMQHandler',
                'address': 'tcp://127.0.0.1:2120',
                'formatter': 'logstash'
            }
        },
        'formatters': {
            'logstash': {
                '()': 'canary.format.LogstashFormatter'
            }
        }
    })

    httpd = make_server('', 8080, LogStashMiddleware(app))
    print "Serving on port 8080..."
    httpd.serve_forever()

Excluding Certain Exceptions

You may want to prevent canary from logging certain types of exceptions. To do so, pass a list of exceptions into the LogStashMiddleware constructor:

app = LogStashMiddleware(app, ignored_exceptions=[SomePrivateException])

Filtering Sensitive Data

canary automatically populates exception logs with contextual data from the WSGI environ. Sometimes, though, this data can contain sensitive details, like customer’s login credentials. canary makes it easy to filter certain request arguments from the logs it produces:

app = LogStashMiddleware(app, sensitive_keys=['password', 'cc_number'])

Development

Source hosted at GitHub. Report issues and feature requests on GitHub Issues.

To fix bugs or add features to canary, a GitHub account is required.

The general practice for contributing is to fork canary and make changes in the next branch. When you’re finished, send a pull request and your patch will be reviewed.

Tests require tox and can be run with $ pip install tox && tox.

All contributions must:

  • Include accompanying tests.
  • Include API documentation if new features or API methods are changed/added.
  • Be (generally) compliant with PEP8.
  • Not break the tests or build. Before issuing a pull request, ensure that all tests still pass across multiple versions of Python.
Release History

Release History

0.1.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
canary-0.1.4.tar.gz (6.9 kB) Copy SHA256 Checksum SHA256 Source Apr 11, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting