diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index a3db6d45..b8b44406 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Adds the `--file-log-max-files` CLI argument and `FILE_LOG_MAX_FILES` environment variable + see detailed [stackable-telemetry changelog](../stackable-telemetry/CHANGELOG.md) ([#1010]). + ### Changed - BREAKING: Update and align telemetry related CLI arguments of `ProductOperatorRun`, see detailed - changelog [here](../stackable-telemetry/CHANGELOG.md) ([#1009]). + changelog [stackable-telemetry changelog](../stackable-telemetry/CHANGELOG.md) ([#1009]). [#1009]: https://github.com/stackabletech/operator-rs/pull/1009 +[#1010]: https://github.com/stackabletech/operator-rs/pull/1010 ## [0.91.1] - 2025-04-09 diff --git a/crates/stackable-telemetry/CHANGELOG.md b/crates/stackable-telemetry/CHANGELOG.md index 9e3c553c..d83b60b3 100644 --- a/crates/stackable-telemetry/CHANGELOG.md +++ b/crates/stackable-telemetry/CHANGELOG.md @@ -17,8 +17,14 @@ All notable changes to this project will be documented in this file. - `FILE_LOG_LEVEL` instead of `FILE_LOG`. - `OTEL_LOG_EXPORTER_LEVEL` instead of `OTLP_LOG`. - `OTEL_TRACE_EXPORTER_LEVEL` instead of `OTLP_TRACE`. +- BREAKING: Allow configuration of `file_log_max_files` ([#1010]). + - Adds the `--file-log-max-files` CLI argument (env: `FILE_LOG_MAX_FILES`). + - `FileLogSettingsBuilder::with_max_log_files` which took a `usize` was renamed to + `FileLogSettingsBuilder::with_max_files` and now takes an `impl Into>` + for improved builder ergonomics. [#1009]: https://github.com/stackabletech/operator-rs/pull/1009 +[#1010]: https://github.com/stackabletech/operator-rs/pull/1010 ## [0.5.0] - 2025-04-08 diff --git a/crates/stackable-telemetry/src/tracing/mod.rs b/crates/stackable-telemetry/src/tracing/mod.rs index 708aac2a..0d7c8357 100644 --- a/crates/stackable-telemetry/src/tracing/mod.rs +++ b/crates/stackable-telemetry/src/tracing/mod.rs @@ -107,6 +107,7 @@ pub enum Error { /// console_log_disabled: false, /// file_log_directory: None, /// file_log_rotation_period: None, +/// file_log_max_files: Some(6), /// otel_trace_exporter_enabled: true, /// otel_log_exporter_enabled: true, /// }; @@ -348,6 +349,7 @@ impl Tracing { console_log_disabled, file_log_directory, file_log_rotation_period, + file_log_max_files, otel_trace_exporter_enabled, otel_log_exporter_enabled, } = options; @@ -367,6 +369,7 @@ impl Tracing { .with_default_level(LevelFilter::INFO) .file_log_settings_builder(log_directory, Self::FILE_LOG_SUFFIX) .with_rotation_period(file_log_rotation_period) + .with_max_files(file_log_max_files) .build() })) .with_otlp_log_exporter(( @@ -775,6 +778,13 @@ pub struct TelemetryOptions { )] pub file_log_rotation_period: Option, + /// Maximum NUMBER of log files to keep. + #[cfg_attr( + feature = "clap", + arg(long, env, value_name = "NUMBER", requires = "file_log") + )] + pub file_log_max_files: Option, + /// Enable exporting OpenTelemetry traces via OTLP. #[cfg_attr(feature = "clap", arg(long, env))] pub otel_trace_exporter_enabled: bool, @@ -1015,6 +1025,7 @@ mod test { console_log_disabled: false, file_log_directory: None, file_log_rotation_period: None, + file_log_max_files: None, otel_trace_exporter_enabled: true, otel_log_exporter_enabled: false, }); diff --git a/crates/stackable-telemetry/src/tracing/settings/file_log.rs b/crates/stackable-telemetry/src/tracing/settings/file_log.rs index 60fb21f8..ad345c4b 100644 --- a/crates/stackable-telemetry/src/tracing/settings/file_log.rs +++ b/crates/stackable-telemetry/src/tracing/settings/file_log.rs @@ -63,8 +63,8 @@ impl FileLogSettingsBuilder { } /// Set maximum number of log files to keep. - pub fn with_max_log_files(mut self, max_log_files: usize) -> Self { - self.max_log_files = Some(max_log_files); + pub fn with_max_files(mut self, max_log_files: impl Into>) -> Self { + self.max_log_files = max_log_files.into(); self } @@ -115,7 +115,7 @@ mod test { .with_default_level(LevelFilter::DEBUG) .file_log_settings_builder(PathBuf::from("/logs"), "tracing-rs.log") .with_rotation_period(Rotation::HOURLY) - .with_max_log_files(6) + .with_max_files(6) .build(); assert_eq!(expected, result);