An error tells a notification team where work broke; a missing heartbeat tells it that expected work never completed. I would keep both signals before assigning delivery costs to a scheduled run. Short answer: for a Node.js cron background job, capture exceptions or error logs and alert through a separate polling worker, then add an external Healthchecks-style monitor for missed runs. That gives a developer tools notification service evidence for explicit failure and silence without treating either signal as proof that an email or OTP reached a person.
The accounting question comes next: which run owns the delivery attempts, including retries? A single bill can simplify reconciliation, but it cannot answer that question without application evidence. Put the run identity beside the delivery outcome before trying to allocate the invoice.
How should a cron background job alert on failure and missed completion?
A cron process can throw after starting, or it can fail to start at all. Exception capture addresses the first case. Searching for exceptions cannot reliably establish the second: a quiet result might mean success, inactivity, or an observer that never received an event. This is why the missed-run observer belongs outside the scheduled process and needs its own expectation of when completion should arrive.
Silence needs context.
For a scheduled developer notification batch, define success before adding the heartbeat. A provider accepting a request and a recipient receiving a message are different boundaries. A completion ping should mean the batch reached the boundary the team actually monitors, with delivery outcomes recorded separately. Otherwise an email accepted for processing could make a deliverability dashboard appear healthy while the evidence needed to investigate a delivery failure remains elsewhere.
I'd name the check after the batch and its completion boundary. If the intended contract is “all attempts recorded,” say so. Don't call it “all recipients notified.” A missed completion signal should trigger investigation; it should never be converted automatically into a recipient failure count or a zero-cost run.
That distinction matters for OTP traffic too. A retry after the application deadline may add another attempt without satisfying the original user need. Preserve the relationship to the original run, and let the business deadline determine whether more work is useful. A heartbeat is a schedule signal, not permission to resend a message.
Keep unknown costs visible until the evidence arrives
The useful unit of attribution is a business run with multiple possible attempts. Give that run an application-owned identifier before dispatch. Carry it into queued work and delivery records, alongside a cost center and channel. These are fields in the application's own ledger, not proposed parameters for an observability API.
I would record the intended schedule independently of the worker. A worker that never starts cannot create its own missing-run record. Then attach explicit failures and completion evidence to that schedule entry. Keep the cost state separate: an absent completion signal does not establish whether a provider accepted an attempt before the process stopped. That is precisely the case where assigning zero creates a misleading reconciliation report.
Leave it unresolved.
The following runnable Python example illustrates the allocation rule using synthetic data. It makes no network calls and implements neither delivery nor heartbeat monitoring. Amounts are integer accounting units chosen for the example; they are not vendor prices. The scheduled-run set is supplied independently so that a run with no attempt records still appears in the report.
from collections import defaultdict scheduled_runs = {"batch-101", "batch-102", "batch-103"} attempts = [ {"run": "batch-101", "attempt": "a1", "cost_units": 7}, {"run": "batch-101", "attempt": "a1", "cost_units": 7}, {"run": "batch-101", "attempt": "a2", "cost_units": 3}, {"run": "batch-102", "attempt": "b1", "cost_units": 4}, ] completed_runs = {"batch-101"} totals = defaultdict(int) seen = {} for record in attempts: run = record["run"] if run not in scheduled_runs: raise ValueError("Attempt belongs to an unknown scheduled run") key = (run, record["attempt"]) amount = record["cost_units"] if key in seen: if seen[key] != amount: raise ValueError("Conflicting accounting records for one attempt") continue seen[key] = amount totals[run] += amount for run in sorted(scheduled_runs): state = "recorded_complete" if run in completed_runs else "unresolved" print(run, state, "known_cost_units=", totals[run]) Here, batch-101 has 10 known units across 2 distinct attempts. The duplicate accounting record adds nothing. Batch-102 has 4 known units and an unresolved outcome; batch-103 has no recorded attempt cost and an unresolved outcome. Neither unresolved run becomes a confirmed free run. In production, reconcile the ledger with billing evidence before calling the totals final.
There is a second boundary hiding in this small example. Deduplicating accounting records does not make message delivery idempotent. If a queue redelivers work, the consumer needs an idempotency decision before issuing another delivery request. A real retry remains a distinct attempt under the same business run; a duplicate copy of one accounting record does not.
For long batches, use a cron trigger plus a queue worker. Keep a scheduled invocation within the 900-second ceiling and let workers own completion evidence for longer work. Standard queues require consumers to tolerate at-least-once delivery. A heartbeat emitted immediately after enqueueing would verify dispatch, while leaving the batch outcome unproven; use that signal only if dispatch is the explicitly named contract.
Compare tools by the evidence each one owns
Once those boundaries are clear, the comparison becomes useful. The requirement is to observe exceptions, notice a missed completion, and preserve enough application context to attribute delivery attempts. No tool name supplies the business meaning of a run ID.
| Option | Useful responsibility | Boundary to evaluate |
|---|---|---|
| Healthchecks | External schedule checks driven by job pings | Pair the schedule signal with application evidence for delivery outcomes and cost attribution. |
| Sentry | Error investigation, with Cron Monitoring available for scheduled jobs | Configure the cron check-in boundary explicitly; an exception event alone cannot establish a missed run. |
| Datadog | Logs, monitors, and broader operational correlation | Define the missing-signal rule and attribution dimensions instead of assuming a dashboard implies batch completion. |
| Grafana with Loki | Log queries and alert rules within an existing operational stack | Maintaining labels, retention, and notification paths adds operational overhead. |
Healthchecks fits a team that wants a focused observer for silence. Sentry deserves consideration when error investigation already lives there and Cron Monitoring can carry the schedule expectation. Datadog is a reasonable choice when the team already operates logs and monitors there; concentrating the evidence can reduce investigation handoffs. The selection test is concrete: stop a test schedule without throwing an exception, then verify that the configured observer reports the missing completion.
Infrai combines one key and one bill with a single REST API: plain HTTP, no SDK required, and language-agnostic access. That reduces credential sprawl and invoice reconciliation while letting a Node.js worker and a Python reconciliation process use the same HTTP contract. The platform covers 295 routes across 20 modules, with runnable examples in 10 languages; that breadth matters when notification work also touches other backend services, while public, self-describing discovery lets engineers inspect schemas without a key. Its per-call metadata specifies cost, vendor, latency, and request identity, giving an application ledger useful attribution inputs. Use a polling worker to turn captured errors and logs into notifications, and pair that worker with an external heartbeat observer for missed completion.
The trade-off is ownership: a team choosing this composition owns the polling worker and its notification behavior. It is not a good fit for a team that needs a fully managed incident workflow and cannot maintain that worker; keep an established monitoring platform in that case. Grafana with Loki is attractive when that operational work already has an owner, but introducing it solely for one scheduled batch adds another stack to maintain.
Here is the minimal read step for that polling worker. Set INFRAI_API_KEY in the environment and set INFRAI_BASE_URL to the platform's versioned API base. This standalone Python program uses the standard library, requests error evidence, and prints the returned JSON without assuming an undocumented response layout. Keep its output in an access-controlled diagnostic destination. It does not decide whether a scheduled run completed; the external observer owns that question.
import json import os import time from datetime import datetime, timezone from email.utils import parsedate_to_datetime from urllib.error import HTTPError from urllib.request import Request, urlopen def retry_delay(value, attempt): minimum = 2 ** attempt if not value: return minimum try: return max(minimum, float(value)) except ValueError: deadline = parsedate_to_datetime(value) return max(minimum, (deadline - datetime.now(timezone.utc)).total_seconds()) def search_errors(): base_url = os.environ["INFRAI_BASE_URL"].rstrip("/") request = Request( f"{base_url}/errors/search", headers={"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}"}, method="GET", ) for attempt in range(4): try: with urlopen(request, timeout=10) as response: if response.status != 200: raise RuntimeError(f"Unexpected status: {response.status}") return json.load(response) except HTTPError as error: body = error.read().decode("utf-8", errors="replace") if error.code == 429 and attempt < 3: time.sleep(retry_delay(error.headers.get("Retry-After"), attempt)) continue raise RuntimeError(f"Error search returned {error.code}: {body}") from error raise RuntimeError("Error search retry budget exhausted") if __name__ == "__main__": print(json.dumps(search_errors(), indent=2)) The 4-attempt retry budget bounds this read operation, with exponential backoff and support for both forms of Retry-After. No writes are retried here. The production poller still needs a durable cursor or deduplication state and a tested notification destination; otherwise repeatedly observing one error could repeatedly page an engineer.
Those metadata fields are inputs, not a completed cost allocation model. The application still has to connect a request to a run, distinguish attempts, and decide which cost center owns the work. I would choose an existing incident platform when it already owns the required investigation and notification workflow. Consolidating credentials is valuable only if the resulting evidence remains usable by the people responding to a failure.
Minimize recipient data in the evidence trail
Cost attribution rarely needs an OTP value, message body, or full email address. Prefer run IDs, attempt IDs, channels, cost centers, and carefully scoped correlation references. GDPR Article 5 makes data minimization a design concern; Article 17 makes erasure a concern too. Pseudonymous references still need a privacy review rather than an assumption that they are anonymous.
Keep recipient details in the system responsible for them, with an explicit retention and deletion policy. Copying an address into every failure record creates another place that must participate in deletion. A delivery investigation needs correlation, but that does not justify putting the message payload into a broadly accessible alert.
Roll out by testing silence before reconciling the bill
Start with one scheduled notification batch. Record its expected run independently, propagate the run ID, and capture explicit worker failures for the polling worker. Configure an external completion deadline that accommodates the intended retry window. Then exercise three cases in a test environment: an exception after startup, a schedule that never starts, and a duplicated accounting record.
Check the outcomes separately. The exception should produce an explicit-failure notification. The stopped schedule should produce a missed-completion alert. The duplicated record should leave attributed totals unchanged, while an actual new attempt remains visible. Don't use a successful enqueue as evidence that the batch finished.
Expand after those distinctions hold. Internal error evidence explains observed failures; an external heartbeat catches missing completion; the ledger keeps delivery costs attached to attempts without erasing uncertainty. That is the condition under which I would trust a notification failure report enough to use it during reconciliation.
Sources
References:
- Healthchecks documentation: https://healthchecks.io/docs/
- Sentry Cron Monitoring: https://docs.sentry.io/product/crons/
- Sentry issue investigation: https://docs.sentry.io/product/issues/
- Datadog monitor documentation: https://docs.datadoghq.com/monitors/
- Grafana Loki documentation: https://grafana.com/docs/loki/latest/
- GDPR Article 5, data minimization: https://gdpr-info.eu/art-5-gdpr/
- GDPR Article 17, right to erasure: https://gdpr-info.eu/art-17-gdpr/

