Skip to main content

This package provides a Django middleware class that attaches custom attributes to the stack trace that the New Relic agent sends to your console. For example, if a server error occurs you may wish to know the username of the user who received it.

Installation

Install via pip:

$ pip install django-newrelic-extensions

Or from Github:

$ pip install -e git://github.com/sheepdoginc/django-newrelic-extensions.git#egg=django-newrelic-extensions

Add the middleware class to your MIDDLEWARE_CLASSES:

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'newrelicextensions.middleware.NewRelicMiddleware',
)

And then add your settings.

Settings

  • NEW_RELIC_EXTENSIONS_ENABLED: This allows you to disable the extensions during development. (Default: False)

  • NEW_RELIC_EXTENSIONS_DEBUG: This enables the extensions but instead of sending trace backs to New Relic, it prints them out to the console. (Default: True)

  • NEW_RELIC_EXTENSIONS_ATTRIBUTES: This is how you specify what attributes of the Django HttpRequest instance you care about. This should be a dict. Please see below for examples.

Examples

NEW_RELIC_EXTENSIONS_ATTRIBUTES = {
    'user': {
        'username': 'Django username',
        'is_superuser': 'Django super user'
    },
    'is_secure': 'Django secure conneciton',
    'something random': 'Name'
}

This will log the user’s username under the key of Django username and so on. If a variable is callable (like is_secure above), it will be called. If it doesn’t exist, it will silently die (unless you have debug on).

For a list of examples attributes that you can log, see the HttpRequest docs.

To learn more about New Relic’s Python integration, please see their Python tips and tricks page.

License

BSD, short and sweet.

Metadata

Release files for django-newrelic-extensions 0.0.1

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-newrelic-extensions 0.0.1
File Size Uploaded Provenance
django-newrelic-extensions-0.0.1.tar.gz 3.7 kB Without provenance Details

Release files / django-newrelic-extensions-0.0.1.tar.gz

Download URL django-newrelic-extensions-0.0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
45eccd1c2df0ffd7de84284526dcdaaf0e677d7def1d203bbc1a464163684b54
BLAKE2b-256 checksum
How to use checksums
fd6953ddb7c928728f9132360f69fc396a9f8e9db47ecb229de39157a2e2ee14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-newrelic-extensions 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

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