linera-io/linera-protocol · error

Benchmark requires the 'opentelemetry' feature to be enabled

Error message

Benchmark requires the 'opentelemetry' feature to be enabled. Run with: cargo run --features opentelemetry --bin linera -- benchmark ...

What it means

Thrown by the `linera benchmark` command when the binary was compiled without the `opentelemetry` Cargo feature. The gate exists so benchmark traffic is always labeled synthetic (the feature branch sets LINERA_TRAFFIC_TYPE=synthetic for OpenTelemetry labeling); without it, synthetic benchmark traffic would be counted as organic and corrupt production metrics. The bail fires under `#[cfg(not(feature = "opentelemetry"))]` before any benchmark work starts.

Source

Thrown at linera-service/src/cli/main.rs:795

                context.wallet().save()?;

                let time_total = time_start.elapsed();
                info!(
                    "Revoking committees confirmed after {} ms",
                    time_total.as_millis()
                );
            }

            #[cfg_attr(
                not(feature = "opentelemetry"),
                allow(unreachable_code, unused_variables)
            )]
            Benchmark(benchmark_command) => {
                // Require opentelemetry feature for benchmarks to ensure traffic is properly
                // labeled as synthetic. Without this, benchmark traffic would be mislabeled
                // as "organic" and corrupt production metrics.
                #[cfg(not(feature = "opentelemetry"))]
                anyhow::bail!(
                    "Benchmark requires the 'opentelemetry' feature to be enabled. \
                     Run with: cargo run --features opentelemetry --bin linera -- benchmark ..."
                );

                // Mark all benchmark traffic as synthetic for observability filtering.
                std::env::set_var("LINERA_TRAFFIC_TYPE", "synthetic");

                match benchmark_command {
                    BenchmarkCommand::Single {
                        options: benchmark_options,
                    } => {
                        let BenchmarkOptions {
                            num_chains,
                            tokens_per_chain,
                            transactions_per_block,
                            fungible_application_id,
                            bps,
                            close_chains,

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Re-run with the feature enabled: `cargo run --features opentelemetry --bin linera -- benchmark ...`
  2. For an installed binary, rebuild it with the feature: `cargo install --features opentelemetry linera-service`
  3. If benchmarks are routine in your workflow, enable the feature permanently in `.cargo/config.toml` or workspace default features

Example fix

# before
cargo run --bin linera -- benchmark --chains e476187f6ddfeb040... 

# after
cargo run --features opentelemetry --bin linera -- benchmark --chains e476187f6ddfeb040...
Defensive patterns

Strategy: validation

Validate before calling

# fail fast before launching a benchmark
if ! cargo tree -f "{f}" -e features --bin linera 2>/dev/null | grep -qw opentelemetry; then
  echo "linera build lacks 'opentelemetry'; rebuild with --features opentelemetry" >&2
  exit 1
fi
cargo run --features opentelemetry --bin linera -- benchmark ...

Prevention

When it happens

Trigger: Running `cargo run --bin linera -- benchmark ...` (or any benchmark invocation on a build that omitted the feature). The cfg-gated branch in the Benchmark command handler at linera-service/src/cli/main.rs:795 triggers immediately on command dispatch.

Common situations: Developer rebuilds the CLI with a default/minimal feature set and re-runs a benchmark that worked on a feature-enabled build; distributed release binaries built without the feature; CI scripts or aliases that drop the `--features opentelemetry` flag.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/a76589b1360fa4cb. Report an issue: GitHub.