Skip to main content

Easily create an endpoint for health checks

Project description

https://badge.fury.io/py/django-healthpoint.png https://travis-ci.org/pennersr/django-healthpoint.png 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'

# 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-healthpoint-0.4.1.tar.gz (5.9 kB view details)

Uploaded Source

File details

Details for the file django-healthpoint-0.4.1.tar.gz.

File metadata

  • Download URL: django-healthpoint-0.4.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.7

File hashes

Hashes for django-healthpoint-0.4.1.tar.gz
Algorithm Hash digest
SHA256 ff64f07f863e8aedd130d492ecaf84d7034b656f61dd2a3f2b36575005f436b3
MD5 b061aae3c5d9dfbe393e452356edc8af
BLAKE2b-256 aae7b38106ccc40e2d3207e2adf86ecdc1414a3ab019930b02d8405d56ae24bf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page