Skip to content

Commit 2822a3a

Browse files
NickLarsenNZTechassi
andauthoredApr 11, 2025··
feat(stackable-telemetry)!: Allow configuration of file_log_max_files (#1010)
* refactor!: Update telemetry related env vars and CLI args * chore: Update changelogs * chore: Update doc comment * test: Fix doc test * chore: Apply suggestions from code review Co-authored-by: Nick <[email protected]> * chore: Update doc comments Co-authored-by: Nick <[email protected]> * feat(stackable-telemetry)!: Allow configuration of file_log_max_files BREAKING: `FileLogSettingsBuilder::with_max_log_files` which took a `usize` was renamed to `FileLogSettingsBuilder::with_max_files` and now takes an `impl Into<Option<usize>>` * chore(stackable-telemetry): Update changelog * chore(stackable-operator): Update changelog --------- Co-authored-by: Techassi <[email protected]>
1 parent 63a4e45 commit 2822a3a

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed
 

‎crates/stackable-operator/CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Adds the `--file-log-max-files` CLI argument and `FILE_LOG_MAX_FILES` environment variable
10+
see detailed [stackable-telemetry changelog](../stackable-telemetry/CHANGELOG.md) ([#1010]).
11+
712
### Changed
813

914
- BREAKING: Update and align telemetry related CLI arguments of `ProductOperatorRun`, see detailed
10-
changelog [here](../stackable-telemetry/CHANGELOG.md) ([#1009]).
15+
changelog [stackable-telemetry changelog](../stackable-telemetry/CHANGELOG.md) ([#1009]).
1116

1217
[#1009]: https://github.com/stackabletech/operator-rs/pull/1009
18+
[#1010]: https://github.com/stackabletech/operator-rs/pull/1010
1319

1420
## [0.91.1] - 2025-04-09
1521

‎crates/stackable-telemetry/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ All notable changes to this project will be documented in this file.
1717
- `FILE_LOG_LEVEL` instead of `FILE_LOG`.
1818
- `OTEL_LOG_EXPORTER_LEVEL` instead of `OTLP_LOG`.
1919
- `OTEL_TRACE_EXPORTER_LEVEL` instead of `OTLP_TRACE`.
20+
- BREAKING: Allow configuration of `file_log_max_files` ([#1010]).
21+
- Adds the `--file-log-max-files` CLI argument (env: `FILE_LOG_MAX_FILES`).
22+
- `FileLogSettingsBuilder::with_max_log_files` which took a `usize` was renamed to
23+
`FileLogSettingsBuilder::with_max_files` and now takes an `impl Into<Option<usize>>`
24+
for improved builder ergonomics.
2025

2126
[#1009]: https://github.com/stackabletech/operator-rs/pull/1009
27+
[#1010]: https://github.com/stackabletech/operator-rs/pull/1010
2228

2329
## [0.5.0] - 2025-04-08
2430

‎crates/stackable-telemetry/src/tracing/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ pub enum Error {
107107
/// console_log_disabled: false,
108108
/// file_log_directory: None,
109109
/// file_log_rotation_period: None,
110+
/// file_log_max_files: Some(6),
110111
/// otel_trace_exporter_enabled: true,
111112
/// otel_log_exporter_enabled: true,
112113
/// };
@@ -348,6 +349,7 @@ impl Tracing {
348349
console_log_disabled,
349350
file_log_directory,
350351
file_log_rotation_period,
352+
file_log_max_files,
351353
otel_trace_exporter_enabled,
352354
otel_log_exporter_enabled,
353355
} = options;
@@ -367,6 +369,7 @@ impl Tracing {
367369
.with_default_level(LevelFilter::INFO)
368370
.file_log_settings_builder(log_directory, Self::FILE_LOG_SUFFIX)
369371
.with_rotation_period(file_log_rotation_period)
372+
.with_max_files(file_log_max_files)
370373
.build()
371374
}))
372375
.with_otlp_log_exporter((
@@ -775,6 +778,13 @@ pub struct TelemetryOptions {
775778
)]
776779
pub file_log_rotation_period: Option<RotationPeriod>,
777780

781+
/// Maximum NUMBER of log files to keep.
782+
#[cfg_attr(
783+
feature = "clap",
784+
arg(long, env, value_name = "NUMBER", requires = "file_log")
785+
)]
786+
pub file_log_max_files: Option<usize>,
787+
778788
/// Enable exporting OpenTelemetry traces via OTLP.
779789
#[cfg_attr(feature = "clap", arg(long, env))]
780790
pub otel_trace_exporter_enabled: bool,
@@ -1015,6 +1025,7 @@ mod test {
10151025
console_log_disabled: false,
10161026
file_log_directory: None,
10171027
file_log_rotation_period: None,
1028+
file_log_max_files: None,
10181029
otel_trace_exporter_enabled: true,
10191030
otel_log_exporter_enabled: false,
10201031
});

‎crates/stackable-telemetry/src/tracing/settings/file_log.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ impl FileLogSettingsBuilder {
6363
}
6464

6565
/// Set maximum number of log files to keep.
66-
pub fn with_max_log_files(mut self, max_log_files: usize) -> Self {
67-
self.max_log_files = Some(max_log_files);
66+
pub fn with_max_files(mut self, max_log_files: impl Into<Option<usize>>) -> Self {
67+
self.max_log_files = max_log_files.into();
6868
self
6969
}
7070

@@ -115,7 +115,7 @@ mod test {
115115
.with_default_level(LevelFilter::DEBUG)
116116
.file_log_settings_builder(PathBuf::from("/logs"), "tracing-rs.log")
117117
.with_rotation_period(Rotation::HOURLY)
118-
.with_max_log_files(6)
118+
.with_max_files(6)
119119
.build();
120120

121121
assert_eq!(expected, result);

0 commit comments

Comments
 (0)
Please sign in to comment.