Skip to main content

Client for App Enlight reporting - supporting WSGI and django (http://appenlight.com)

Project description

https://appenlight.com/static/images/index-laptop-sm.png

appenlight_client

Python Logo Pyramid Logo Flask Logo Django Logo

Installation and Setup

Install appenlight_client using pip:

pip install appenlight-client

Main Documentation location

appenlight developer documentation contains most up to date information, including implementation guides in popular python web frameworks.

https://appenlight.com

Documentation: https://appenlight.com/page/api/main

Usage

Configuring appenlight and django

For django framework there is separate compatible middleware provided.

Modify your settings file to contain:

import appenlight_client.client as e_client
APPENLIGHT = e_client.get_config({'errormator.api_key':'YOUR_PRIVATE_KEY'})

Additionally middleware stack needs to be modified with additional middleware:

MIDDLEWARE_CLASSES = (
    'appenlight_client.django_middleware.appenlightMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...

Please note that appenlight middleware should be the first one in stack to function properly.

Run your django app providing appenlight_INI env variable containing absolute path to your config file.

Configuring appenlight and pyramid

Usage (example for pyramid or other WSGI pipeline compatible solutions like Zope):

In your INI file you need to add:

[filter:appenlight_client]
use = egg:appenlight_client
appenlight.config_path = %(here)s/appenlight.ini #optional if you don't want to set appenlight_INI env var

[pipeline:main]
pipeline =
    .....your other pipeline entries ....
    appenlight_client
    app_name

To minimize configuration complexity, the client by default will look for appenlight_INI environment variable that will supply absolute path to config file.

for pylons app you can modify config/middleware.py: import the callable and add this lines:

#exception gathering
# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)

app = make_appenlight_middleware(app,config)

and add in your ini:

appenlight.config_path = %(here)s/appenlight.ini #optional if you don't want to set appenlight_INI env var

appenlight client provides slow call and datastore timing capabilities, currently out of the box folliwing libraries are supported:

  • urllib

  • urllib2

  • urllib3

  • requests

  • pysolr

  • httplib

  • most used dbapi2 drivers

  • mongodb

  • mako templates

  • jinja2 templates

  • django templates

If for some reason you want to disable timing of specific library - just set the time value to false.

Changing default scaffold configuration in Pyramid Web Framework

Default scaffolds in pyramid 1.3 have a section called [app:main] - appenlight client expects that you are using wsgi pipeline instead to position itself in it.

The easiest way to accomplish that is to alter your configuration file to look like this:

[app:main] becomes [app:yourappname]

and inside your configuration, above [server:main] directive following directive should appear:

[pipeline:main]
pipeline =
    ... your other middleware you may have ...
    appenlight_client
    yourappname

Exception views in Pyramid Web Framework and appenlight

You also need to add appenlight tween to your application, you can do this in two ways:

# by adding following line to your config object
config.include('appenlight_client.ext.pyramid_tween')

Or by altering your ini file to contain a new include:

pyramid.includes = appenlight_client.ext.pyramid_tween
                   ... other includes you might have ..

Sensitive data filtering

The client by default blanks out COOKIE,POST,GET for keys like: ‘password’,’passwd’,’pwd’,’auth_tkt’

This behaviour can be altered to filter all kinds of data from the structures that get sent to the server by passing dotted module name in configuration:

appenlight.filter_callable = foo.bar.baz:callable_name

example:

def callable_name(structure, section=None):
    structure['request']['SOMEVAL'] = '***REMOVED***'
    return structure

appenlight will try to import foo.bar.baz and use callable_name as the function that accepts parameters (structure, section) and returns altered data structure.

Please note that this functionality can be used to alter things like appenlight grouping mechanism - you can set this variable based on values present in structure generated by the client

appenlight_client is BSD licensed, consult LICENSE for details.

client source: https://github.com/AppEnlight/appenlight-client-python

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

appenlight_client-0.6.7.tar.gz (42.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page