Skip to main content
https://badge.fury.io/py/django-healthpoint.png https://github.com/pennersr/django-healthpoint/actions/workflows/ci.yml/badge.svg https://img.shields.io/pypi/v/django-healthpoint.svg Coverage Status https://pennersr.github.io/img/bitcoin-badge.svg https://pennersr.github.io/img/emacs-badge.svg

Framework for adding an endpoint for health checks to your project.

Source code

http://github.com/pennersr/django-healthpoint

Quickstart

Install the app:

# settings.py
INSTALLED_APPS = [
    ...
    'healthpoint'
]

# If specified, this user is able to see the details for each
# individual check in the endpoint.
HEALTHPOINT_BASICAUTH_USERNAME = 'john'
HEALTHPOINT_BASICAUTH_PASSWORD = 'doe'

# If set to True authentication is required for executing the
# health checks.
HEALTHPOINT_AUTH_REQUIRED = True

# urls.py
urlpatterns = [
    ...
    url(r'^', include('healthpoint.urls')),
]

Add a module named health.py to any of your apps. For example:

from datetime import timedelta

from django.contrib.auth.models import User
from django.utils import timezone

from healthpoint.decorators import health_check


@health_check
def user_signup():
    last_user = User.objects.last()
    time_since_last_signup = timezone.now() - last_user.date_joined
    # Return True/False, throw an exception, or return a tuple with a
    # detail message.
    return (
        time_since_last_signup <= timedelta(days=1),
        "last signup was: {}".format(last_user.date_joined))

The health checks can be accessed via the /health/ endpoint:

  • It executes all health checks, and reports status 200 if all checks succeed, status 500 otherwise.

  • If a staff user is logged in, the endpoint reports the result for each individual check:

    {
     "success": {},
     "error": {
       "myproject.myapp.health.user_signup": "Last signup was: 2017-10-29 08:45:51"
     }
    }
  • To provide more detail on the result, the @health_check can return a tuple (success:bool, detail:str). The detail message will be listed in the result.

Metadata

Release files for django-healthpoint 1.0.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-healthpoint 1.0.0
File Size Uploaded
django-healthpoint-1.0.0.tar.gz 7.0 kB Details

Release files / django-healthpoint-1.0.0.tar.gz

Download URL django-healthpoint-1.0.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f3bca2452d3f5fc9c8baa9a82e723b0cddcfd7ca00747041ebe24583c415ccdb
BLAKE2b-256 checksum
How to use checksums
aa606171b18404c1937da73dae899a5dabd099dee24c2743a133ae9384ed5843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

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