Skip to main content

django-cavalry

A Performance Tracer!

CircleCI Codecov PyPI MIT License

Setup

  • Add 'cavalry.middleware.cavalry' to your middleware.
  • Add CAVALRY_ENABLED = bool(DEBUG) (or similar~) to your settings.

Settings – General

CAVALRY_ENABLED

(boolean, default False)

Master switch for the middleware.

This is toggleable during runtime. That is, it does not wholesale disable the middleware forever via the MiddlewareNotUsed mechanism.

CAVALRY_PROBABILITY

(float, default 1)

Probability (0..1) for a request to be traced; useful in production.

CAVALRY_DB_RECORD_STACKS

(boolean, default True)

Whether or not database stack traces should be recorded. Recording stack traces naturally has a performance impact.

Settings – Posting

The requests library must be available for posting to work.

You can install it by hand, or by using the [poster] extra while installing Cavalry.

CAVALRY_ELASTICSEARCH_URL_TEMPLATE

(string)

An URL template for posting payloads to Elasticsearch. {curly-braced} segments are interpolated using Python syntax. All fields in the payload are available, plus {ymd} is the YYYY-MM-DD of the current time. If falsy, no Elasticsearch posting is attempted.

An useful default might be 'http://localhost:9200/my-app-{ymd}/item'. This is easily ingestible by Kibana.

CAVALRY_THREADED_POST

(boolean, default False)

Whether or not to execute posting in another thread.

Enabling this has a positive performance impact in that formatting and submitting data to Elasticsearch data will not tie up request handling.

On the flipside, though, if the worker process dies before posting is complete, the trace is lost.

Also, if you're running on uWSGI, make sure enable-threads is set.

CAVALRY_POST_STACKS

(boolean, default True)

Whether or not post stack traces.

Not posting stack traces makes the ES payloads smaller.

Runtime

When

  • running in DEBUG, or
  • when you're a superuser, or
  • if request._cavalry_can_inject_stats is truthy (e.g. via a middleware of your own design)
    • Note that this may, especially in conjunction with _cavalry_stacks, reveal sensitive information. Be very diligent with that middleware.

Cavalry injects a small perf bar into each rendered HTML page, as well as a script segment that outputs SQL queries into the dev console.

By default, stack traces are not printed for the SQL queries; add the _cavalry_stacks query parameter to have them printed too.

Release files for django-cavalry 0.5.0

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

Source distribution (sdist)

Source distribution for django-cavalry 0.5.0
File Size Uploaded
django_cavalry-0.5.0.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-cavalry 0.5.0
File Interpreter ABI Platform
django_cavalry-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / django_cavalry-0.5.0.tar.gz

Download URL django_cavalry-0.5.0.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f064b9042c6e4858a4eda19151eafd8bd5bc821abf9e1a2b4d4573115c3b11ae
BLAKE2b-256 checksum
How to use checksums
eb13aafa4d506196572256e7a3e76271ad47f4e822a8292e4c60eddabfe5667d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / django_cavalry-0.5.0-py3-none-any.whl

Download URL django_cavalry-0.5.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
248d5e03b2181d46481cfded6903da3416db18ff1d5f746ebfd8f2809042e1d1
BLAKE2b-256 checksum
How to use checksums
a697d9c5c3d981ba20a8e402e34987836011113d6aaaad1f4a188f0bc24e5b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

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