Page on unresolved notification delivery, and keep individual API errors as investigation evidence. An error counter without a delivery outcome cannot tell a fintech responder whether a customer notification still needs attention.
TL;DR: To capture and resolve API errors in a Node.js notification service, connect each failed attempt to the logical notification, record a bounded failure class, and close the investigation only after checking the delivery outcome. The Go example below instruments a caller at the API boundary; it gives a Node.js service a reproducible failing request without requiring JavaScript instrumentation code. It deliberately stops short of claiming that an API acknowledgment proves delivery.
OpenTelemetry describes metrics as measurements of a service captured at runtime, with aggregation across measurements. That makes them useful for finding a pattern; the individual attempt record supplies the context needed to investigate it. The operational recommendation here is to preserve both, while reserving the page for the condition that actually calls for intervention.
How should API error tracking capture unresolved notification failures?
What page fired?
Start the incident review there. A dashboard full of red API requests is an invitation to count the wrong thing: attempts can fail independently of the eventual notification outcome, while an accepted request can still leave delivery unconfirmed. Treat acceptance and delivery as separate states in the application contract. If that contract provides no delivery confirmation, say that the outcome is unknown; do not silently promote an accepted request to a delivered notification.
Consider a hypothetical incident fixture with 12 logical notifications and 30 attempts. Eleven notifications have confirmed delivery, and one remains unresolved at its configured deadline. Those are test inputs, not production measurements. A page that says only “19 failed attempts” leaves the responder to discover whether there are 19 affected notifications, one repeatedly failing notification, or a backlog that has already recovered. The useful page identifies the unresolved population and links to the evidence needed to explain it.
Count logical work.
Don't page on arithmetic alone.
For this runbook, define a notification as unresolved when its delivery requirement remains unmet at an application-owned deadline. Choose that deadline from the notification's purpose, then document who can change it. A threshold copied from an unrelated dashboard is a weak basis for waking somebody, especially when a burst of failed attempts may recover before the delivery requirement is breached. Keep attempt failures visible for diagnosis, but evaluate the page against the unresolved state and its age. This trades some immediacy for better signal quality; where intervention must begin before the deadline, define an explicit earlier condition and test it against recovery scenarios.
Preserve a small evidence record before building the dashboard
Use two related records: a logical notification with its current outcome, and an attempt with its own result. Give each attempt an opaque reference that can be joined to the notification inside the service's restricted investigation store. Include the operation, deployment revision, start time, elapsed duration, failure class, and response status when one exists. These are proposed application fields, not a telemetry standard's mandatory schema.
Keep the metric dimensions much smaller. A fixed operation name and a bounded failure class are enough for this example; notification IDs, recipient addresses, arbitrary exception messages, and response bodies do not belong in those dimensions. OpenTelemetry's metrics documentation explains how attributes distinguish metric streams. An identifier that changes on every request therefore defeats the purpose of grouping attempts into a small set of operational signals. Retain the join reference in controlled evidence storage instead.
The distinction matters in fintech: a useful error record need not contain the message body or the destination. Decide which evidence a responder needs before collecting payloads, and make retention and access part of the implementation review. More data also means more storage, more review work, and more material to search during an incident.
A terminal state deserves its own record.
If successful recovery only increments another counter, the responder still has to infer whether the original notification recovered. Record the transition for the same logical notification, and make the incident view show the latest authoritative outcome alongside the attempt history.
Capture the API boundary with a bounded Go example
This code is a diagnostic caller for a notification API, including one implemented in Node.js. It captures transport failures and unsuccessful HTTP status responses through the same evidence interface. It does not install an exception handler inside the Node.js process; internal exceptions require evidence from that process, joined to the request through an agreed correlation mechanism.
The interfaces below separate aggregate counting from per-attempt evidence. Supply adapters for your telemetry and restricted evidence store, pass a configured HTTP client, and use a fixed operation name. The caller accepts a prebuilt request so authentication, body construction, and the service's request contract remain explicit at the call site.
package deliveryprobe
import (
"context"
"errors"
"net/http"
"time"
)
type Metrics interface {
CountAttempt(operation, class string)
}
type Attempt struct {
Reference string
Revision string
Class string
Status int
Elapsed time.Duration
}
// Evidence must provide a durable write or return an error.
type Evidence interface {
SaveAttempt(context.Context, Attempt) error
}
func Capture(
requestCtx context.Context,
evidenceCtx context.Context,
client *http.Client,
req *http.Request,
reference, revision string,
metrics Metrics,
evidence Evidence,
) error {
started := time.Now()
attempt := Attempt{Reference: reference, Revision: revision}
resp, requestErr := client.Do(req.Clone(requestCtx))
switch {
case requestErr != nil:
attempt.Class = "transport_error"
case resp.StatusCode >= 200 && resp.StatusCode < 300:
attempt.Class = "api_accepted"
default:
attempt.Class = "http_error"
}
if resp != nil {
attempt.Status = resp.StatusCode
if resp.Body != nil {
resp.Body.Close()
}
}
attempt.Elapsed = time.Since(started)
metrics.CountAttempt("notification_submit", attempt.Class)
saveErr := evidence.SaveAttempt(evidenceCtx, attempt)
if requestErr == nil && attempt.Class == "http_error" {
requestErr = errors.New("notification API returned an unsuccessful status")
}
return errors.Join(requestErr, saveErr)
}
This example requires Go 1.20 or later for errors.Join. Configure separate bounded contexts for the request and the evidence write; reusing an already canceled request context for storage can erase precisely the timeout evidence the responder needs. The evidence interface returns an error so a storage failure cannot silently look like successful capture. Monitor that failure path too. The function captures returned errors, rather than panics, and it makes no retry decision.
This approach has limitations. The example classifies every 2xx response as API acceptance, so adapt that classification if the application contract uses a more specific acknowledgment. It closes the response body without reading it and returns no payload, which makes it suitable for this diagnostic boundary, but unsuitable as a drop-in replacement for a caller that needs the response content. Its elapsed duration includes body closure and excludes the evidence write. Keep that meaning when graphing it. The trade-off is deliberate: capturing less content reduces the evidence available for debugging malformed acknowledgments, while keeping recipient data and message bodies out of this diagnostic record. If resolving those errors requires inspecting a structured acknowledgment, use a caller that validates that response against the application contract and records a bounded validation result; this wrapper alone cannot do that job.
Acceptance isn't delivery.
The api_accepted class never updates the logical notification to delivered. That transition belongs to the component that can verify the required delivery outcome. A counter with an encouraging label cannot supply missing evidence.
Verify recovery before enabling the page
Run the capture path against a controlled endpoint before using it with real notifications. Exercise an accepted response, an unsuccessful response, a request deadline, and an evidence-store failure. Check that each attempt increments exactly one result class, that a status is available only when a response exists, and that an evidence failure reaches the caller. Use synthetic recipients and opaque references in the test data.
Then replay the 12-notification fixture through the logical state evaluator. The attempt view should show 30 attempts, while the delivery view should show one unresolved notification. Change that last notification to confirmed delivery and verify that the unresolved condition clears. Also test acceptance without confirmation: the page must remain governed by the delivery requirement. This catches a particularly expensive mistake, where a successful submission clears an incident that still needs work.
Keep the page disabled while evaluating its output alongside the current response process. Inspect every proposed page: what action would the responder take, and does the attached evidence let them take it? Measure recovered-before-intervention cases separately from unresolved cases. No universal count or window follows from the metrics specification; selecting one requires the service's delivery requirements and observed behavior.
For deployment, introduce capture and state evaluation before changing the paging rule. Review evidence completeness and the proposed pages first, then enable the rule through a reversible configuration change. Keep instrumentation failures visible independently so a quiet notification dashboard cannot conceal a broken evidence path.
Roll back the rule without losing the investigation
If the new page fires on recovered notifications, return paging to the previous reviewed configuration and preserve the attempt records for analysis. Keep collection enabled only if its overhead and data handling remain acceptable; otherwise disable the new capture path through its deployment control while retaining already recorded evidence.
Close the postmortem with the delivery outcome, the page that fired, and the missing or misleading evidence that delayed the response. For notification error tracking, the useful result is a responder who can identify unresolved work, explain the failing boundary, and verify recovery. A quieter graph alone does not establish any of those things.
References
- OpenTelemetry, Metrics signal concepts: https://opentelemetry.io/docs/concepts/signals/metrics/
Top comments (0)