skip to navigation
skip to content

Not Logged In

iscool_e.pynba 0.4.0

lightweight timers and wsgi middleware to monitor performance in production systems

Latest Version: 0.5.0

IsCool Entertainment Pynba

Pynba is a WSGI Middleware for Pinba. It allows realtime monitoring/statistics server using MySQL as a read-only interface. It works on Python 2.7, 3.3 and more.

It accumulates and processes data sent over UDP by multiple Python processes and displays statistics in a nice human-readable form of simple “reports”, also providing read-only interface to the raw data in order to make possible generation of more sophisticated reports and stats.

Users also can measure particular parts of the code using timers with arbitrary tags.

Why another statistics manager ?

Because Pinba rocks!

At IsCool Entertainment, we already use Pinba for monitoring our PHP based applications.


This library relies on Pinba and Protobuf, and Werkzeug before the version 0.3. You will need to install theses packages before using Pynba.

The installation process requires setuptools to be installed. If it is not, please refer to the installation of this package.


If you want to install the official release, do:

$ pip install iscool_e.pynba

But i you prefer to use the current developement version, do:

$ git clone
$ python install


Says that your main WSGI application is:

def app(environ, start_response):

Import the pynba decorator, and decorate your main app with it:

from iscool_e.pynba import monitor

@monitor(('', 30002))
def app(environ, start_response):

Each time the app will be processed, a new UPD stream will be sent.

Eventualy, you can use timers to measure particular parts of your code. For it, just import the pynba proxy, and use it to create new timers:

from iscool_e.pynba import pynba

timer = pynba.timer(foo="bar")

But you may want to supervise simple scripts. For this usage, use ScriptMonitor:

from iscool_e.pynba.util import ScriptMonitor

monitor = ScriptMonitor(('', 30002))
timer = monitor.timer(foo='bar')

Some use cases are available on src/examples/

Logging and debugging

Pynba log to the ‘pynba’ logger. You should plug an handler in it. For example, let’s say you want to log everything to syslog, here is the modop:

import logging
import logging.handlers
logger = logging.getLogger('pynba')

Another aspect is that reporting will be as discreet as possible, by not raising exceptions on errors. This feature can be disabled directly into the reporter instance.

For the WSGI usage:

from iscool_e.pynba import PynbaMiddleware

monitored_app = PynbaMiddleware(app, ('', 30002))
monitored_app.reporter.raise_on_fail = True

The decorated version:

from iscool_e.pynba import monitor

@monitor(('', 30002))
def app(environ, start_response):
app.reporter.raise_on_fail = True

Or the script usage:

from iscool_e.pynba.util import ScriptMonitor

monitor = ScriptMonitor(('', 30002))
monitor.reporter.raise_on_fail = True


While debugging, you can rebuild c package with this command:

$ python cythonize develop

Differences with PHP extension

About the data sent:

  • ru_utime and ru_stime represent the resource usage for the current process, not the shared resources.

  • document_size cannot be automaticaly processed with the current WSGI specification. You are able to set manually this value like this:

    pynba.document_size = [YOUR VALUE]
  • memory_peak also is currently not implemented. Like the previous data, you can set manually this value like this:

    pynba.memory_peak = [YOUR VALUE]
  • memory_footprint also is currently not implemented. Like the previous data, you can set manually this value like this:

    pynba.memory_footprint = [YOUR VALUE]

About timers:

  • The Python version permites multiple values for each timer tags. Just declare any sequences, mapping or callable. This example:

    pynba.timer(foo='bar', baz=['seq1', 'seq2'], qux={'map1': 'val1'})

    Will populates 4 values for 3 tags in the Pinba database:

    ('foo', 'bar'),
    ('baz, 'seq1'),
    ('baz, 'seq2'),
    ('qux.map1', 'val1')

Other additions:

  • ScriptMonitor allows to monitor single scripts. At IsCool Entertainment, we use it for monitoring our AMQ based workers.


This package is release under the MIT Licence. Please see LICENSE document for a full description.



Release date: 19-Jun-2012

  • First release


Release date: 29-Jun-2012

  • Logging refactoring


Release date: 26-Sept-2012

  • Migrate to cython
  • Removed Werkzeug dependency


Release date: 1-Oct-2012

  • Fixed empty strings


Release date: 29-Oct-2012

  • Added util for scripts monitoring


Release date: 29-Oct-2013

  • Status support on reporter


Release date: 4-Jun-2014

  • preparation for Python 3 support
  • use pytest and tox for testing
  • added a Reporter.raise_on_fail attribute, in order to hide exceptions on production servers.
  • describe logging strategy


Release date: 6-Jun-2014

  • Python >= 3.3 support !
  • added memory_footprint and schema reporting
  • added cythonize command
  • dropped protobuf library for the benefit of a small embedded script
File Type Py Version Uploaded on Size
iscool_e.pynba-0.4.0.tar.gz (md5) Source 2014-06-06 185KB
  • Downloads (All Versions):
  • 18 downloads in the last day
  • 187 downloads in the last week
  • 869 downloads in the last month