Skip to main content

build_tracer

Return a function that traces task execution. Catches all exceptions and updates result backend with the state and result.

def build_tracer(
name: string,
task: celery.app.task.Task,
loader: celery.loaders.base.BaseLoader = None,
hostname: string = None,
store_errors: boolean = True,
Info: type = TraceInfo,
eager: boolean = False,
propagate: boolean = False,
app: celery.Celery = None,
monotonic: callable = time.monotonic,
trace_ok_t: namedtuple = trace_ok_t,
IGNORE_STATES: set = IGNORE_STATES
) - > function

Return a function that traces task execution. Catches all exceptions and updates result backend with the state and result.

Parameters

NameTypeDescription
namestringThe display name of the task being traced.
taskcelery.app.task.TaskThe task instance to be executed and monitored.
loadercelery.loaders.base.BaseLoader = NoneThe loader used for task initialization and process cleanup hooks.
hostnamestring = NoneThe worker hostname to record in the task metadata.
store_errorsboolean = TrueWhether to persist error details to the result backend.
Infotype = TraceInfoThe class used to wrap task execution metadata and state handling.
eagerboolean = FalseIf true, the task is executed locally in the current process without a broker.
propagateboolean = FalseWhether to re-raise exceptions to the caller instead of catching them.
appcelery.Celery = NoneThe Celery application instance associated with the task.
monotoniccallable = time.monotonicThe clock function used to measure task execution duration.
trace_ok_tnamedtuple = trace_ok_tThe return type structure for successful trace results.
IGNORE_STATESset = IGNORE_STATESA set of task states that should not trigger the after_return hook.

Returns

TypeDescription
functionA trace_task function that wraps the task execution, handles state transitions (SUCCESS, RETRY, FAILURE), and manages result persistence.