django_auto_healthchecks

Module contents

class django_auto_healthchecks.Healthcheck(route=None, args=None, kwargs=None, current_app=None, name=None, code=None, method=u'GET', querystring=None, body=None, headers=None, cookies=None, assertions=None, tags=None, note=None, interval_seconds=None, timeout_seconds=None)[source]

Bases: object

:type healthchecks.Healthcheck

display_name()[source]

Retrieve the effective name of this healthcheck.

resolve()[source]

Because the route cannot be reversed into a URL at the same time its defined, we delay route resolution until we are ready to submit the healthchecks to the API.

serialize()[source]

Serialize current instance details into valid API payload :return: dict

exception django_auto_healthchecks.HealthcheckError[source]

Bases: exceptions.RuntimeError

:type healthchecks.HealthcheckError Healthcheck definition exception

django_auto_healthchecks.put(healthchecks=())[source]

Optionally, use the put method to batch create/update healthcheck definitions

django_auto_healthchecks.url(regex, view, healthcheck=None, **kwargs)[source]

url is a drop-in replacement for django URL that adds a new healthcheck kwarg

django_auto_healthchecks.healthchecks module

class django_auto_healthchecks.healthchecks.Healthcheck(route=None, args=None, kwargs=None, current_app=None, name=None, code=None, method=u'GET', querystring=None, body=None, headers=None, cookies=None, assertions=None, tags=None, note=None, interval_seconds=None, timeout_seconds=None)[source]

Bases: object

Define a healthcheck using a django url route that will be put to the Cronitor API

route (str): Name of a url route. If omitted, must be set before resolve().

args (list|tuple): Optional args to be passed to reverse() this route. Cannot be used with kwargs.

kwargs (dict): Optional kwargs to be passed to reverse() this route. Cannot be used with args.

current_app (str): If the app is namespaced or route name is not unique the current_app argument is
needed for reverse().

name (str): Optional name for this monitor. If none is provided, a name will be generated.

code (str): Optional monitor code. Use this to tie to an existing healthcheck on your Cronitor dashboard

method (str): Request method used when performing this healthcheck.

querystring (dict): Optional querystring parameters that will be appended to the URL

body (str): Request body sent when performing this healthcheck if method is PUT, POST or PATCH.

headers (dict): Optional request headers that will be sent when performing this healthcheck.

cookies (dict): Optional cookies that will be sent when performing this healthcheck.

assertions (dict): Optional assertions for this monitor. See API docs for details.

tags (list|tuple): Optional tags for this monitor.

note (string): Optional note that will be attached to this monitor.

interval_seconds (int): Optional interval between healthcheck tests. If omitted, a default will be used.

timeout_seconds (int): Optional timeout for this request, maximum of 10 seconds.

display_name()[source]

Retrieve the effective name of this healthcheck.

resolve()[source]

Because the route cannot be reversed into a URL at the same time its defined, we delay route resolution until we are ready to submit the healthchecks to the API.

serialize()[source]

Serialize current instance details into valid API payload :return: dict

exception django_auto_healthchecks.healthchecks.HealthcheckError[source]

Bases: exceptions.RuntimeError

class django_auto_healthchecks.healthchecks.HealthcheckUrl(path, querystring)[source]

Bases: object

display = None

:type unicode Shorter, prettier version of URL for display

url = None

:type unicode Fully qualified URL that will be used in healthcheck

class django_auto_healthchecks.healthchecks.IdempotentHealthcheckClient[source]

Bases: object

Put enqueued healthchecks to the Cronitor API.

drain()[source]

Drain enqueued healthchecks and return a list of distinct Healthcheck objects :return: List[Healthcheck]

enqueue(healthcheck)[source]

Add a healthcheck instance to a queue for later processing. healthcheck (Healthcheck): Healthcheck instance to enqueue

put(additional_healthchecks=None)[source]
django_auto_healthchecks.healthchecks.put(healthchecks=())[source]

Batch create-or-update health checks with supplied list of Healthcheck instances. Invoke from your deploy script, or add healthchecks for third-party apps without having to hack their code. :param healthchecks: list[Healthcheck] of Healthcheck objects These healthchecks will be merged with any defined in

urls.py file(s). See https://cronitor.io/docs/django-health-checks for details.
django_auto_healthchecks.healthchecks.url(regex, view, healthcheck=None, **kwargs)[source]

Drop-in replacement for django.conf.urls.url to create and update a Cronitor healthcheck when your app restarts. See https://cronitor.io/docs/django-health-checks for details. regex (str): Route regex, passed to django.conf.urls.url() view (mixed): Attached view for this route, passed to django.conf.urls.url() healthcheck (Healthcheck): Define your healthcheck with a Healthcheck() instance. :return RegexURLPattern

django_auto_healthchecks.apps module

class django_auto_healthchecks.apps.HealthchecksAppConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

Attach into the Django app startup. At this point the URL resolver cache has not been warmed yet.

name = 'django_auto_healthchecks'
ready()[source]