DEV Community

TheodorHawkins9251
TheodorHawkins9251

Posted on

Retaining Pricing Evidence — Feature Flags, Stale Cache, and Polling Interval Decisions

For an e-commerce pricing rollout, the observability bill covers both polling feature flags and retaining evidence that explains a stale cache or a client/server mismatch. For a hypothetical workload of 1,000,000 checkout decisions per day, an application exposure record averaging 500 bytes produces 500 MB per day before indexing, replication, or compression. Keeping that payload for 30 days means 15 GB; keeping it for seven means 3.5 GB. Those are planning assumptions, not vendor measurements. Log ingestion and retained data belong in separate budget lines: Amazon CloudWatch documents per-GB ingestion charges, so deleting a record sooner does not undo the ingestion that already happened.

TL;DR: For a new pricing rule behind a feature flag, retain compact application-side decision records, use short polling selectively for critical decisions, and reconstruct browser/server disagreements from the states each actually observed. Polling permits stale reads. A current flag value cannot establish which rule priced an earlier checkout. Reduce the bytes written per decision before shortening the evidence window.

What evidence explains stale feature flags between client and server?

Start with the question support will ask after a disputed order: which pricing rule did the server apply, and why did the browser show something else? A flag configuration retrieved during the investigation answers a different question. Even if its current value is correct, a browser that refreshed earlier and a server that refreshed later can temporarily disagree; changing their polling intervals changes that opportunity for disagreement without producing a historical record of either decision. This is eventual consistency with a commercial consequence, because the visible offer and the accepted charge can reflect different observations.

Keep both observations.

A snapshot isn't history.

The proposed application record should carry an opaque checkout correlation identifier, the execution surface, the flag key, the value actually used, an application rule revision, the decision time, and the last successful flag-fetch time. These are application-defined fields, not a claimed flag-service response schema. The revision identifies the pricing implementation; a Boolean alone cannot distinguish two implementations that both ran while the flag was enabled. Capture the server decision at the point where the pricing rule is applied, and capture the browser observation separately if reconstructing the displayed offer is within scope.

A refresh failure and an ordinary polling gap deserve different names. With an ordinary gap, the cached value reflects a successful but older fetch; after refresh failures, the age of that last successful fetch keeps growing, so the configured interval is no longer a useful bound on freshness. Log the successful-fetch timestamp, rather than stamping the cache with the latest attempted refresh. Otherwise a stale observation acquires a misleadingly recent date.

Do not confuse these records with proof of what a human saw. A browser-side decision record establishes what the application reported using. Establishing that an offer rendered needs an explicit application event, and establishing what was charged needs the authoritative order record. Treat these as separate facts joined by the checkout identifier, with a recorded distinction between observations and completed business actions.

Move the ingestion term before trimming retention

For the same hypothetical million decisions, replacing a 2,000-byte diagnostic payload with a 500-byte exposure record changes raw ingestion from 2 GB to 500 MB per day. The change comes from the record design, not from dropping customers out of the sample. No claim about a particular vendor's bill follows from those byte counts: indexing behavior, compression, retention charges, and other services still need their own accounting. The useful conclusion is narrower. Payload size affects every retained decision.

Proposed control Term it changes What incident reconstruction gives up
Keep a compact exposure envelope instead of the whole request Bytes ingested for each decision Request context omitted from that envelope
Retain every pricing decision, but sample low-risk UX diagnostics Number of diagnostic records written Complete histories for the sampled UX behavior
Shorten detailed diagnostic retention while keeping decision evidence Retained diagnostic volume Older detailed explanations of execution
Poll critical pricing flags more frequently Flag-fetch request volume and freshness opportunity Additional request budget; still no atomic browser/server update

The risky shortcut is to retain only mismatches. Detecting a mismatch requires both sides to be observable in the first place, while a customer complaint can arrive after the application has stopped considering that checkout interesting. For a high-risk pricing release, keep the compact decision stream in your own logs or analytics layer and make any sampling decision about the larger diagnostic context separately. This is a proposed evidence policy, not a claim that a flag product automatically generates it.

Retention is a durability decision too. A successful local write, a log collector receiving a line, and a record surviving until the investigation date are different milestones. Define the acknowledgment and retention guarantees required from the chosen sink, then test them before treating an exposure record as durable evidence. A configuration screen with a retention number does not, by itself, prove that the disputed checkout's record arrived.

A small reconstruction example with two observations

This Python example uses standard-library modules only. Set INFRAI_API_BASE to your configured v1 API base and INFRAI_API_KEY to your credential; the first operation fetches the current flag snapshot with an explicit GET and bounded retries for rate limiting. It prints the response without assuming an undocumented response shape. The remaining data is synthetic: two application observations of the same flag, with 30-second and 120-second polling intervals that illustrate application choices rather than product defaults. All observation field names belong to the application's envelope.

import json
import os
import time
from datetime import datetime
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.request import Request, urlopen

def fetch_snapshot():
    base = os.environ["INFRAI_API_BASE"].rstrip("/")
    request = Request(
        base + "/flags/get_all",
        headers={"Authorization": "Bearer " + os.environ["INFRAI_API_KEY"]},
        method="GET",
    )
    for attempt in range(4):
        try:
            with urlopen(request, timeout=15) as response:
                if response.status != 200:
                    raise RuntimeError(f"Unexpected status: {response.status}")
                return json.load(response)
        except 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
            retry_after = error.headers.get("Retry-After")
            delay = 2 ** attempt
            if retry_after:
                try:
                    delay = max(delay, float(retry_after))
                except ValueError:
                    retry_at = parsedate_to_datetime(retry_after).timestamp()
                    delay = max(delay, retry_at - time.time())
            time.sleep(delay)

print(json.dumps({"current_snapshot": fetch_snapshot()}, sort_keys=True))

def timestamp(value):
    return datetime.fromisoformat(value.replace("Z", "+00:00"))

observations = [
    {
        "checkout_id": "synthetic-checkout-42",
        "surface": "browser",
        "flag_key": "pricing_rule_enabled",
        "value_used": False,
        "rule_revision": "pricing-v1",
        "decided_at": "2026-11-09T12:01:30Z",
        "last_successful_fetch_at": "2026-11-09T12:00:00Z",
        "poll_interval_seconds": 120,
    },
    {
        "checkout_id": "synthetic-checkout-42",
        "surface": "server",
        "flag_key": "pricing_rule_enabled",
        "value_used": True,
        "rule_revision": "pricing-v2",
        "decided_at": "2026-11-09T12:01:31Z",
        "last_successful_fetch_at": "2026-11-09T12:01:20Z",
        "poll_interval_seconds": 30,
    },
]

for observation in observations:
    age = timestamp(observation["decided_at"]) - timestamp(
        observation["last_successful_fetch_at"]
    )
    observation["cache_age_seconds"] = int(age.total_seconds())
    print(json.dumps(observation, sort_keys=True))

browser, server = observations
print(json.dumps({
    "checkout_id": server["checkout_id"],
    "flag_values_disagree": browser["value_used"] != server["value_used"],
    "rule_revisions_disagree": (
        browser["rule_revision"] != server["rule_revision"]
    ),
}, sort_keys=True))
Enter fullscreen mode Exit fullscreen mode

The browser observation is 90 seconds old; the server observation is 11 seconds old. That establishes different observation ages and values. It does not establish the exact time the flag changed, prove a failed refresh, or show that an order was accepted. Those conclusions require additional evidence. Clocks matter as well: cross-surface ordering needs a defined clock strategy, whereas correlation by checkout identifier avoids pretending that adjacent timestamps alone establish causality.

The example prints records for inspection. A production implementation must send them to its chosen evidence sink, define behavior when recording fails, and decide whether a high-risk pricing decision may proceed without the required evidence. Failing closed preserves an evidence requirement at the expense of checkout availability; proceeding preserves availability while accepting a gap in reconstruction. Make that trade-off explicit before launch.

Compare the evidence boundary, then the flag service

The useful comparison is between what a candidate can prove about this checkout and what the application must retain itself. LaunchDarkly, Unleash, and Flagsmith are real alternatives to evaluate for feature management; their documentation should anchor a version-specific review, rather than assuming that a product name guarantees an immutable exposure ledger or identical browser and server refresh behavior. The table identifies different investigation priorities, not a benchmark ranking or a claim of verified feature parity.

Candidate Focus of the evaluation Boundary for this pricing rollout
LaunchDarkly Compare its documented SDK update behavior with the required pricing freshness window Require an application decision record even if configuration delivery meets that window
Unleash Review the selected deployment and client configuration as part of the evidence path Establish who owns refresh health and retained records in that deployment
Flagsmith Check the selected evaluation mode against browser and server observations Demonstrate how an actual applied rule can be joined to the order record
Amazon CloudWatch Evaluate a log sink's ingestion and retention accounting Logs can hold evidence; collecting a line does not make a flag update synchronous
Sentry Prefer error-centered investigation when the disputed decision accompanies an exception A successfully executed wrong price still needs an explicit exposure record
Datadog Prefer a shared observability investigation when the pricing path crosses several services Scope ingestion and retained context to the reconstruction question
Grafana Prefer investigation around the team's selected telemetry data sources Establish retention and durability at the underlying evidence store

Infrai is a reasonable candidate where one REST API and one key provide a stable capability contract: swapping the vendor behind a capability doesn't change the application code that uses that contract. Public self-describing discovery provides request and response schemas for checking the integration boundary. For this polling-based workflow, keep application-side exposure evidence and a separate configuration-change ledger, treat flags as independent controls, and protect deletion through your own operational policy. Simple gradual rollout is the suitable boundary; evidence-intensive release governance needs additional systems.

The same boundary applies to the observability design. Use a dedicated system for alert delivery, span-tree investigation, source-map decoding, crash symbolication, session replay, and heartbeat checks when the workflow requires them. Keep subject-level deletion and archival/export obligations in a storage layer whose documented controls meet those obligations. Build any required filtering into that evidence design rather than guessing query parameters. These are selection requirements, not incidental implementation details.

Decide what to stop keeping

A defensible starting policy is to retain every compact pricing exposure for the agreed dispute-investigation window, keep larger diagnostic context for a shorter operational window, and let low-risk UX flags poll less frequently than the pricing control. Choose the windows with the people responsible for orders and investigations. Seven days and 30 days illustrate volume arithmetic above; neither is a universal retention recommendation, especially for a US/EU application with its own privacy and recordkeeping obligations.

Stop keeping full request payloads merely to explain a Boolean decision. Retain the rule revision, actual value, correlation identifier, surface, and successful-fetch timestamp instead. After the detailed context expires, an investigator may still establish which pricing rule ran but lose the inputs needed to explain why a particular branch was selected; retain the specific necessary inputs if that explanation is a requirement, with an explicit data-handling policy.

That loss is real.

Don't hide it.

A smaller record earns its place only if it can answer the incident question. Before rollout, reconstruct one synthetic browser/server disagreement from retained evidence, confirm that the authoritative order can be joined, and test what remains after detailed diagnostics expire. Accept the retention boundary only after seeing the explanation it can still support.

Further reading

References for the competing products and log-ingestion accounting; verify the chosen deployment and SDK version before relying on update or retention behavior.

Top comments (0)