(name, fn, run_every, multiprocess_mode=MPM_ALL)
return inner
Helper for easily registering gauges to run periodically

    To update a gauge on a schedule based on the result of a function
    just add to your app's tasks.py:

    ::

        my_calculation = metrics_gauge_task(
            'commcare.my.metric', my_calculation_function, run_every=crontab(minute=0)
        )

    kwargs:
        multiprocess_mode: See PrometheusMetrics._gauge for documentation.
Helper for easily registering gauges to run periodically
Helper for easily registering gauges to run periodically
def metrics_gauge_task(name, fn, run_every, multiprocess_mode=MPM_ALL):
    """
    Helper for easily registering gauges to run periodically

    To update a gauge on a schedule based on the result of a function
    just add to your app's tasks.py:

    ::

        my_calculation = metrics_gauge_task(
            'commcare.my.metric', my_calculation_function, run_every=crontab(minute=0)
        )

    kwargs:
        multiprocess_mode: See PrometheusMetrics._gauge for documentation.
    """
    _enforce_prefix(name, 'commcare')

    @periodic_task(serializer='pickle', queue='background_queue', run_every=run_every,
                   acks_late=True, ignore_result=True)
    @wraps(fn)
    def inner(*args, **kwargs):
        from corehq.util.metrics import metrics_gauge
        metrics_gauge(name, fn(*args, **kwargs), multiprocess_mode=multiprocess_mode)

    return inner
def metrics_gauge_task ( name , fn , run_every , multiprocess_mode = MPM_ALL ) : _enforce_prefix ( name , 'commcare' ) @ periodic_task ( serializer = 'pickle' , queue = 'background_queue' , run_every = run_every , acks_late = True , ignore_result = True ) @ wraps ( fn ) def inner ( * args , * * kwargs ) : from corehq . util . metrics import metrics_gauge metrics_gauge ( name , fn ( * args , * * kwargs ) , multiprocess_mode = multiprocess_mode ) return inner