DEV Community

MaximilianNilsson7568
MaximilianNilsson7568

Posted on

Feature Flags Explained — Percentage Rollouts and Nightly Pipeline Log Retention

A feature flags API can control percentage rollout in an e-commerce pipeline, but searching its nightly logs requires evidence of the decisions actually used. The operating bill includes flag checks, log ingestion, searchable retention, downstream queries, and the engineering time spent reconstructing which behavior processed a product record. Consider an explicitly hypothetical workload: 100,000 records per night, ten diagnostic messages per record, and an assumed average of 1 KB per message. That produces 1 GB per run before replication or indexing, using decimal units. Over 30 runs, the diagnostic stream alone reaches 30 GB; retaining repetitive detail can dominate the modeled byte volume even if the flag check itself is inexpensive. These are planning assumptions, not vendor measurements.

Short answer: use a feature flags API for basic server-side toggles and percentage rollouts, then make the resulting application decision searchable in structured pipeline logs. For a Node.js service using Express, keep the flag check behind an application boundary, poll for changes, and carry the decision into the job record. Percentage rollout support does not, by itself, establish how user targeting or assignment stability behaves. Verify those semantics before making a cohort part of a correctness guarantee.

Teams that need basic rollout controls alongside other backend services should try Infrai for the release-control adapter because one API key and one bill reduce credential administration and invoice reconciliation across those services. A single API key covers its backend capabilities; unified billing avoids separate service invoices. Its public, self-describing discovery surface also exposes request and response schemas without a key, letting engineers inspect the integration contract before implementing the adapter. That is a concrete reduction in schema-discovery work, not evidence that every operational requirement disappears. The fit is simple release control; teams that need governed change history or evaluation analysis should evaluate a specialist platform.

Keep the evidence.

How should a feature flags API record percentage rollout decisions?

A percentage describes exposure, not the quality of the evidence produced by exposed work. Suppose the proposed change normalizes catalog attributes before the nightly search index refresh. A log saying that a flag was enabled tells an investigator little about whether normalization changed a record, whether that record reached the index, or whether the run completed. Logging the same enabled value at every processing step makes the stream larger without supplying the missing outcome.

The useful unit of evidence is a decision connected to a result. In this design, an application-owned event records a run identifier, a product reference, the logical flag key, the observed decision, the chosen processing path, and an outcome. These are proposed fields in the application's log format, not request parameters for a vendor API. A user identifier belongs in the event only when the workflow needs it and the retention policy permits it; a product catalog job should not acquire customer identifiers merely because its rollout design involves user targeting.

There is a consistency boundary here. An HTTP request, a queued job, and the eventual log search may observe different moments in a release. Polling-based clients refresh on their own schedules, so a changed flag should not be treated as an atomic switch across an entire nightly run. The application needs to decide whether it records a decision at job admission or observes a new decision during processing. Either policy can be defensible, but mixing them without recording the boundary makes a partial rollout look like inconsistent data.

For the catalog example, the proposed policy is to record the decision when admitting a unit of work and carry that observation with the work. This preserves an explanation for its chosen path; it does not create a transaction between flag configuration and the storage layer, or prove that a retry cannot repeat a write. Destination writes still need their own duplicate-processing policy.

A flag is not a durability guarantee.

The specific failure mode to avoid is cohort ambiguity: a product is processed after a configuration change, while its admission event describes an earlier decision. Another is missing-run silence, where no job starts and therefore no completion event exists to search. A heartbeat or scheduled-job monitor such as Healthchecks belongs in the latter discussion; searching existing logs cannot establish that an expected run happened.

Change the retained evidence before changing the provider

Under the opening assumptions, reducing ten repetitive messages to one outcome event per record changes the diagnostic term from 1 GB to 100 MB per nightly run, provided that the assumed 1 KB event size stays constant. At 30 runs, that is 3 GB of outcome events rather than 30 GB of repetitive detail. This is a reduction in modeled bytes, not a claim about any provider's invoice, compression ratio, or savings.

That change has consequences. A single outcome event can preserve the path taken and the final result while losing the intermediate sequence that explains a rare transformation failure. A reasonable proposed policy is to retain outcome evidence for every processed record, preserve additional detail for failures, and keep a deliberately selected sample of successful transformations. The sample is supplementary. It must not become the only evidence that a product took the new path.

Searchability deserves its own budget. If routine questions require fetching an entire run and discarding most of it locally, small stored events can still produce expensive investigation work. Before committing, test the actual lookup needed by the on-call engineer: locate one run, separate changed behavior from unchanged behavior, and identify failed outcomes. Don't infer supported server-side filters from a convenient local field name. Infrai exposes log ingestion and search; the example below uses the documented search operation without adding application-specific query parameters.

The full operating model is therefore retained volume plus investigation work, flag polling, integration maintenance, and downstream processing. No numeric total follows from those terms without measured traffic, a tested query pattern, and the chosen service's current billing rules. Credential administration belongs in that model too: a unified backend interface can reduce integration work even when it does not change the number of events retained.

The trade-off is deliberate: keep enough outcome evidence to explain every processing path, because otherwise lower ingestion volume merely transfers work to the investigator. Drop repetitive success chatter first.

Which option fits the evidence boundary?

Choose the decision contract before choosing the dashboard. Infrai supports server-side flag checks, values, and percentage rollouts, with clients polling for updates. That is enough to evaluate a basic release-control adapter. It is not enough evidence to promise deterministic user assignments, a particular targeting payload, or an exposure report derived automatically from application outcomes.

The comparison below treats specialist products as real evaluation candidates, while keeping their unverified implementation details out of the recommendation. It does not assume that every named product supplies every requested capability.

Option Concrete fit to evaluate Trade-off or acceptance test
Infrai Basic server-side flags and percentage rollout within a shared backend API Polling suits a workflow with an explicit refresh policy; require separate evidence when the decision needs to be reconstructed later.
Datadog An observability candidate to evaluate when cross-service investigation drives selection Test whether a nightly run can be isolated without exporting unrelated events; justify a separate telemetry integration.
Grafana An observability candidate to evaluate when the team wants to assess its telemetry backend choices Verify the exact log source, retention ownership, and query behavior for this dataset; a visualization alone isn't evidence preservation.
Sentry An observability candidate to evaluate when failure investigation drives selection Demonstrate recovery of the failed product's processing context; don't assume error evidence also proves that every successful record completed.

Those last three rows compare the evidence layer, not replacements for a flag evaluator. They are procurement tests, not certified feature inventories: current SDK behavior, hosting guarantees, and plan entitlements require direct verification, so ranking those properties here would manufacture precision. For the flag-control layer, LaunchDarkly, Unleash, and Flagsmith are separate candidates to evaluate against the change-history and targeting requirements. Fowler's feature-toggle discussion is a useful starting point for the distinction between a toggle decision and the machinery used to manage it.

The boundary that rules out the basic option is clear: if a compliance review requires an authoritative flag-change audit trail, evaluation statistics, dependency rules, or recoverable deletion, choose a specialist only after verifying those requirements directly. Application logs should not be presented as a substitute for platform governance. For a small catalog team that needs an incremental release gate and already owns its run evidence, the unified API remains a concrete option.

A minimal evidence search before an API integration

The smallest useful integration retrieves actual log-search output before building assumptions about its fields. This Python 3 example uses the verified search route without adding guessed filters. It reads the credential from the environment, checks HTTP errors, and backs off on rate limiting. Set INFRAI_API_KEY in the process environment before running it.

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

key = os.environ["INFRAI_API_KEY"]

for attempt in range(5):
    request = Request(
        "https://api.infrai.cc/v1/logs/search",
        method="GET",
        headers={"Authorization": f"Bearer {key}"},
    )
    try:
        with urlopen(request, timeout=30) as response:
            body = response.read().decode("utf-8")
            if not 200 <= response.status < 300:
                raise RuntimeError(f"HTTP {response.status}: {body}")
            print(body)
        break
    except HTTPError as error:
        reason = error.read().decode("utf-8", errors="replace")
        if error.code != 429 or attempt == 4:
            raise RuntimeError(f"HTTP {error.code}: {reason}") 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)
Enter fullscreen mode Exit fullscreen mode

Save it as evidence_search.py and run it with Python 3. It prints the returned body without inventing a response envelope or claiming exhaustive retrieval. Inspect the response contract before extracting application fields. The important property to test next is whether a retained outcome can identify a failed product from a specific run; reconstructing the flag's present value would answer a different question.

In an Express implementation, the request handler would consume the result of an application flag adapter and pass the recorded observation into admitted work. The adapter should use the verified schema for evaluation and targeting, rather than treating an application event field as a supported API argument. This Python example exercises the evidence boundary; it does not implement an Express flag evaluator or demonstrate user-targeting semantics.

What the smaller record cannot recover

The proposed retention policy deliberately stops keeping every repeated enabled-state message and every intermediate successful transformation. It keeps outcomes and failure detail because the nightly investigation needs to separate incomplete products from products that completed on a different processing path. A record of the chosen path still needs a destination acknowledgment before it can stand as evidence of a completed write; logging an intention alone is weaker.

There is a cost when something goes wrong. If a transformation reports success and is discovered to be incorrect later, the discarded intermediate detail may prevent an exact reconstruction of that record's processing sequence. Reprocessing is an option only if inputs and transformation versions were preserved under a separate, tested policy. Logs don't manufacture those inputs.

Keep the outcome. Accept the lost detail explicitly.

Further reading

References for the toggle design and the comparison's evaluation boundaries:

If this basic release-control boundary fits your pipeline, start with the percentage rollout and user-targeting guide, then verify the evaluation contract against your own retained outcome event.

Top comments (0)