Skip to content

Feature flags #6057

Closed

Description

@inancgumus

Feature Description

k6 has no shared way to put a feature behind a named, discoverable flag. Anything experimental or optional ends up with its own ad-hoc env var or option, with no common naming, no lifecycle, and no single place to list what exists. As more in-progress features land, this gets harder to reason about for both users and maintainers.

Suggested Solution (optional)

Add a generic feature-flag system:

  • A --features flag on k6 run and k6 cloud run, plus a features field in the config file. Precedence: command line, then environment, then config file.
  • A k6 features command that lists every flag and its lifecycle stage (experimental, GA, deprecated), with a --json option.
  • Active flags carried into the run environment so they reach archives and cloud/distributed workers, and surfaced as k6_feature_<name> metric tags.
  • A retirement path for old env vars: an alias can be honored (still works, warns), tombstoned (errors), or removed (ignored).
  • native-histograms as the first real flag, replacing the K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM env var (kept as a deprecated alias).

Current spec match

Scenario Result
CLI > env > JSON precedence ✅
Multiple --features flags merge/dedup ✅
Empty --features "" overrides everything ✅
K6_FEATURES="" + legacy alias → union, alias activates ✅
Falsy legacy alias (=false) → env not supplied, JSON consulted ✅
Non-kebab input treated as Unknown (not hard error) ✅
Unknown flag: ERROR log, exit 0, not in activation set ✅
Experimental activation: INFO log ✅
Deprecated activation: WARN log ✅
GA activation: INFO "please remove" log ✅
GA forced true without activation: no log, no tag ✅
CLI overrides JSON; GA stays on regardless ✅
Legacy alias: dual log (alias WARN + canonical INFO) ✅
Legacy alias: telemetry uses canonical name ✅
Phase-1 alias with dangling canonical: WARN + ERROR ✅
Phase-2 tombstoned: ERROR only, no activation ✅
Phase-3 removed: silent ✅
Tag: k6_feature_<snake>=true per activated feature ✅
Tag: unactivated GA emits no tag ✅
Tag: kebab → snake (native-histograms → k6_feature_native_histograms) ✅
k6 features table: sorted Experimental → Deprecated → GA ✅
k6 features --json: exact keys name/lifecycle/description ✅
Distributed exec: archive bakes K6_FEATURES ✅
Worker replay: reads from baked env (is_archive=true), not process env ✅
Version skew: unknown feature on worker → ERROR, continues ✅
Telemetry: canonical names reported ✅
noCopy: go vet catches value copies ✅
Activated() returns defensive copy ✅
Stale k6_feature_* run tags stripped and replaced ✅
remotewrite gets NativeHistograms=true when feature active ✅
remotewrite gets NativeHistograms=false when feature absent ✅

Already existing or connected issues / PRs (optional)

Activity

  1. self-assigned this
    on Jun 5, 2026
  2. changed the title [-]Implement feature flags[/-] [+]Feature flags[/+] on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions