Use a simple metrics dashboard API for checkout counters, latency, and errors, and preserve the applied pricing rule with the business decision before rolling out a new rule behind a flag. The deciding constraint is incident reconstruction: the graph should locate the interval to investigate, while the order record should explain the price after the flag has changed again.
TL;DR: For an e-commerce SaaS app, send aggregate product and performance measurements through a small HTTP interface, retain decision evidence in the application's durable store, and run threshold polling and notification routing separately. Choose the dashboard by the investigation it supports. A current flag value cannot explain a historical checkout.
Infrai offers a plain REST API with no SDK to install, a single key for metrics, logs, and flags, and a single bill for those services. Any language that can send HTTP requests can call it, so a Node.js backend can use its existing HTTP facilities for counters and latency measurements. The shared credential and consolidated billing reduce credential and invoice administration across the pricing workflow. This unified API brings multiple backend capabilities under one API with consistent conventions.
The shared interface spans 295 routes across 20 modules. Public discovery supplies request and response schemas without requiring a key, allowing the team to inspect the reporting contract before provisioning credentials. These conveniences don't establish an atomic commit across operations.
Keep the receipt.
The architecture decision below treats metrics as an index into evidence. That is a narrower job than storing the evidence itself, and the distinction determines where consistency and durability have to live.
What must survive a pricing flag rollback?
The invariant is that an accepted pricing decision remains explainable after configuration changes. In this proposed design, each checkout decision retains the rule revision actually used, the evaluated flag result, a release identifier, and an application correlation identifier. These are application fields, not a claimed telemetry request schema. Store the record alongside the business state whose price it explains, under the application's own access and retention requirements.
Consider the illustrative release pricing-r17, revision 17, and two cohorts, control and candidate. Count pricing evaluations and pricing errors; record calculation duration with an explicit unit. Keep the individual checkout identifier in the decision record instead of turning every order into a metric dimension. The aggregate dashboard answers whether candidate traffic changed around the release. The durable record answers why one checkout received one price. Prometheus's naming guidance is useful here because names and units tend to outlive the first dashboard implementation.
Those answers differ.
Preserve both clocks.
A rollback exposes the trap particularly clearly: querying the flag after rollback returns the configuration available then, which cannot substitute for the result used earlier. Likewise, a mean latency can move while the evidence for a particular slow decision remains elsewhere. The reconstruction path therefore starts with the retained decision and follows its correlation identifier outward to supporting observations; it doesn't infer the applied rule from a graph's shape or from today's configuration.
For an EU/US application, add processing location, permitted data fields, retention, and evidence retrieval to the acceptance criteria. This comparison establishes no residency guarantee for any option. A region label on a dashboard is insufficient evidence for the location of every associated record.
Invariants and failure boundaries
There are three distinct boundaries: committing the checkout decision, handing off its telemetry, and observing the reported measurements. A business commit followed by a process interruption can leave a missing measurement; retrying an ambiguous write can double a counter; collecting an observation later can put it in the wrong investigative interval if collection time replaces decision time. These are application architecture failure modes. A successful HTTP response alone doesn't resolve them.
An outbox addresses the handoff boundary by committing the decision and the pending reporting work together. The worker then delivers the measurement independently, preserving a stable identity for retries and retaining enough state to distinguish pending work from acknowledged work. This introduces a queue to operate and delayed visibility to explain. For reconstruction, that is usually an acceptable trade: a delayed graph is easier to interpret than a graph whose apparent completeness hides lost business evidence. In the proposed checkout example, a delayed observation must still lead back to revision 17 even if the operator has already restored the control rule; preserving decision time and reporting time separately lets an investigator explain the lag without attributing the old decision to the new configuration.
Retry identity has a lifetime. The reporting service's platform convention specifies a default deduplication window of 24 hours, so a worker design must account for delivery attempts that outlive that window instead of assuming a stable key prevents duplicates forever. Establish the selected write operation's idempotency contract before enabling retries. Local deduplication and remote deduplication solve different boundaries.
Threshold evaluation and notification routing belong in an external polling process for the simple metrics approach. Keep distributed trace investigation, source-map processing, session replay, and missed-job monitoring as separate selection requirements; use a tracing system or a healthcheck/heartbeat tool when those investigations are part of the job. Logs with correlation identifiers can support a join, but they don't by themselves establish a distributed span tree.
Treat the application decision record as the audit evidence for the flag result and applied rule, and design its retention, authorized deletion, and retrieval independently of the dashboard. For this rollout, keep flag refresh polling separate from recording the value actually evaluated. Neither a later configuration read nor an aggregate evaluation counter replaces the original decision evidence.
How should a SaaS app metrics dashboard API connect counters, latency, and errors?
The useful comparison starts with the first question after a release: did pricing evaluations, latency, or errors change? It then asks a harder question: can the retained evidence explain the exact rule used for a selected checkout after rollback? Treat the second question as an acceptance exercise rather than awarding it to whichever product has the most attractive chart.
| Option | Reason to evaluate it for this rollout | Trade-off and acceptance boundary |
|---|---|---|
| Simple REST metrics service | Small KPI and performance dashboards receiving counters, gauges, and latency-style numeric series from the backend. Public schemas help define the reporting contract before implementation. | The application renders its admin charts from query results and owns external alert polling. Keep historical pricing decisions in application storage. |
| PostHog | Start with its product analytics documentation when the investigation is primarily about customer behavior around the candidate pricing rule. | Test the required operational measurements and checkout evidence lookup explicitly; a behavioral view does not establish the decision's commit boundary. |
| Grafana Cloud | Start with its observability documentation when pricing metrics are one part of a broader operational investigation. | Specify the ingestion, correlation, and retention workflow the team will operate. A broader investigation requirement can justify more integration work. |
| Better Stack | Review its telemetry and uptime documentation when the buying decision includes operational investigation and monitoring. | Demonstrate the evidence retrieval path for a selected checkout. An uptime observation and a retained pricing decision answer different questions. |
These are selection criteria, not measured rankings of throughput, durability, or regional coverage. The three named alternatives deserve an actual workflow demonstration, using their primary documentation, before a purchase decision. None of them removes the need to define which business record is authoritative.
For the acceptance exercise, retain one candidate checkout, change the flag, and reconstruct the original price using only retained evidence. Then repeat with a delayed telemetry observation and a repeated delivery attempt. The expected outcome is the same applied revision and one identifiable reporting operation, with delay visible rather than silently reinterpreted as a new business event. This is a proposed test dataset, not a report of a production incident or a vendor benchmark.
Don't infer causality.
Delivery isn't completeness.
The resulting choice can be modest. If aggregate counters and performance charts answer the operational question, a small metrics API is enough for the dashboard layer. If investigators require behavioral analysis, trace navigation, or monitoring workflows as part of the same interface, evaluate the corresponding broader option against that explicit requirement.
The critical path is a durable decision, then a handoff
The dashboard's read boundary can be exercised without inventing filters. Set INFRAI_API_BASE_URL to the documented HTTPS API base ending in /v1, and set INFRAI_API_KEY to your credential; this Python standard-library client explicitly makes a GET request, prints the returned JSON without assuming its shape, and retries rate limiting with bounded exponential backoff. It honors both forms of Retry-After. Other HTTP errors retain their status and response body so an operator can diagnose them.
import json
import os
import time
import urllib.error
import urllib.request
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
base = os.environ["INFRAI_API_BASE_URL"].rstrip("/")
if not base.startswith("https://") or not base.endswith("/v1"):
raise ValueError("Use the documented HTTPS API base ending in /v1")
request = urllib.request.Request(
base + "/metrics/query",
headers={
"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"],
"Accept": "application/json",
},
method="GET",
)
for attempt in range(4):
try:
with urllib.request.urlopen(request, timeout=15) as response:
result = json.load(response)
print(json.dumps(result))
break
except urllib.error.HTTPError as error:
body = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {body}") 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)
delay = max(
delay,
(retry_at - datetime.now(timezone.utc)).total_seconds(),
)
time.sleep(delay)
This is a read, so it cannot double-apply a counter. The maximum of four attempts is an example client policy, not a service limit; a remote write worker also needs its documented idempotency contract. No successful read proves that every checkout has been reported.
The minimal implementation worth showing is the transaction boundary, because a metrics request cannot repair a decision record that was never committed. The Python program below uses only the standard library and an in-memory SQLite database, so it is runnable without credentials or a vendor-specific payload. It illustrates the local commit and a duplicate decision attempt; it is not a complete checkout or a remote telemetry client.
Every field in the example belongs to the application. The stored duration is an illustrative input of 12 milliseconds, not a measurement of an API's latency. The pending record is a local reporting instruction, not a promised batch format.
import json
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE pricing_decisions (
checkout_id TEXT PRIMARY KEY,
evidence TEXT NOT NULL
);
CREATE TABLE reporting_outbox (
operation_id TEXT PRIMARY KEY,
checkout_id TEXT NOT NULL,
payload TEXT NOT NULL,
state TEXT NOT NULL DEFAULT 'pending'
);
""")
def commit_decision(checkout_id, evidence):
encoded = json.dumps(evidence, sort_keys=True)
with db:
existing = db.execute(
"SELECT evidence FROM pricing_decisions WHERE checkout_id = ?",
(checkout_id,),
).fetchone()
if existing is not None:
if existing[0] != encoded:
raise ValueError("Checkout already has a different decision")
return
db.execute(
"INSERT INTO pricing_decisions VALUES (?, ?)",
(checkout_id, encoded),
)
db.execute(
"INSERT INTO reporting_outbox "
"(operation_id, checkout_id, payload) VALUES (?, ?, ?)",
("pricing-decision:" + checkout_id, checkout_id, encoded),
)
decision = {
"release_id": "pricing-r17",
"rule_revision": 17,
"candidate_enabled": True,
"cohort": "candidate",
"correlation_id": "example-checkout-1042",
"calculation_duration_ms": 12,
"pricing_error": False,
}
commit_decision("checkout-1042", decision)
commit_decision("checkout-1042", decision)
rows = db.execute(
"SELECT operation_id, payload, state FROM reporting_outbox"
).fetchall()
assert len(rows) == 1
print(json.dumps({"operation_id": rows[0][0], "state": rows[0][2]}))
db.close()
Within this local transaction, either both inserts commit or neither does. Repeating the same decision creates no second outbox row; attempting to replace it with conflicting evidence raises an error. Production storage must supply the required persistence, concurrency control, and recovery behavior, and the order mutation must share the intended business transaction. An in-memory demonstration makes no durability claim.
The reporting worker is the next boundary. Map pending records to the documented metrics write schema, aggregate where appropriate, and preserve the reporting operation's identity across retries. An acknowledgment advances the outbox state; an ambiguous response leaves work requiring reconciliation. Keep the evidence even after reporting succeeds, because a measurement's delivery status does not determine how long a checkout decision needs to remain explainable.
The admin dashboard reads reported measurements through queries. Define the charts and prove their required query behavior in an acceptance test before committing to the interface; this example deliberately supplies no remote filter names or write fields. For threshold monitoring, let a separate poller evaluate query results and route notifications, with its own handling for stale observations. An unchanged graph alone cannot distinguish quiet traffic from a stopped reporting worker.
Rejected option and when it becomes reasonable
Reject a dashboard-only record of the rollout. Saving the current flag value beside a chart leaves the reconstruction dependent on mutable configuration, while aggregate counters cannot establish which decision produced an individual checkout's price. More visual detail doesn't repair that evidence boundary.
A dashboard-only approach is reasonable for a disposable experiment in which aggregate behavior is the entire question and individual pricing reconstruction is explicitly outside the requirements. For an accepted checkout that may later need explanation, retain the decision first and choose the dashboard around the observations investigators actually need. The rejected option is smaller. Its evidence obligation is smaller too.
References
- Prometheus, metric naming best practices: https://prometheus.io/docs/practices/naming/
- PostHog documentation, for evaluating product analytics workflows: https://posthog.com/docs
- Grafana Cloud documentation, for evaluating broader observability workflows: https://grafana.com/docs/grafana-cloud/
- Better Stack documentation, for evaluating telemetry and monitoring workflows: https://betterstack.com/docs/
Top comments (0)