Package: pynba
PynbaPynba is a WSGI Middleware forPinba. It allows realtime monitoring/statistics
server using MySQL as a read-only interface. It works on Python 2.7, >=3.3 and
pypy.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!AndIsCool Entertainmentalready uses Pinba for monitoring PHP based
applications.RequirementsThis library relies only onPinba.
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.SetupIf you want to install the official release, do:$ pip install pynbaBut i you prefer to use the current developement version, do:$ git clone https://github.com/johnnoone/pynba.git
$ python setup.py installUsageSays that your main WSGI application is:def app(environ, start_response):
    ...Import the pynba decorator, and decorate your main app with it:from pynba.wsgi import monitor

@monitor(('127.0.0.1', 30002))
def app(environ, start_response):
    ...Each time the app will be processed, a new UPD stream will be sent.You can also tag the process, for example:@monitor(('127.0.0.1', 30002), tags={'foo': 'bar'})
def app(environ, start_response):
    ...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 pynba.wsgi import pynba

timer = pynba.timer(foo="bar")
timer.start()
...
timer.stop()But you may want to supervise simple scripts. For this usage, useScriptMonitor:from pynba.util import ScriptMonitor

monitor = ScriptMonitor(('127.0.0.1', 30002), tags={'foo': 'bar'})
timer = monitor.timer(foo='bar')
timer.start()
...
timer.stop()
monitor.send()Some use cases are available on src/examples/Logging and debuggingPynba 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')
logger.setLevel(logging.DEBUG)
logger.setHandler(logging.handlers.SysLogHandler)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 pynba.wsgi import PynbaMiddleware

monitored_app = PynbaMiddleware(app, ('127.0.0.1', 30002))
monitored_app.reporter.raise_on_fail = TrueThe decorated version:from pynba.wsgi import monitor

@monitor(('127.0.0.1', 30002))
def app(environ, start_response):
    ...
app.reporter.raise_on_fail = TrueOr the script usage:from pynba.util import ScriptMonitor

monitor = ScriptMonitor(('127.0.0.1', 30002))
monitor.reporter.raise_on_fail = TrueContributeWhile debugging, you can rebuild c package with this command:$ python setup.py cythonize developDifferences with PHP extensionAbout the data sent:ru_utimeandru_stimerepresent the resource usage for the current
process, not the shared resources.document_sizecannot be automaticaly processed with the current WSGI
specification. You are able to set manually this value like this:pynba.document_size = [YOUR VALUE]memory_peakalso is currently not implemented. Like the previous data,
you can set manually this value like this:pynba.memory_peak = [YOUR VALUE]memory_footprintalso 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:ScriptMonitorallows to monitor single scripts.IsCool Entertainmentuses it for monitoring our AMQ based workers.LicenseThis package is release under the MIT Licence.
Please see LICENSE document for a full description.CreditsPinbaIsCool EntertainmentNews0.1Release date: 19-Jun-2012First release0.2Release date: 29-Jun-2012Logging refactoring0.3Release date: 26-Sept-2012Migrate to cythonRemoved Werkzeug dependency0.3.2Release date: 1-Oct-2012Fixed empty strings0.3.3Release date: 29-Oct-2012Added util for scripts monitoring0.3.5Release date: 29-Oct-2013Status support on reporter0.3.6Release date: 4-Jun-2014preparation for Python 3 supportuse pytest and tox for testingadded a Reporter.raise_on_fail attribute, in order to hide exceptions on production servers.describe logging strategy0.4.0Release date: 6-Jun-2014Python >= 3.3 support !added memory_footprint and schema reportingadded cythonize commanddropped protobuf library for the benefit of a small embedded script0.4.1Release date: 6-Jun-2014don’t raise an Exception on pynba.enabled when outside of contextimplements DataCollector tags0.4.2Release date: 18-Jul-2014fix util.ScriptMonitor0.4.3Release date: 06-Nov-2014fix util.ScriptMonitor tags0.5.4Release date: 18-Jun-2015PyPy support !forked from iscool_e.pynbarefactored packages: it’s not a wsgi only usage anymore0.5.5Release date: 8-Sept-2015Cython unicode fix