Skip to main content

Overview

The slowlog library helps you find out why some requests to your web application take a long time. It periodically dumps stack traces of long running requests to a log file. It works as a Pyramid tween or as a WSGI component. It is inspired by Products.LongRequestLogger, which provides similar functionality for Zope 2.

This library can also log frame statistics to Graphite using the perfmetrics library, making it possible to create real-time graphs that reveal expensive code paths.

This library uses sys._current_frames() to gather stack traces, so it supports CPython versions 2.6+ and 3.2+, but other Python implementations might not work.

TravisBadge

Installation

Install using setuptools, e.g. (within a virtualenv):

$ bin/easy_install slowlog

Pyramid Configuration

Once the slowlog library is installed, use the config.include mechanism to add slowlog to your project. In your Pyramid project’s __init__.py:

config = Configurator(...)
config.include('slowlog')

Alternately, you can add the following line to your application’s .ini file:

pyramid.includes = slowlog

Next, Pyramid needs some settings before the slowlog library has any effect. Two tweens are available, slowlog and framestats.

The slowlog tween

The slowlog tween periodically logs stack traces of long running requests. To activate it, set slowlog = true in your Pyramid settings. The slowlog tween supports the following settings.

slowlog

Set to true to activate the slowlog tween. Default: false.

slowlog_timeout

Only log stack traces of requests that last at least this number of seconds (floating point). Default: 2.0.

slowlog_interval

Once a request lasts longer than slowlog_timeout, the slowlog tween continues to log stack traces periodically with the given interval in seconds (floating point). Default: 1.0.

slowlog_file

Log all stack traces to the given file. The file will be rotated automatically when it grows to 10 megabytes. If this setting is empty or missing, stack traces will be logged using Python’s standard logging module with the logger name slowlog. Default: none.

slowlog_frames

Limit the number of frames in stack traces. If set to 0, no stack traces will be logged. Default: 100.

slowlog_hide_post_vars

A whitespace-delimited list of POST variables that should be redacted (hidden) in logs. Useful for avoiding accidental storage of cleartext passwords. Default: password.

The framestats tween

The framestats tween periodically increments Statsd counters for all frames on the stack of long-running requests. To activate it, set framestats = true in your Pyramid settings. The framestats tween supports the following settings.

framestats

Set to true to activate the framestats tween. Default: false.

statsd_uri

Required. A common URI is statsd://localhost:8125. See the perfmetrics library for supported parameters.

framestats_timeout

Only update Statsd for requests that last at least this number of seconds (floating point). Default: 2.0.

framestats_interval

Once a request lasts longer than framestats_timeout, the framestats tween continues to update Statsd periodically with the given interval in seconds (floating point). Default: 1.0.

framestats_frames

Limit the number of frames to follow in stack traces. If set to 1, Statsd will receive information about only the current frame. Default: 100.

CHANGES

0.9 (2012-09-22)

  • Initial release.

Release files for slowlog 0.9

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

Source distribution (sdist)

Source distribution for slowlog 0.9
File Size Uploaded
slowlog-0.9.tar.gz 14.6 kB Details

Release files / slowlog-0.9.tar.gz

Download URL slowlog-0.9.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4faae46b28ab5a133c0b9ad49e1dae5435d8e977e7fbab7195bc99556f71325a
BLAKE2b-256 checksum
How to use checksums
66dafd7339236cf78322f97d4e94750bd9100655211f5bb86523e09cf639fdbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.9 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