From 935f2bb185d8282a2356a21198ac429399761322 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 30 Jan 2025 11:41:54 +0100 Subject: [PATCH 1/2] chore(stackable-operator):Remove redundant clap tests --- crates/stackable-operator/src/cli.rs | 52 ---------------------------- 1 file changed, 52 deletions(-) diff --git a/crates/stackable-operator/src/cli.rs b/crates/stackable-operator/src/cli.rs index 8bfeb26c9..ae762ece7 100644 --- a/crates/stackable-operator/src/cli.rs +++ b/crates/stackable-operator/src/cli.rs @@ -285,16 +285,13 @@ fn resolve_path<'a>( #[cfg(test)] mod tests { use super::*; - use clap::Parser; use rstest::*; - use std::env; use std::fs::File; use tempfile::tempdir; const USER_PROVIDED_PATH: &str = "user_provided_path_properties.yaml"; const DEPLOY_FILE_PATH: &str = "deploy_config_spec_properties.yaml"; const DEFAULT_FILE_PATH: &str = "default_file_path_properties.yaml"; - const WATCH_NAMESPACE: &str = "WATCH_NAMESPACE"; #[test] fn verify_cli() { @@ -376,53 +373,4 @@ mod tests { panic!("must return RequiredFileMissing when file was not found") } } - - #[test] - fn product_operator_run_watch_namespace() { - // clean env var to not interfere if already set - env::remove_var(WATCH_NAMESPACE); - - // cli with namespace - let opts = ProductOperatorRun::parse_from([ - "run", - "--product-config", - "bar", - "--watch-namespace", - "foo", - ]); - assert_eq!( - opts, - ProductOperatorRun { - product_config: ProductConfigPath::from("bar".as_ref()), - watch_namespace: WatchNamespace::One("foo".to_string()), - tracing_target: TracingTarget::None, - cluster_info_opts: Default::default(), - } - ); - - // no cli / no env - let opts = ProductOperatorRun::parse_from(["run", "--product-config", "bar"]); - assert_eq!( - opts, - ProductOperatorRun { - product_config: ProductConfigPath::from("bar".as_ref()), - watch_namespace: WatchNamespace::All, - tracing_target: TracingTarget::None, - cluster_info_opts: Default::default(), - } - ); - - // env with namespace - env::set_var(WATCH_NAMESPACE, "foo"); - let opts = ProductOperatorRun::parse_from(["run", "--product-config", "bar"]); - assert_eq!( - opts, - ProductOperatorRun { - product_config: ProductConfigPath::from("bar".as_ref()), - watch_namespace: WatchNamespace::One("foo".to_string()), - tracing_target: TracingTarget::None, - cluster_info_opts: Default::default(), - } - ); - } } From 69819e52e9a6574f57b3ec75e1d5d3e866afef87 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 30 Jan 2025 11:42:37 +0100 Subject: [PATCH 2/2] chore(stackable-operator):Replace TracingTarget with TelemetryOpts --- crates/stackable-operator/src/cli.rs | 42 ++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/crates/stackable-operator/src/cli.rs b/crates/stackable-operator/src/cli.rs index ae762ece7..3e5ff8e03 100644 --- a/crates/stackable-operator/src/cli.rs +++ b/crates/stackable-operator/src/cli.rs @@ -217,14 +217,50 @@ pub struct ProductOperatorRun { #[arg(long, env, default_value = "")] pub watch_namespace: WatchNamespace, - /// Tracing log collector system - #[arg(long, env, default_value_t, value_enum)] - pub tracing_target: TracingTarget, + #[command(flatten)] + pub telemetry_opts: TelemetryOpts, #[command(flatten)] pub cluster_info_opts: KubernetesClusterInfoOpts, } +/// Telemetry options for logs/metrics/traces +#[derive(clap::Args, Debug, PartialEq, Eq)] +pub struct TelemetryOpts { + /// Disable console log output + #[arg(long, env)] + pub no_console_log: bool, + + /// Console log format. Currently only "plain" is supported. + // NOTE (@NickLarsenNZ): We have to choose from one of these options: + // 1. Include stackable-telemetry to get access to console_log::Format, or + // 2. Use a String, and leave the bin crate to figure it out + // 3. Duplicate console_log::Format, and leave it to the bin crate to figure out. + // We have hidden it for now until we decide what to do. + #[arg(hide = true, long, env, default_value_t = String::from("plain"))] + console_output_format: String, + + /// Enable OTLP export for logs + // TODO (@NickLarsenNZ): Add long help test describing the default endpoint: http://localhost:4317 + #[arg(long, env)] + pub otlp_logs: bool, + + /// Enable OTLP export for metrics + // TODO (@NickLarsenNZ): Add long help test describing the default endpoint: http://localhost:4317 + // NOTE (@NickLarsenNZ): Hidden for now as stackable-telemetry doesn't yet handle metrics. + #[arg(hide = true, long, env)] + otlp_metrics: bool, + + /// Enable OTLP export for traces + // TODO (@NickLarsenNZ): Add long help test describing the default endpoint: http://localhost:4317 + #[arg(long, env)] + pub otlp_traces: bool, + + /// Enable rolling log files in the given directory + #[arg(long, env)] + pub rolling_logs_directory: Option, +} + /// A path to a [`ProductConfigManager`] spec file #[derive(Clone, Debug, PartialEq, Eq)] pub struct ProductConfigPath {