mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-16 05:20:22 +08:00
* 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>
74 lines
2.3 KiB
Bash
Executable File
74 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# Verify whether telemetry emission code is present in a compiled binary.
|
|
#
|
|
# The `telemetry` Cargo feature (default-on, defined in openshell-core) gates the
|
|
# telemetry endpoint, HTTP client, and emission code. Building with
|
|
# --no-default-features must produce a binary that contains none of it. This
|
|
# guard inspects a built binary for telemetry markers that only exist when the
|
|
# emission code is compiled in.
|
|
|
|
set -euo pipefail
|
|
|
|
# Markers that appear only in compiled-in telemetry emission code. Sourced from
|
|
# crates/openshell-core/src/telemetry.rs (DEFAULT_ENDPOINT host and CLIENT_ID).
|
|
# Keep in sync with that file; the `present` positive control fails loudly if a
|
|
# marker goes stale, so the `absent` checks can never become silently vacuous.
|
|
MARKERS=(
|
|
"events.telemetry.data.nvidia.com"
|
|
"415437562476676"
|
|
)
|
|
|
|
usage() {
|
|
echo "Usage: verify-telemetry-compiled-out.sh <present|absent> <binary> [binary ...]" >&2
|
|
echo " present assert telemetry markers ARE present (positive control for a telemetry-enabled build)" >&2
|
|
echo " absent assert telemetry markers are NOT present (telemetry compiled out)" >&2
|
|
}
|
|
|
|
if [[ $# -lt 2 ]]; then
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
mode=$1
|
|
shift
|
|
case "$mode" in
|
|
present | absent) ;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
if ! command -v strings >/dev/null 2>&1; then
|
|
echo "error: 'strings' (binutils) is required to inspect the binary" >&2
|
|
exit 2
|
|
fi
|
|
|
|
failed=0
|
|
for binary in "$@"; do
|
|
if [[ ! -f $binary ]]; then
|
|
echo "error: binary not found: $binary" >&2
|
|
failed=1
|
|
continue
|
|
fi
|
|
|
|
dump=$(strings -a "$binary")
|
|
for marker in "${MARKERS[@]}"; do
|
|
count=$(grep -c -F "$marker" <<<"$dump" || true)
|
|
if [[ $mode == absent && $count -ne 0 ]]; then
|
|
echo "FAIL: telemetry marker '$marker' found in $binary ($count occurrence(s)); telemetry was not compiled out" >&2
|
|
failed=1
|
|
elif [[ $mode == present && $count -eq 0 ]]; then
|
|
echo "FAIL: telemetry marker '$marker' missing from $binary; positive control failed (marker stale or build misconfigured)" >&2
|
|
failed=1
|
|
else
|
|
echo "OK: marker '$marker' $mode in $(basename "$binary") ($count occurrence(s))"
|
|
fi
|
|
done
|
|
done
|
|
|
|
exit "$failed"
|