Skip to content

Commit 07d78c1

Browse files
feat!: Add method for pre-configured Tracing instance (#1001)
* feat: Add method to construct pre-configured Tracing instance * test: Add unit test for Tracing::pre_configured * chore: Update variable name used in unit test * docs: Add doc comments for Tracing::pre_configured * chore(docs): Fixup various doc comments * chore: Fix doc comment references * refactor: Use stackable_telemetry::TelemetryOptions * chore: Update changelogs * chore: Fix doc tests * chore: Change filename suffix to "tracing-rs.json" * docs: Document default env vars, level filters and default values * chore(stackable-telemetry): Adjust changelog * chore: Change level for OTLP logs and traces to INFO Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> * docs: Add clap specific example for TelemetryOptions * chore: Fix changelog --------- Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent ea063b4 commit 07d78c1

File tree

8 files changed

+256
-85
lines changed

8 files changed

+256
-85
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-operator/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Changed
8+
9+
- BREAKING: Remove `cli::TelemetryArguments` and `cli::RollingPeriod` which are both replaced by
10+
types from `stackable_telemetry` ([#1001]).
11+
- BREAKING: The `ProductOperatorRun` struct now uses `stackable_telemetry::tracing::TelemetryOptions`
12+
for the `telemetry_arguments` field ([#1001]).
13+
14+
[#1001]: https://github.com/stackabletech/operator-rs/pull/1001
15+
716
## [0.90.0] - 2025-04-07
817

918
### Added

crates/stackable-operator/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repository.workspace = true
1111
time = ["dep:time"]
1212

1313
[dependencies]
14+
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"]}
1415
stackable-operator-derive = { path = "../stackable-operator-derive" }
1516
stackable-shared = { path = "../stackable-shared" }
1617

crates/stackable-operator/src/cli.rs

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@
108108
//!
109109
use std::{
110110
ffi::OsStr,
111-
ops::Deref,
112111
path::{Path, PathBuf},
113112
};
114113

115114
use clap::Args;
116115
use product_config::ProductConfigManager;
117116
use snafu::{ResultExt, Snafu};
117+
use stackable_telemetry::tracing::TelemetryOptions;
118118

119119
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts};
120120

@@ -165,10 +165,8 @@ pub enum Command<Run: Args = ProductOperatorRun> {
165165
/// ```rust
166166
/// # use stackable_operator::cli::{Command, ProductOperatorRun, ProductConfigPath};
167167
/// use clap::Parser;
168-
/// use stackable_operator::{
169-
/// cli::TelemetryArguments,
170-
/// namespace::WatchNamespace,
171-
/// };
168+
/// use stackable_operator::namespace::WatchNamespace;
169+
/// use stackable_telemetry::tracing::TelemetryOptions;
172170
///
173171
/// #[derive(clap::Parser, Debug, PartialEq, Eq)]
174172
/// struct Run {
@@ -184,7 +182,7 @@ pub enum Command<Run: Args = ProductOperatorRun> {
184182
/// common: ProductOperatorRun {
185183
/// product_config: ProductConfigPath::from("bar".as_ref()),
186184
/// watch_namespace: WatchNamespace::One("foobar".to_string()),
187-
/// telemetry_arguments: TelemetryArguments::default(),
185+
/// telemetry_arguments: TelemetryOptions::default(),
188186
/// cluster_info_opts: Default::default(),
189187
/// },
190188
/// }));
@@ -219,7 +217,7 @@ pub struct ProductOperatorRun {
219217
pub watch_namespace: WatchNamespace,
220218

221219
#[command(flatten)]
222-
pub telemetry_arguments: TelemetryArguments,
220+
pub telemetry_arguments: TelemetryOptions,
223221

224222
#[command(flatten)]
225223
pub cluster_info_opts: KubernetesClusterInfoOpts,
@@ -280,50 +278,6 @@ impl ProductConfigPath {
280278
}
281279
}
282280

283-
#[derive(Debug, Default, PartialEq, Eq, Args)]
284-
pub struct TelemetryArguments {
285-
/// Disable console output.
286-
#[arg(long, env)]
287-
pub no_console_output: bool,
288-
289-
/// Enable logging to rolling files located in the specified DIRECTORY.
290-
#[arg(long, env, value_name = "DIRECTORY", group = "rolling_logs_group")]
291-
pub rolling_logs: Option<PathBuf>,
292-
293-
/// Time PERIOD after which log files are rolled over.
294-
#[arg(long, env, value_name = "PERIOD", requires = "rolling_logs_group")]
295-
pub rolling_logs_period: Option<RollingPeriod>,
296-
297-
/// Enable exporting traces via OTLP.
298-
#[arg(long, env)]
299-
pub otlp_traces: bool,
300-
301-
/// Enable exporting logs via OTLP.
302-
#[arg(long, env)]
303-
pub otlp_logs: bool,
304-
}
305-
306-
#[derive(Clone, Debug, PartialEq, Eq, strum::Display, strum::EnumString, clap::ValueEnum)]
307-
pub enum RollingPeriod {
308-
Minutely,
309-
Hourly,
310-
Daily,
311-
Never,
312-
}
313-
314-
impl Deref for RollingPeriod {
315-
type Target = tracing_appender::rolling::Rotation;
316-
317-
fn deref(&self) -> &Self::Target {
318-
match self {
319-
RollingPeriod::Minutely => &tracing_appender::rolling::Rotation::MINUTELY,
320-
RollingPeriod::Hourly => &tracing_appender::rolling::Rotation::HOURLY,
321-
RollingPeriod::Daily => &tracing_appender::rolling::Rotation::DAILY,
322-
RollingPeriod::Never => &tracing_appender::rolling::Rotation::NEVER,
323-
}
324-
}
325-
}
326-
327281
#[cfg(test)]
328282
mod tests {
329283
use std::{env, fs::File};

crates/stackable-telemetry/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add new `Tracing::pre_configured` method ([#1001]).
10+
- Add `TelemetryOptions` struct and `RollingPeriod` enum
11+
- Add `clap` feature to enable `TelemetryOptions` being used as CLI arguments
12+
13+
### Changed
14+
15+
- BREAKING: Change `FileLogSettingsBuilder::with_rotation_period` to take `impl Into<Rotation>`
16+
instead of `Rotation` ([#1001]).
17+
18+
[#1001]: https://github.com/stackabletech/operator-rs/pull/1001
19+
720
## [0.4.0] - 2025-04-02
821

922
### Added

crates/stackable-telemetry/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ license.workspace = true
66
edition.workspace = true
77
repository.workspace = true
88

9+
[features]
10+
clap = ["dep:clap"]
11+
912
[dependencies]
1013
axum.workspace = true
14+
clap = { workspace = true, optional = true }
1115
futures-util.workspace = true
1216
opentelemetry = { workspace = true, features = ["logs"] }
1317
opentelemetry-appender-tracing.workspace = true
@@ -16,6 +20,7 @@ opentelemetry-otlp = { workspace = true, features = ["grpc-tonic", "gzip-tonic",
1620
opentelemetry_sdk = { workspace = true, features = ["logs", "rt-tokio", "spec_unstable_logs_enabled"] }
1721
pin-project.workspace = true
1822
snafu.workspace = true
23+
strum.workspace = true
1924
tokio.workspace = true
2025
tower.workspace = true
2126
tracing.workspace = true

0 commit comments

Comments
 (0)