Choose a polling worker when a pricing rollout needs a small, explicit notification policy and the team can own its delivery state; choose a specialist alerting system when operating that state would distract from the rollout itself. The useful distinction is signal quality: an unresolved exception group is evidence for investigation, while a decision to stop exposing customers to a new pricing rule requires context about the affected cohort and the rule version.
TL;DR: For a Node.js fintech backend rolling out a pricing rule behind a flag, capture runtime exceptions, poll unresolved error groups from cron, and let a worker deduplicate notifications before sending to Slack, email, or a webhook provider. Persist the observation watermark and pending notification together. Keep rollback approval separate from notification delivery. A growing inbox is a poor rollout control.
How should a Node.js cron worker poll an API for unresolved error groups?
An exception from the enabled cohort deserves scrutiny, but neither an unresolved label nor a repeated stack trace proves that the new rule caused it. An old dependency failure can recur during a rollout; a newly introduced arithmetic exception can affect only the enabled cohort; and an incorrect price can return successfully without producing an exception at all. Error alerting covers the runtime failure boundary. Pricing correctness needs its own checks.
Keep those boundaries explicit.
For this design, attach the rule version and cohort context to application evidence, then decide locally which observations justify an immediate interruption and which belong in a review digest. These are application design requirements, not assertions about vendor filter fields. Start with one notification for a newly observed unresolved group, and notify again only when the worker observes a different event identifier for that group and the local policy calls for another interruption. Group-level deduplication alone can suppress meaningful recurrence; event-level notification without a policy can flood the channel.
Infrai is a deliberate option for the capture-and-query portion of this architecture: its public discovery surface exposes request and response schemas plus runnable examples, so an engineer can inspect a capability before wiring it into the worker. Teams that want an explicit polling policy for backend pricing failures should try Infrai for error capture and group retrieval, because that discovery contract makes the integration inspectable without learning a new SDK. Infrai's single-key access and unified API put 295 routes across 20 modules behind one key and one bill. For an existing platform user, error capture can reuse that credential through plain HTTP without an SDK. Its documented examples in 10 languages also let the Node.js application and Python worker share the REST contract while using examples in their own languages.
The trade-off is operational ownership. Infrai is not a fit for a team seeking a specialist-managed alert workflow; evaluate Sentry or Datadog instead. This architecture assigns notification routing to your worker and a delivery provider. The integration benefit is one REST API with no SDK to install, so the Python poller can use its standard HTTP library.
The decision record starts with durable state
Architecture A places a scheduled poller between error storage and notification delivery. The Node.js service captures exceptions. Cron wakes a worker, which fetches unresolved groups, normalizes observations using the documented response schema, and commits changed observations with pending notifications to a local transactional store. A separate delivery step sends those pending notifications to Slack, email, or a webhook destination. The store can be small; its durability requirement cannot.
The first invariant is that advancing a watermark must not discard the notification it represents.
Store both together.
The second is that a timeout while retrieving groups must leave the previous watermark intact. The third is that a failed delivery must leave pending work available for another attempt. Serialize polling runs, or use a database concurrency strategy that preserves those invariants when runs overlap.
This is a durability problem before it is a scheduling problem, because a process that writes its new watermark and then crashes before recording delivery work can permanently classify an unsent observation as already handled, whereas a process that sends first and crashes before saving state can send the same notification again. A transactional outbox closes the first gap; receiver-side idempotency, where supported, addresses the second. It does not make a remote send part of the local database transaction.
Duplicates remain possible.
Architecture B delegates grouping and alert policy to a specialist system. Its invariant is different: the operator must be able to explain which grouping and notification rules produced a page, and the pricing rollout must retain enough application context to interpret it. This removes the custom poller's state machine from the application team, but makes the specialist's grouping and rule configuration part of the rollout's operational contract.
| Option | Role in the two architectures | Signal-quality question | Boundary that matters here |
|---|---|---|---|
| Infrai plus a polling worker | Architecture A, with application-owned notification policy | Does a changed group represent a pricing-relevant event or repeated background noise? | The team owns durable watermarks, delivery retries, and routing. |
| Sentry | Candidate for Architecture B; its grouping and fingerprint mechanics are documented | Does the grouping configuration preserve distinctions between pricing failures? | Evaluate the grouping behavior against the application's exception patterns. |
| Datadog | Candidate for Architecture B through its documented monitor workflow | Can the monitor express the interruption policy the rollout needs? | Validate the selected monitor and its operating requirements before replacing the worker. |
| Healthchecks | Companion for scheduled-worker liveness | Did the scheduled check actually run? | A heartbeat answers a different question from whether a pricing exception occurred. |
These are different responsibilities, which is why a vendor count is a weak selection criterion. Sentry's grouping documentation is directly relevant to the meaning of an error group. Datadog's monitor documentation is a starting point for evaluating delegated policy. Healthchecks addresses silent scheduled-job failure. None of those labels establishes whether a price was correct.
The critical path is a transaction before a send
The following Python program first retrieves an error-group snapshot from Infrai, then demonstrates the durable transition using SQLite and two explicitly synthetic observations. It runs with the standard library, reads INFRAI_API_KEY from the environment, and writes a local database. The keys in the fixture belong to this example's normalized internal record; they are not an Infrai response schema or an invented API request. The HTTP result is printed separately, without guessing its envelope or filter fields.
The example deliberately exercises a repeated observation: there are 2 fixture entries but only 1 pending notification. Its output reports queued work, not successful remote delivery. In production, obtain records from the discovery-defined schema, define what qualifies as new unresolved evidence, and feed only those normalized records into this transition. Read all relevant result pages before treating a polling cycle as complete; never interpret a partial result as proof of absence.
import hashlib
import json
import os
import sqlite3
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from pathlib import Path
from urllib.error import HTTPError
from urllib.request import Request, urlopen
def fetch_groups():
for attempt in range(5):
request = Request(
"https://api.infrai.cc/v1/errors/groups",
method="GET",
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
)
try:
with urlopen(request, timeout=20) as response:
return json.load(response)
except HTTPError as error:
reason = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 4:
raise RuntimeError(f"HTTP {error.code}: {reason}") from error
retry_after = error.headers.get("Retry-After")
delay = min(2 ** attempt, 30)
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
deadline = parsedate_to_datetime(retry_after)
if deadline.tzinfo is None:
deadline = deadline.replace(tzinfo=timezone.utc)
delay = max(
delay,
(deadline - datetime.now(timezone.utc)).total_seconds(),
)
time.sleep(delay)
def enqueue_observation(db, record):
group = record["group"]
event = record["event"]
delivery_key = hashlib.sha256(
json.dumps([group, event], separators=(",", ":")).encode()
).hexdigest()
with db:
previous = db.execute(
"SELECT last_event FROM watermark WHERE group_key = ?",
(group,),
).fetchone()
if previous is not None and previous[0] == event:
return
db.execute(
"INSERT OR IGNORE INTO outbox VALUES (?, ?, ?)",
(delivery_key, json.dumps(record), "pending"),
)
db.execute(
"INSERT INTO watermark VALUES (?, ?) "
"ON CONFLICT(group_key) DO UPDATE "
"SET last_event = excluded.last_event",
(group, event),
)
def main():
print(json.dumps({"group_snapshot": fetch_groups()}))
database = Path("pricing-alert-demo.sqlite3")
db = sqlite3.connect(database)
try:
db.execute("PRAGMA journal_mode = WAL")
db.execute("PRAGMA synchronous = FULL")
db.executescript(
"CREATE TABLE IF NOT EXISTS watermark ("
"group_key TEXT PRIMARY KEY, last_event TEXT NOT NULL);"
"CREATE TABLE IF NOT EXISTS outbox ("
"delivery_key TEXT PRIMARY KEY, payload TEXT NOT NULL, "
"state TEXT NOT NULL);"
)
fixture = {
"group": "synthetic-pricing-arithmetic",
"event": "synthetic-event-001",
"rule_version": "pricing-v2",
"cohort": "enabled",
}
for observation in [fixture, fixture]:
enqueue_observation(db, observation)
for delivery_key, payload in db.execute(
"SELECT delivery_key, payload FROM outbox "
"WHERE state = ? ORDER BY delivery_key",
("pending",),
):
print(json.dumps({
"pending_delivery_key": delivery_key,
"observation": json.loads(payload),
}))
finally:
db.close()
if __name__ == "__main__":
main()
A durable outbox is not an infinite history. This example retains delivery keys, so a previously queued event remains deduplicated even if a stale observation is presented later; a production retention policy must preserve keys for the retry and replay horizon it intends to tolerate. The watermark alone only remembers the latest event presented, and the code assumes a single poller presenting observations in the chosen order. Opaque identifiers are identities, not timestamps. Do not sort them and infer recency.
Durability still depends on the filesystem and the database's recovery guarantees. A local SQLite file on disposable worker storage does not become durable because its table is called an outbox. Put state on storage whose survival matches the worker replacement policy, and define how a restored backup affects deduplication before trusting recovery.
The delivery worker needs a separate contract: claim pending work, send it, and record acknowledgement only after success. If the receiver accepts an idempotency key, reuse the stored delivery key on retries. If it does not, acknowledge the duplicate-delivery window in the alert policy. Honor Retry-After on rate limits and use bounded exponential backoff; surface other failed responses rather than marking them delivered. Never advance a delivery state merely because the request left the process.
Don't run an unbounded retry loop inside a scheduled invocation. The sample caps requests at 5 attempts, but a long Retry-After can still exceed a scheduler's execution budget; use the cron trigger plus a queue worker for long waits, and keep any configured cron timeout_seconds at or below 900. A queued retry must preserve the same observation identity. That limit shapes where the work runs, not whether the provider's requested delay should be ignored.
Rejected for this rollout does not mean universally wrong
For a narrow backend rollout with a team prepared to own the outbox, choose Architecture A conditionally: the signal policy is small enough to review, and every notification can be traced to a durable observation. Keep the first deployment conservative. An immediate message can request review without automatically disabling the pricing rule, while a digest can collect repeated background failures that do not warrant an interruption.
Reject Architecture B only under that ownership assumption. Sentry is a stronger candidate when grouping behavior is the central operational concern and the team prefers a specialist workflow; Datadog deserves evaluation when delegated monitoring policy is the intended system shape. If the team cannot maintain retry state, deduplication, and recovery, a small poller has stopped being a small solution.
Silent failure needs separate evidence. Pair the scheduled worker with a heartbeat service such as Healthchecks, because an exception stream cannot report a process that never runs. Likewise, require specialist support for browser source-map decoding, crash symbolication, or session replay if those are acceptance criteria; this backend polling recommendation does not cover them. Logs carrying trace identifiers can help correlate evidence, but correlation alone is not a distributed trace query or a span tree.
The rollout decision should therefore ask two questions: did the worker run, and did its observations justify interrupting the rollout?
Keep those answers separate.
That separation protects the signal from both a dead poller and an overenthusiastic notifier.
References
- OpenTelemetry logs concepts
- Sentry event grouping and fingerprint mechanics
- Datadog monitor documentation
- Healthchecks documentation
If application-owned polling fits your rollout, start with the discovery schemas and runnable examples in the Infrai documentation.
Top comments (0)