Files
OpenShell/tasks/rust.toml
Russell Bryant 3aba30c36f feat(telemetry): add build-time option to compile out telemetry (#1845)
* feat(telemetry): add build-time option to compile out telemetry

Gate anonymous telemetry emission behind a default-on `telemetry` Cargo
feature in openshell-core. The data model (enums, validation, emit_*/enabled*
signatures) stays always-compiled, while the endpoint, HTTP client, queue, and
emission code are feature-gated. With the feature off, enabled() returns false
and emit_* are no-ops, so dependent crates compile unchanged and no telemetry
endpoint, HTTP client, or emission code is included in the binary.

chrono and reqwest become optional dependencies of openshell-core, dropped from
its dependency graph when telemetry is disabled.

Thread the switch through the workspace: every crate depends on openshell-core
with default-features = false, and the default-on `telemetry` passthrough lives
on the binary crates that emit or collect telemetry (openshell-server,
openshell-sandbox, openshell-driver-vm). In-process drivers inherit it via
resolver v2 feature unification.

Build a telemetry-free binary with, e.g.:
  cargo build --release -p openshell-server --no-default-features

The runtime OPENSHELL_TELEMETRY_ENABLED switch is unchanged for default builds.

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>

* ci(telemetry): guard that telemetry can be compiled out

Add tasks/scripts/verify-telemetry-compiled-out.sh, which inspects a built
binary for telemetry markers (the telemetry endpoint host and client ID) that
exist only when emission code is compiled in. The rust:verify:telemetry-off
mise task builds the gateway with default features (positive control: markers
must be present, so the absent checks can never be silently vacuous) and with
--no-default-features (markers must be absent), and checks the
--no-default-features sandbox binary as well.

Wire the task into the Rust branch-checks job so a regression that reintroduces
telemetry code into a --no-default-features build fails CI.

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>

---------

Signed-off-by: Russell Bryant <russell.bryant@gmail.com>
2026-06-09 14:19:26 -07:00

42 lines
1.5 KiB
TOML

# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Rust check, lint, and format tasks
["rust:check"]
description = "Check all Rust crates for errors"
run = "cargo check --workspace"
hide = true
["rust:lint"]
description = "Lint Rust code with Clippy (deny warnings)"
run = [
"cargo clippy --workspace --all-targets -- -D warnings",
"cargo clippy --manifest-path e2e/rust/Cargo.toml --all-targets -- -D warnings",
]
hide = true
["rust:format"]
description = "Format Rust code"
run = "cargo fmt --all"
hide = true
["rust:format:check"]
description = "Check Rust formatting"
run = "cargo fmt --all -- --check"
hide = true
["rust:verify:telemetry-off"]
description = "Verify telemetry emission code is compiled out with --no-default-features"
run = [
# Positive control: the default (telemetry-on) gateway must contain the
# markers, so the absent checks below can never become silently vacuous.
"cargo build -p openshell-server --bin openshell-gateway",
"tasks/scripts/verify-telemetry-compiled-out.sh present target/debug/openshell-gateway",
# Guard: telemetry-free builds must contain no telemetry markers.
"cargo build -p openshell-server --bin openshell-gateway --no-default-features",
"tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-gateway",
"cargo build -p openshell-sandbox --bin openshell-sandbox --no-default-features",
"tasks/scripts/verify-telemetry-compiled-out.sh absent target/debug/openshell-sandbox",
]