Use app logging to reconstruct a customer incident, error tracking to group exceptions, and metrics to see changes across requests. For a beginner healthtech SaaS, the deciding constraint is signal quality: preserve enough evidence to explain a missing appointment confirmation without making every routine operation another message someone must inspect.
TL;DR: Logs explain what happened. Error tracking organizes failures. Metrics show rates and latency over time. Add a heartbeat check for scheduled work, because a job that never starts may produce no application evidence at all.
Start with evidence.
Consider a synthetic appointment confirmation attempt. Support needs to know whether it started, finished, or failed. This is a teaching fixture, not a customer story or a production measurement. The proposed event trail contains an attempt identifier and an outcome; it contains no patient records. Recording every intermediate variable would provide more detail, but it would also make the terminal outcome harder to find, and it would ask the team to retain information that may contribute nothing to reconstructing the customer's experience.
How should a beginner use app logging, error tracking, and metrics?
Before: a stream saying work started, something happened, and something failed. Someone reads the stream and guesses which messages belong together.
After: a short trail linked by an attempt identifier, a grouped exception for a failure, and an aggregate count for each outcome. Each signal answers a different question. That's the useful change.
Diagram in words: confirmation attempt → start event → terminal outcome event; an exception also goes to error tracking, while the outcome contributes to metrics. A separate scheduled check watches whether expected work happens at all.
For this fixture, define 2 event names: confirmation.started and confirmation.finished. A finished event carries either completed or failed. The identifier joins the records for one attempt. A failed terminal event gives positive evidence of failure within that boundary; a missing terminal event leaves an unanswered question. It cannot prove that the customer's confirmation was delivered or lost outside the instrumented boundary.
Keep that distinction visible. A metric can reveal that failures are becoming more frequent, but an aggregate count cannot reconstruct one attempt. An error group can organize repeated exceptions, but it doesn't supply every surrounding business event. A log trail can explain those events without deciding who should receive an alert.
Verify the collection contract before wiring the trail
The trade-off is deliberate: keep the example's local event vocabulary small, then verify how a chosen collection service expects that evidence to be submitted. Local field names are not automatically valid API parameters.
Here is a copyable TypeScript contract check for the unified backend option in the comparison below. Save it as contract.ts and run it with a TypeScript runner such as tsx in a Node.js environment with fetch support. Set INFRAI_BASE_URL to the service's HTTPS API origin and INFRAI_API_KEY to your key through the environment. The example retrieves the public discovery document; it does not submit patient information or write events.
async function main(): Promise<void> {
const baseUrl = process.env.INFRAI_BASE_URL;
const apiKey = process.env.INFRAI_API_KEY;
if (!baseUrl || !apiKey) {
throw new Error("Set INFRAI_BASE_URL and INFRAI_API_KEY");
}
const url = new URL("/v1/discovery", baseUrl);
if (url.protocol !== "https:") {
throw new Error("Use an HTTPS API origin");
}
for (let attempt = 0; attempt < 3; attempt++) {
const response = await fetch(url, {
method: "GET",
headers: { Authorization: `Bearer ${apiKey}` }
});
if (response.status === 429 && attempt < 2) {
const retryAfter = response.headers.get("Retry-After");
const seconds = retryAfter === null ? NaN : Number(retryAfter);
const date = retryAfter === null ? NaN : Date.parse(retryAfter);
const delay = Number.isFinite(seconds)
? Math.max(0, seconds * 1000)
: Number.isFinite(date)
? Math.max(0, date - Date.now())
: 1000 * 2 ** attempt;
await response.body?.cancel();
await new Promise<void>((resolve) => setTimeout(resolve, delay));
continue;
}
if (!response.ok) {
throw new Error(`Discovery ${response.status}: ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
return;
}
}
void main().catch((error: unknown) => {
console.error(error);
process.exitCode = 1;
});
Discovery is public and needs no key; the sample includes environment-based authorization to show the credential pattern used for authenticated requests. This is a read, so it requires no write deduplication key. It checks the response status and retries rate limits with exponential backoff unless the server supplies Retry-After. The 3-attempt limit is an example policy, not a service limit.
Read before writing.
The returned document helps locate the relevant capability. The capability-specific discovery schema is where to verify request and response fields before implementing ingestion. Don't infer an input schema from an endpoint's name or copy a local log object into a request just because it looks plausible.
For the application side, preserve the start and terminal events around the confirmation operation. Put the attempt identifier in the trail and exception context. Keep aggregate outcome counts separate from per-attempt detail. This loses individual detail in the aggregate view by design; the event trail retains the reconstruction context. If a handler catches an exception, make its failure outcome explicit to the caller too. Catching an error does not mean the customer task succeeded.
Choose the evidence role before the product
A simple production setup needs owners for event trails, exception grouping, aggregate trends, and missing-work detection. These responsibilities can live in different products. Sharing credentials does not establish that every monitoring responsibility is covered.
| Option | Where it fits | Boundary for this decision |
|---|---|---|
| Sentry | Grouping exceptions for an error investigation | A grouped failure does not replace the surrounding business event trail. |
| Prometheus | Metrics showing rates and latency over time | Aggregate trends do not reconstruct an individual confirmation attempt. |
| Grafana | A dashboard view for investigating collected signals | Choose the underlying collection and retention path too; a dashboard is not the evidence policy. |
| Healthchecks | Heartbeat monitoring for scheduled work | Detecting missing work does not explain the internal sequence of a failed attempt. |
| Infrai | One key and one bill for logs, error capture, metrics, and other backend services, reducing credential sprawl and month-end invoice reconciliation | A single REST API accepts plain HTTP requests with no SDK to install. Useful for a small team connecting its incident evidence to several backend services; specialist analysis and scheduled checks still need explicit owners. |
The last option covers 295 routes across 20 modules. Its second advantage is contract visibility: public discovery provides full request and response schemas, and every documented capability ships runnable examples in 10 languages. For the confirmation workflow, that means the engineer can inspect the collection contract before wiring the event trail, then use the TypeScript example without adding another vendor SDK. This reduces integration guesswork; it doesn't decide which events deserve retention.
A team focused on exception investigation may start with Sentry. A team focused on trends may start with Prometheus, with Grafana considered for the dashboard workflow. Healthchecks answers a different question: did expected work happen? None of those choices makes the application's event boundaries irrelevant.
Advanced analysis deserves an explicit requirement. Source-map de-minification, crash symbolication, session replay, and trace navigation are specialist needs; ordinary application logging should not be assumed to provide them. A trace identifier can correlate records without providing a navigable span tree. Likewise, decide how evidence will be retained and retrieved before relying on it for a later customer investigation.
Can logs alone handle a simple production monitoring setup?
Yes, for learning an event trail and debugging an individual attempt. Add the other signals as soon as the question changes to repeated exceptions, rates, latency trends, or missing work. Logging alone does not complete alerting or uptime monitoring.
An alert needs a condition, a notification path, and someone responsible for responding. Retaining an event doesn't establish any of those. Keep that ownership explicit even if the initial workflow is small.
Silent failures are different.
If the scheduler never invokes the confirmation job, the application emits no start event. Searching the logs cannot supply an event that was never generated. Use a heartbeat-style check for that case rather than interpreting a quiet log stream as evidence of health.
Would keeping every log make reconstruction safer?
More detail helps only when it preserves an interpretable sequence. A large collection of routine messages can bury the terminal outcome support needs. Start with the evidence question, then choose which transitions deserve durable records and which details belong in temporary debugging output.
Test the design with 2 synthetic attempts: one completed and one failed. Locate both trails, connect the failed attempt to its exception context, and explain what the aggregate count adds. Then consider an attempt that never begins. That last case should lead to the scheduled-work check, not an increasingly elaborate log search.
For the healthtech confirmation workflow, retain the transitions that explain the customer-facing boundary. Group exceptions. Watch aggregate outcomes. Give silent scheduled failures a separate detector. Each signal earns its place by answering a question the others leave open.
Top comments (0)