Minutely probes

This feature requires AppSignal for Python version 1.2.0 or higher.

Minutely probes are a mechanism to periodically send custom metrics to AppSignal. In minutely intervals from when the probe was first created, a user-defined function can be called in which you can capture metrics to send them to AppSignal. Minutely probe functions are ran asynchronously.

You can enable or disable minutely probes entirely with the enable_minutely_probes config option.

Registering probes

To track custom metrics from your application, you can add your own probes. To register a probe, you must call the probes.register() method with two arguments: a probe name, and a function to be called once every minute.

Python
from appsignal import probes, set_gauge def set_database_size_gauge(): set_gauge("database_size", 10) probes.register("database", set_database_size_gauge)

To ensure all minutely probes are ran in a timely manner, it is important to avoid blocking for long periods inside a minutely probe function.

Stateful probes

A probe function can keep state in between executions by accepting it as an argument and returning it. This is useful to keep track of how values change over time:

Python
from appsignal import probes, set_gauge def set_user_signups_gauge(previous_user_count): current_user_count = User.objects.all().count() if previous_user_count is not None: set_gauge("user_signups", current_user_count - previous_user_count) return current_user_count probes.register("user_signups", set_user_signups_gauge)

The first time the minutely probe is called, None will be passed as the argument. In successive invocations, the value returned by the previous invocation will be passed to it as an argument.