A nightly catalog pipeline needs to explain which behavior processed a batch, even after an operator changes a feature flag through an API. TL;DR: For feature flags in Node.js with API support, separate configuration changes from evaluation, pin each batch to an immutable configuration revision, and emit structured decision evidence alongside the batch outcome. Search by run, revision, and decision source before counting errors. A green dashboard cannot reconstruct a missing decision.
For a bounded production review exercise, I would take one catalog import, one flag controlling a new normalization path, and one question: what page fired? This is a proposed investigation, not a reported incident. Suppose the page concerns a batch that did not complete; the useful evidence must connect its outcome to the decision that actually selected its processing path, including any fallback. The flag's current value cannot answer that historical question.
Preserve the decision.
The invariant is narrow: a completed unit of work should remain attributable to the configuration and evaluation result it used. This article treats that as an evidence-design problem, with signal quality versus noise as the deciding trade-off.
What page fired, and can the logs explain it?
Begin the postmortem with the alert condition and its affected work. For this example, define a completion deadline for each nightly catalog import and page when required work misses it; keep the actual deadline in the pipeline's operational policy. A count of flag evaluations is supporting evidence, not a definition of a successful import. If a dashboard shows healthy evaluation traffic while required batches remain unfinished, the dashboard has answered the wrong question.
Give each run a stable identifier.
Carry it through batch processing, retries, and the outcome event, then include a batch identifier, flag key, configuration revision, selected variant, and decision source wherever the decision needs to be reconstructed. Treat those names as a proposed application schema. They are not standardized logging field names. Avoid putting customer details or catalog payloads into decision records merely because those fields are available.
OpenTelemetry's logs documentation describes structured logs and correlation with traces and spans. That supports the transport and correlation model; it does not choose your application's flag schema or establish which catalog outcome deserves a page. Those are contracts the team must define. Preserve trace context when available, but retain run and batch identifiers so a responder can follow scheduled work without depending on a particular trace being present.
The concrete search sequence should be reproducible: find the missed run, identify its incomplete batches, inspect their decision revisions, and compare outcomes for the selected variants. Search fallback decisions separately. Mixing explicit disabled decisions with fallback-to-disabled decisions hides a control-path problem behind an apparently ordinary value.
How should Node.js feature flags use API support?
For a Node.js implementation, make the API responsible for validated, authorized configuration changes and revision history. Have the worker obtain an accepted snapshot before starting its batch, evaluate against that snapshot, and attach the resulting decision to the work context. Carry that context into asynchronous processing instead of consulting mutable global configuration whenever a log statement runs. The code below expresses the contract in Go; the same inputs and outputs belong at the Node.js worker boundary.
There are three useful alternatives, and they produce different evidence. Evaluating through a remote request for every item permits frequent changes, but introduces another failure decision into the processing path and makes attribution more granular. Reading a mutable local cache reduces those requests, but can still split a batch across revisions unless evaluation captures a snapshot. Pinning a revision for the batch makes its behavior easier to explain, while delaying ordinary changes until the next boundary. Choose that delay deliberately.
For this catalog pipeline, prefer the batch boundary when consistent normalization within a batch matters more than immediate configuration adoption. Define a separate emergency-stop mechanism if operations require immediate interruption; record where work stopped and make the resume policy explicit. Pretending a pinned snapshot also provides instant interruption leaves an operational promise the implementation cannot keep.
The control API should reject malformed changes before publication, require the caller's expected revision when changing existing configuration, and retain the actor and reason for accepted changes. Specify what a stale revision response means so an automated client does not blindly overwrite an operator's intervention. A successful configuration write means a new revision was accepted; it should not imply that every running batch has already adopted it. Consider this hypothetical sequence: batch-3 captures rev-42, an operator publishes rev-43, and a subsequent search finds failures from both batches that retained rev-42 and batches that adopted rev-43. Filtering only by the publication timestamp would attribute some old behavior to the new change. Keeping the captured revision makes that distinction explicit, while a separate attempt identifier prevents a retry from silently replacing the evidence for its first execution.
Expose adoption through worker evidence.
Capture evidence at the evaluation boundary
This small example uses an immutable snapshot value and an explicit decision source. It deliberately supports one Boolean flag with no targeting rules. The identifiers and revision are illustrative fixtures, not measured production results.
package catalog
import "log/slog"
type Snapshot struct {
Revision string
Enabled bool
Valid bool
}
type Decision struct {
Enabled bool
Revision string
Source string
}
func Evaluate(s Snapshot) Decision {
if !s.Valid || s.Revision == "" {
return Decision{Enabled: false, Source: "fallback"}
}
return Decision{
Enabled: s.Enabled, Revision: s.Revision, Source: "snapshot",
}
}
func RecordDecision(log *slog.Logger, run, batch string, d Decision) {
log.Info("catalog flag decision",
"event_name", "catalog.flag_decision",
"run_id", run,
"batch_id", batch,
"flag_key", "catalog_normalization",
"config_revision", d.Revision,
"enabled", d.Enabled,
"decision_source", d.Source,
)
}
func ExampleBatch(log *slog.Logger) Decision {
snapshot := Snapshot{Revision: "rev-42", Enabled: true, Valid: true}
decision := Evaluate(snapshot)
RecordDecision(log, "nightly-catalog-17", "batch-3", decision)
return decision
}
The caller must use the returned decision for processing and carry it into the eventual outcome record.
Otherwise this is only a log of an unused evaluation, which would be poor incident evidence. Configure the supplied logger for structured output in the actual service. This example leaves authentication, snapshot retrieval, persistence, and catalog processing outside the function rather than suggesting that a logging helper implements a control plane.
Here, fallback selects the existing normalization path. That is an explicit example policy, justified only if that path remains acceptable for the batch. A flag protecting a mandatory validation step may need to stop work when configuration is unavailable. Specify this per flag; a universal fallback value is too coarse to express those different consequences.
Test the evidence as well as the returned Boolean. With a valid disabled snapshot, expect a snapshot decision with its revision; with an invalid snapshot, expect a fallback decision without an invented revision. Change the available configuration while a batch runs and verify that the batch's captured decision stays stable. Then retry a failed batch under the documented policy: either preserve its original revision or create a new attempt that records the newly selected revision. The distinction must survive log search.
Keep the evidence useful under noise and change
Emit one decision event per batch when the flag really is constant for that batch, and include the captured decision in its outcome event. Per-item logging buys finer attribution at the expense of ingestion, indexing, and responder attention. If targeting varies by item, the batch-level shortcut no longer provides sufficient evidence: choose a smaller decision boundary or retain suitably detailed records, with an explicit data-handling policy.
Don't sample away the only record connecting a failed batch to its revision.
Keep routine progress chatter separate from decision, fallback, and outcome events, and give them stable event names. A query that must parse a changing English sentence to distinguish a fallback from a configured value is a maintenance obligation waiting for the next deployment.
During rollout, publish the logging schema before relying on it for incident searches, verify that deployed workers populate it, and keep old fields searchable for the investigation period your team requires. Assign someone ownership of each flag and its retirement condition. Removing a flag should not erase the meaning of historical decision records.
This method has limits. It assumes a batch can tolerate a fixed decision until its boundary, and it does not implement percentage targeting, identity assignment, or immediate cancellation. If those are requirements, expand the evaluation contract and test its evidence before rollout. The operational acceptance test remains concrete: starting from the page, can another responder identify the affected work, recover its actual decision, and explain its outcome without trusting a dashboard summary?
References
The source below supports the discussion of structured logs and trace correlation. The catalog schema, fallback behavior, and batch-boundary policy above are proposed engineering choices, with their applicability conditions stated in the text.
Sources
- OpenTelemetry, Logs signal concepts: https://opentelemetry.io/docs/concepts/signals/logs/
Top comments (0)