Skip to Content
ExamplesBackground Jobs

Background Jobs

Background jobs are a strong fit for Chirpier because the model is simple and operational. Each job run produces a small number of flat events that map directly to the signals you care about.

EventValueWhy
job.completed.count1 per completionTrack throughput and spot processing stalls
job.retry.count1 per retryCatch jobs that are failing and retrying repeatedly
queue.backlog.gaugeCurrent queue depthMonitor queue pressure in real time
job.duration_msDuration in msDetect slow jobs before they block the queue

Logging events

await client.log({ agent: "worker.billing", event: "job.completed.count", value: 1, meta: { job_type: "invoice_generate", queue: "billing" } }); await client.log({ agent: "worker.billing", event: "job.duration_ms", value: 3200, meta: { job_type: "invoice_generate" } }); await client.log({ agent: "worker.billing", event: "queue.backlog.gauge", value: 42, meta: { queue: "billing" } });
EventPeriodAggregateConditionThresholdWhy
job.retry.counthoursumgt20Jobs failing and retrying too often
queue.backlog.gaugeminutemaxgt500Queue building up faster than workers can drain
job.duration_msdayp95_estgt30000Slow jobs that might block the queue
job.completed.counthoursumlt10Processing stall — too few completions

Using comparisons

Compare this hour’s retry count to the same hour yesterday to see if retries are normal or elevated:

const analytics = await client.getEventAnalytics(retryEventID, { view: "window", period: "1h", previous: "previous_1d", }); // value_pct_change of +300% means retries are 3x higher than usual

Destination routing

Use destination policy_ids to separate job alerts by team. For example, route billing job alerts to a #billing-ops Slack channel and general infrastructure alerts to #platform-ops.

Last updated on