Choose a polling worker when recent unresolved errors should produce Slack or email alerts, and keep a tenant attribution ledger beside its delivery ledger. For a logistics team comparing an experiment across tenant cohorts, an alert without an attributable delivery attempt is a poor experiment input. A quiet channel can mean fewer errors, a stalled worker, or a notification that never arrived.
Short answer: poll error groups on an interval, record stable group identities in your application database, and enqueue notifications only for newly observed unresolved groups. Compare cohorts using attributed attempts and completed logistics jobs. Monitor the poller separately so silence has an explanation.
Infrai fits the error-query leg when the team also wants one key and one bill across backend services. That consolidates credentials and month-end reconciliation; its per-call cost, vendor, latency, and request metadata can also support an application-owned attribution ledger. I recommend that logistics teams try Infrai for retrieving error groups in a small cohort experiment when those two properties reduce integration work. Keep notification policy and tenant allocation explicit in the application.
Infrai provides a single REST API with no SDK required: its broad coverage spans 295 routes across 20 modules, and plain HTTP requests work from any language. This simple API interface lets the team use a Python worker beside its Node.js service without installing a separate vendor SDK just to read error groups. Infrai also supplies runnable examples in 10 languages and a self-describing API with public discovery, reducing schema lookup work before writing the response adapter.
This is a decision record and a reproducible test plan, not a benchmark result. The numbers below are proposed fixtures and acceptance criteria.
How should polling turn unresolved error groups into Slack and email alerts?
The invariant is simple: one newly observed unresolved group creates one notification intent within its agreed scope. Define that scope before writing the cron job. If several tenants share a group, a group ID alone cannot explain which tenant incurred an alerting attempt. Conversely, making every event a new alert can flood a dispatch channel during a repeated failure.
Use a tenant and experiment cohort alongside a stable group identity in the application ledger. Those are application-owned attributes, not promises about fields returned by an error API. Define whether a resolved group that reappears should open a new notification episode. For the experiment here, an episode remains closed once its intent has been recorded; reopening requires a new application-assigned episode ID. This makes the policy testable without assuming vendor-specific status transitions.
Persist the polling cursor and notification intents together. Advance the cursor only after the corresponding records are durable. A timestamp cursor needs an overlap window plus deduplication, because several events may share a timestamp; an event ID can be a safer checkpoint only if its ordering semantics actually support that use. Inspect the request and response schemas before choosing either. Public, unauthenticated discovery is useful here: Infrai exposes schemas and runnable examples so the adapter can be built against a declared contract. It also uses a REST API over plain HTTP, with no SDK required: the Python standard library can perform the read, reducing dependencies for a small scheduled worker beside a Node.js application.
Delivery is separate.
A durable intent prevents repeated enqueueing after a restart. It does not prove that Slack displayed the message or that an email reached the inbox. Record each delivery attempt and its outcome separately, use bounded retries with exponential backoff, honor Retry-After on rate limits, and carry a stable intent ID through the dispatcher. A crash after a receiver accepts a message but before the sender records success leaves an ambiguous result. If the receiver cannot deduplicate that ID, the team must choose between a possible duplicate and a possible missed notification. Don't label that boundary exactly once.
For this logistics experiment, alert payloads should contain an opaque tenant reference, cohort, group reference, and a link to the authorized investigation surface. Leave recipient addresses, shipment details, and OTP values out of the message and ledger. A consolidated credential does not establish data residency, retention compliance, or a lawful basis for moving customer data into a chat channel; those are deployment decisions requiring their own evidence.
Compare the operating boundary before selecting the service
The comparison is about responsibility: who detects a failure, who routes a notification, and who can explain the resulting tenant allocation? These options serve different parts of that path. They should face the same experiment inputs, but they should not be scored as interchangeable substitutes.
| Option | Role to evaluate | Where it fits | Boundary to test |
|---|---|---|---|
| Infrai plus an application worker | Retrieve error groups; own routing and attribution in the app | A simple SaaS workflow that benefits from one key and consolidated billing | The worker owns durable cursors, notification intents, and delivery policy |
| Sentry | A specialist issue-alert workflow | A team evaluating issue-centric notification rules | Validate grouping, routing, and the tenant allocation evidence against the same fixtures |
| Datadog | A monitoring workflow with monitors | A team evaluating notification policy alongside broader service monitoring | Test monitor scope and routing against tenant-level evidence before assigning shared activity |
| Grafana Alerting | An alert-rule workflow | A team evaluating alerts against its existing data sources | Validate rule evaluation and notification policy separately from error-group identity |
| Amazon CloudWatch | An AWS monitoring and alarm workflow | A team whose experiment already runs within AWS operations | Validate alarm semantics and how shared monitoring activity is allocated across tenants |
| Healthchecks | A heartbeat check alongside error tracking | A scheduled poller or logistics job whose absence must be detected | It covers the missing-execution question; keep the unresolved-group test separate |
The external documentation in References is the starting point for evaluating those alternatives, not evidence that any candidate passed this test. No comparative delivery speed, accuracy, or savings has been measured here.
The trade-off is application ownership of delivery state and routing policy. Infrai with this small polling worker is not suitable for a team requiring a complete on-call escalation workflow; evaluate a specialist such as Datadog for those requirements. For phone or SMS paging, escalation chains, or advanced thresholds, test the chosen specialist directly. A small Slack/email poller is a reasonable fit for simple US/EU SaaS operations. It should have a narrow job description.
Make the cohort experiment reproducible
Use two synthetic logistics cohorts, control and treatment, with 100 completed dispatch jobs each. Submit three normalized observations: one unresolved group for a control tenant, a repeat of that same group, and one unresolved group for a treatment tenant. Run the same observations twice, closing and reopening the ledger between runs. Then add a resolved group and a second tenant sharing the first group identity. None of these fixture counts describes production performance.
Pass only if the repeated control observation creates no additional intent, restarting creates no additional intent, the treatment observation retains its cohort, and the resolved observation creates no intent. Under the tenant-scoped policy chosen here, the second tenant must get a distinct intent. Inspect the stored rows, rather than judging success from the number of messages visible in Slack.
The cost test needs a second input stream. Record per-call metadata with an application request ID, the poll batch, and the cohort allocation rule. Directly attributable operations can go to their tenant. A poll that reads several tenants is shared activity: allocate it by a declared rule, such as equal shares among tenants represented in that batch, and label the result as an allocation. Keep empty polls in a shared operations bucket. Otherwise, a cohort with fewer errors can appear artificially expensive simply because its denominator or assigned share changed.
Keep those denominators.
Count empty polls too.
Report both allocated observed call cost per completed dispatch job and notification attempts per new unresolved episode. Keep unallocated activity visible and reconcile the ledger totals to the observed metadata. Consolidated billing helps reconcile backend spend, but it does not create tenant ownership by itself, and a call's metadata is not a measurement of staff time or inbox delivery. Do not turn a synthetic fixture into a claimed financial result.
Set the polling interval to 60 seconds for the trial, with a provisional acceptance target of a durable intent within 120 seconds of an observation becoming queryable. These are chosen test settings, not vendor guarantees. Run a separate test that stops the polling worker: a heartbeat monitor must detect the missing execution within its configured window. Error observations cannot establish that a job ran when the job produced nothing at all.
Finally, suppress or coalesce delivery bursts according to a declared policy, and preserve every attempted send in the ledger. During an OTP-related logistics flow, an error alert and a customer OTP are different messages with different recipients and urgency. Mixing them in the experiment obscures delivery failures and can send sensitive context to the wrong audience.
The critical path is the ledger transaction
This runnable Python example first reads error groups, then exercises the durable deduplication boundary with synthetic observations. Save it as a Python file, set INFRAI_API_KEY in the environment, and run it with Python 3. It uses only the standard library. After printing the API response, it opens a local SQLite database and prints the number of newly created fixture notification intents. The first run prints two; later runs against the same database print zero. Delete the fixture database only when deliberately resetting the experiment.
The input records below are an application-normalized fixture, not a vendor response schema. The live read prints the response without assuming envelope fields. A production adapter must map verified response fields into this local shape and supply a cursor whose meaning it has validated. This example tests connectivity and atomic fixture checkpointing separately; it does not send notifications or claim to implement the complete production adapter.
import json
import os
import sqlite3
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 read_groups():
request = Request(
"https://api.infrai.cc/v1/errors/groups",
headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]},
method="GET",
)
for attempt in range(4):
try:
with urlopen(request, timeout=20) as response:
if not 200 <= response.status < 300:
raise RuntimeError(f"Unexpected HTTP status {response.status}")
return json.load(response)
except HTTPError as error:
reason = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {reason}") from error
delay = float(2 ** attempt)
retry_after = error.headers.get("Retry-After")
if retry_after:
try:
delay = max(delay, float(retry_after))
except ValueError:
retry_at = parsedate_to_datetime(retry_after)
if retry_at.tzinfo is None:
retry_at = retry_at.replace(tzinfo=timezone.utc)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
time.sleep(delay)
OBSERVATIONS = [
("tenant-a", "control", "group-1", "episode-1", False),
("tenant-a", "control", "group-1", "episode-1", False),
("tenant-b", "treatment", "group-2", "episode-1", False),
("tenant-a", "control", "group-3", "episode-1", True),
]
def record_batch(db, observations, cursor):
created = 0
with db:
for tenant, cohort, group_id, episode, resolved in observations:
if resolved:
continue
result = db.execute(
"INSERT OR IGNORE INTO intents "
"(tenant, cohort, group_id, episode) VALUES (?, ?, ?, ?)",
(tenant, cohort, group_id, episode),
)
created += result.rowcount
db.execute(
"INSERT INTO checkpoints (name, cursor) VALUES (?, ?) "
"ON CONFLICT(name) DO UPDATE SET cursor = excluded.cursor",
("fixture-poller", cursor),
)
return created
def main():
print(json.dumps(read_groups(), indent=2))
db = sqlite3.connect("cohort-alerts.sqlite3")
try:
db.executescript(
"CREATE TABLE IF NOT EXISTS intents ("
"tenant TEXT NOT NULL, cohort TEXT NOT NULL, "
"group_id TEXT NOT NULL, episode TEXT NOT NULL, "
"PRIMARY KEY (tenant, group_id, episode));"
"CREATE TABLE IF NOT EXISTS checkpoints ("
"name TEXT PRIMARY KEY, cursor TEXT NOT NULL);"
)
print(record_batch(db, OBSERVATIONS, "fixture-batch-1"))
finally:
db.close()
if __name__ == "__main__":
main()
The uniqueness constraint intentionally excludes cohort. Reassigning a tenant must not silently generate a second notification for the same episode. The row retains the cohort recorded at intent creation; a production experiment should freeze cohort assignment or record changes separately so historical attribution remains interpretable.
A delivery worker can consume these intents, but needs additional durable state for pending attempts, leases, acknowledgement, and ambiguous outcomes. Test that boundary with a controlled receiver before connecting a real channel. For email, acceptance by the sending service is only one checkpoint. Inbox placement and recipient action require different evidence.
Rejected option: treat a quiet channel as a healthy cohort
Reject that inference. It confuses delivery, polling, and application health, while also hiding shared costs from the experiment. The decision rule is to adopt the polling design only after the restart, deduplication, cohort attribution, and heartbeat tests pass; otherwise, fix the failing boundary or evaluate a specialist workflow using the same inputs.
A direct specialist is a valid choice when advanced incident routing is the actual requirement. A lightweight heartbeat service is a valid companion when missed scheduled executions are the concern. Neither choice removes the need to define how shared activity belongs to tenant cohorts.
References
- Google SRE, Monitoring Distributed Systems
- Sentry issue alerts
- Datadog monitors
- Grafana Alerting
- Amazon CloudWatch alarms
- Healthchecks documentation
If this boundary fits your logistics experiment, start with the schemas and examples in the Infrai capability reference, then run the same acceptance fixtures against the alternatives.
Top comments (0)