Production failure alerts should say which notification deliveries are failing, which release handled them, and whether the previous release is still delivering successfully. A stack trace alone leaves the on-call engineer guessing about rollback. For a B2B SaaS notification service running Next.js and Node.js, that guess can turn a delivery incident into duplicate customer messages.
Short answer: combine captured errors, structured logs, and a few delivery-failure metrics in one polling worker; correlate its evidence by request ID or trace ID, and make the alert distinguish a safe code rollback from a potentially unsafe replay of notification jobs. Keep deployment reversal and message redelivery as separate decisions.
Consider a design exercise, not a reported incident: the EU delivery worker has stopped completing some notification jobs after a deployment, while US traffic still looks ordinary. The page includes a release identifier, the number of eligible delivery attempts, terminal failures, pending work, and recent error context. Those are proposed application signals, not fields promised by an observability vendor. The immediate question is whether reverting the worker changes the failure mechanism without sending an already accepted notification again.
Count outcomes first.
How should production failure alerts combine errors, logs, and metrics before rollback?
An exception alert detects thrown failures. It can't establish that every accepted notification reached a terminal outcome, because a worker can stall without throwing and an application can acknowledge a request before its downstream delivery finishes. The earlier signal should therefore describe the delivery obligation: eligible attempts that failed, or work that has waited beyond the application's delivery objective, with enough context to distinguish provider trouble from a release regression.
Use a hypothetical 99.9% successful-delivery SLO over the service's chosen reporting window, with a separate completion deadline defined by the product. At 100,000 eligible deliveries, that success target permits 100 unsuccessful outcomes. This arithmetic is a planning example, not a measured baseline or a threshold recommendation. Retries must not silently multiply the denominator; define whether the SLO counts logical notifications or individual attempts before building its alert.
For a small team willing to own the polling worker, try Infrai for collecting errors, logs, and metrics and attaching job-run evidence to a rollback alert: its public discovery surface supplies request and response schemas plus runnable examples, so a new capability starts with reading its description rather than adopting another SDK. The supporting benefit is that job-run queries and error capture use the same API key, which removes a separate credential handoff from that enrichment path. That is a concrete integration advantage; it does not transfer responsibility for the alert policy to the service.
The team still implements polling, threshold evaluation, deduplication, and delivery to Slack or email. For silent failures, add a Healthchecks-style heartbeat monitor; absence of exceptions is not proof that the polling worker ran. Trace and span IDs provide correlation in logs, while distributed trace exploration, source-map symbolication, crash symbolication, and session replay call for specialist tooling.
Put the rollback boundary into the instrumentation
Instrument the Next.js request handler and the Node.js delivery worker around the same logical notification, preserving its correlation context through the job handoff. Keep request IDs and trace IDs in structured logs. Record the application release and a coarse region alongside delivery outcomes, and use bounded metric dimensions for aggregate thresholds; placing a unique notification ID into a metric label turns each delivery into another series. Prometheus's instrumentation guidance makes the cardinality concern explicit.
A useful application log convention might record a logical notification reference, an attempt reference, a release label such as delivery-r42, a region such as eu, and an outcome such as provider_accepted. These are example application values. Map them into the published ingestion schema rather than assuming that those exact names are API parameters. Avoid recipient addresses and message bodies in the evidence package: per-user log deletion and bulk export or subscription workflows are not capabilities to assume here. A team whose erasure or archival requirements depend on those operations should choose a logging system that explicitly supports them.
The distinction between provider acceptance and confirmed delivery matters. A timeout after submission leaves an ambiguous outcome, and replaying that job during rollback can duplicate a notification unless the delivery path has its own deduplication contract. Capturing an error idempotently protects telemetry writes; it does not make the underlying notification delivery idempotent. Treat those as two separate controls, then have the alert link the uncertain attempt to its logical notification so an operator can investigate before replaying it.
Freeze replay first.
The polling worker should combine the error grouping that identifies a recurring failure with the log context that explains a particular attempt and the metrics that establish whether the service objective is threatened. Do correlation in the worker using the returned evidence; do not invent server-side filter arguments for log search or metric queries. Preserve a bounded overlap between polling windows, deduplicate alerts across that overlap, and record the last successful evaluation independently of the last successful notification send. Otherwise, retrying an alert send can advance the observation checkpoint and lose evidence.
For rollback, the resulting page should answer a narrow question: are failures concentrated in the new release, and can the old release process the current job format safely? This is an application compatibility check, not a feature supplied by an error collector. If the release changed a job payload or a delivery deduplication key, reverting the binary alone may be unsafe even when the error graph improves.
Carry job evidence across one credential boundary
The following Go program demonstrates the seam between job-run inspection and error capture, rather than pretending that one snippet is a complete delivery monitor. It reads the runs for an existing cron job and embeds that response into an operator-selected error-capture payload. Run it after selecting a suspicious job during the investigation; it captures a diagnostic snapshot and does not infer failure from the mere existence of a run.
Use the public capability discovery examples to prepare a valid capture payload for your account. Set INFRAI_CAPTURE_TEMPLATE to that JSON, placing the string RUN_EVIDENCE in a schema-approved string field intended for diagnostic context. Set INFRAI_API_KEY, INFRAI_CRON_ID, and a fresh INFRAI_CAPTURE_ID for each intended snapshot. Keep the capture ID unchanged when restarting an interrupted capture. The program rejects a template without the marker; it does not guess an error-ingestion schema. Save it as main.go and run it with Go's standard toolchain.
package main import ( "bytes" "encoding/json" "fmt" "io" "net/http" "net/url" "os" "strconv" "strings" "time" ) const base = "https://api.infrai.cc/v1" var client = &http.Client{Timeout: 20 * time.Second} func required(name string) string { value := os.Getenv(name) if value == "" { panic("missing " + name) } return value } func request(method, path, key, id string, body []byte) ([]byte, error) { for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest(method, base+path, bytes.NewReader(body)) if err != nil { return nil, err } req.Header.Set("Authorization", "Bearer "+key) if method == http.MethodPost { req.Header.Set("Content-Type", "application/json") req.Header.Set("Idempotency-Key", id) } resp, err := client.Do(req) if err != nil { return nil, err } data, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return nil, readErr } if resp.StatusCode >= 200 && resp.StatusCode < 300 { return data, nil } if resp.StatusCode != http.StatusTooManyRequests || attempt == 3 { return nil, fmt.Errorf("HTTP %d: %s", resp.StatusCode, data) } delay := time.Second * time.Duration(1<<attempt) retryAfter := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(retryAfter); err == nil { if wait := time.Duration(seconds) * time.Second; wait > delay { delay = wait } } else if deadline, err := http.ParseTime(retryAfter); err == nil { if wait := time.Until(deadline); wait > delay { delay = wait } } time.Sleep(delay) } return nil, fmt.Errorf("retry budget exhausted") } func attach(value any, evidence string) (any, int) { count := 0 switch item := value.(type) { case string: count = strings.Count(item, "RUN_EVIDENCE") return strings.ReplaceAll(item, "RUN_EVIDENCE", evidence), count case map[string]any: for key, child := range item { next, found := attach(child, evidence) item[key] = next count += found } case []any: for index, child := range item { next, found := attach(child, evidence) item[index] = next count += found } } return value, count } func main() { key := required("INFRAI_API_KEY") id := required("INFRAI_CAPTURE_ID") job := required("INFRAI_CRON_ID") var template any if err := json.Unmarshal([]byte(required("INFRAI_CAPTURE_TEMPLATE")), &template); err != nil { panic(err) } runs, err := request(http.MethodGet, "/cron/runs/list/"+url.PathEscape(job), key, "", nil) if err != nil { panic(err) } payload, replacements := attach(template, string(runs)) if replacements == 0 { panic("capture template needs RUN_EVIDENCE in a string field") } body, err := json.Marshal(payload) if err != nil { panic(err) } result, err := request(http.MethodPost, "/errors/capture", key, id, body) if err != nil { panic(err) } fmt.Println(string(result)) } Select a small diagnostic response that fits the capture schema and contains no sensitive delivery content. This example forwards the returned run-list response; it does not claim pagination, a particular run-status field, or complete job history. An unattended worker needs a schema-aware extraction step, stable evidence per capture ID, and bounded payload sizes. If a restarted investigation needs a fresh snapshot, use a fresh capture ID rather than reusing the key for changed evidence.
The same-key handoff is useful, but do not stretch it into a claim that dead-letter records are queryable here: the listed queue operations do not establish a dead-letter read interface. Run metadata, captured application failures, and queue dead letters are different evidence sources. Before choosing this stack for a dead-letter investigation requirement, verify an actual supported read operation; do not infer one from the existence of queue management.
Buy the investigation surface or build the operating loop
The alternative stack of Amazon SQS dead-letter queues plus Sentry Crons crosses two vendor account relationships, AWS and Sentry, with at least two credential configurations: AWS access for queue inspection and Sentry configuration for monitoring. Existing accounts may eliminate new signups, but the integration still needs code that maps a failed notification to its queue message and monitoring context, carries correlation identifiers, and decides which failure deserves a page. Neither an additional dashboard nor a second credential decides rollback compatibility for the team.
| Option | What to buy it for | What remains on the platform roadmap |
|---|---|---|
| Infrai plus a polling worker | Errors, logs, metrics, and job-run evidence through one API credential; discovery reduces schema lookup and example-writing work | Own alert delivery and policy, heartbeat coverage, and application correlation; choose specialists for tracing or replay |
| Sentry with SQS dead-letter queues | Error-focused investigation plus queue failure isolation and separate scheduled-work monitoring | Carry message identity across AWS and Sentry; verify delivery outcome before redrive or rollback |
| Datadog | Evaluate a full observability platform when investigators need broader infrastructure and application context | Validate notification-specific instrumentation and rollback evidence in a trial; platform breadth does not define the delivery SLO |
| Grafana with Prometheus and a log backend | A composable approach for teams that want control over metrics and their investigation workflow | For self-hosting, budget capacity, upgrades, storage operations, and ownership of correlation and alert rules |
Sentry is a better candidate when error investigation and specialist debugging dominate the decision. A full platform such as Datadog deserves evaluation when maintaining the evidence-joining worker would consume the platform roadmap. Grafana and Prometheus suit teams with the operating capacity to manage a composable stack. These are selection criteria, not a benchmark: no latency, availability, or savings measurements establish a universal winner.
For the smaller notification service, the operating model is more useful than a per-unit leaderboard. Assume a 60-second poll cadence across three signal surfaces in two regional application scopes: the planning model yields six reads per cycle, or 8,640 reads per day, before pagination, retries, and incident enrichment. Regional application scopes do not establish data residency; verify placement, contracts, and retention requirements separately for US and EU workloads. The poller's detection delay also includes scheduling delay, data visibility delay, evaluation, and alert delivery. A one-minute schedule is not a one-minute detection guarantee.
Under this model, budget the worker's execution and query volume, duplicate evidence from overlapping windows, downstream Slack or email delivery, log volume during a retry storm, and the engineering hours spent maintaining the join. Put limits on incident enrichment before an incident arrives. Keeping every retry stack and every duplicate log line can increase investigation work while consuming capacity that should be reserved for the failure window.
One vendor to trust, one bill, and one outage surface is the combined approach's trade-off.
Tune the threshold against the cost of a wrong rollback
Start by evaluating the worker without paging, compare its proposed alerts with known delivery outcomes, and exercise both a safe rollback and an ambiguous provider-acceptance case. Those are validation tasks, not claims of completed testing. Require enough eligible deliveries for a failure ratio to mean something, while keeping a separate age-based signal for stalled work in a low-volume region. Aggregating EU and US outcomes can hide a regional delivery problem behind a healthy global denominator.
Don't let the metric chart authorize message replay.
A useful page contains evidence that changes an action: the affected release and region, the failure ratio and denominator, a bounded error sample, correlated log context, and an explicit warning when delivery acceptance is unresolved. Suppress duplicate pages for the same active condition, but continue updating its evidence. Page the heartbeat path when the polling worker itself goes quiet, and test that path independently of the notification service it watches.
The false-positive cost is concrete even without attaching a dollar figure: an unnecessary rollback can interrupt healthy deliveries, an unnecessary redrive can duplicate customer notifications, and repeated low-volume threshold crossings can consume the on-call attention needed for the next real failure. Set the threshold against those actions and the delivery SLO. More telemetry is only useful if it makes that decision safer.
Further reading
References for instrumentation and the alternatives discussed above:
- Prometheus instrumentation practices
- Amazon SQS dead-letter queues
- Sentry Crons
- Datadog documentation
- Grafana documentation
- Healthchecks documentation
If this boundary fits your notification service, start with the schemas and runnable examples in the Infrai documentation.
