Skip to content

feat!: Use stackable-telemetry #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Changed

- Replace stackable-operator `initialize_logging` with stackable-telemetry `Tracing` ([#840]).
- BREAKING: The file log directory was set by `KAFKA_OPERATOR_LOG_DIRECTORY`, and is now set by `ROLLING_LOGS`
(or via `--rolling-logs <DIRECTORY>`).
- Replace stackable-operator `print_startup_string` with `tracing::info!` with fields.

[#840]: https://github.com/stackabletech/kafka-operator/pull/840

## [25.3.0] - 2025-03-21

### Deprecated
752 changes: 604 additions & 148 deletions Cargo.lock

Large diffs are not rendered by default.

3,670 changes: 2,971 additions & 699 deletions Cargo.nix

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,9 +10,10 @@ edition = "2021"
repository = "https://github.com/stackabletech/kafka-operator"

[workspace.dependencies]
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.6.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.87.0" }
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.89.1" }
stackable-telemetry = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-telemetry-0.4.0" }
stackable-versioned = { git = "https://github.com/stackabletech/operator-rs.git", features = ["k8s"], tag = "stackable-versioned-0.7.1" }

anyhow = "1.0"
built = { version = "0.7", features = ["chrono", "git2"] }
13 changes: 7 additions & 6 deletions crate-hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions rust/operator-binary/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,9 +9,10 @@ repository.workspace = true
publish = false

[dependencies]
stackable-versioned.workspace = true
stackable-operator.workspace = true
product-config.workspace = true
stackable-operator.workspace = true
stackable-telemetry.workspace = true
stackable-versioned.workspace = true

indoc.workspace = true
anyhow.workspace = true
73 changes: 56 additions & 17 deletions rust/operator-binary/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::sync::Arc;
use std::{ops::Deref as _, sync::Arc};

use clap::{Parser, crate_description, crate_version};
use clap::Parser;
use futures::StreamExt;
use product_config::ProductConfigManager;
use stackable_operator::{
YamlSchema,
cli::{Command, ProductOperatorRun},
cli::{Command, ProductOperatorRun, RollingPeriod},
client::{self, Client},
commons::listener::Listener,
k8s_openapi::api::{
@@ -25,9 +25,11 @@ use stackable_operator::{
namespace::WatchNamespace,
shared::yaml::SerializeOptions,
};
use stackable_telemetry::{Tracing, tracing::settings::Settings};
use tracing::level_filters::LevelFilter;

use crate::{
crd::{APP_NAME, KafkaCluster, OPERATOR_NAME, v1alpha1},
crd::{KafkaCluster, OPERATOR_NAME, v1alpha1},
kafka_controller::KAFKA_FULL_CONTROLLER_NAME,
};

@@ -45,6 +47,9 @@ mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

// TODO (@NickLarsenNZ): Change the variable to `CONSOLE_LOG`
pub const ENV_VAR_CONSOLE_LOG: &str = "KAFKA_OPERATOR_LOG";

#[derive(clap::Parser)]
#[clap(about, author)]
struct Opts {
@@ -71,23 +76,57 @@ async fn main() -> anyhow::Result<()> {
ProductOperatorRun {
product_config,
watch_namespace,
tracing_target,
telemetry_arguments,
cluster_info_opts,
},
..
}) => {
stackable_operator::logging::initialize_logging(
"KAFKA_OPERATOR_LOG",
APP_NAME,
tracing_target,
);
stackable_operator::utils::print_startup_string(
crate_description!(),
crate_version!(),
built_info::GIT_VERSION,
built_info::TARGET,
built_info::BUILT_TIME_UTC,
built_info::RUSTC_VERSION,
let _tracing_guard = Tracing::builder()
.service_name("kafka-operator")
.with_console_output((
ENV_VAR_CONSOLE_LOG,
LevelFilter::INFO,
!telemetry_arguments.no_console_output,
))
// NOTE (@NickLarsenNZ): Before stackable-telemetry was used, the log directory was
// set via an env: `KAFKA_OPERATOR_LOG_DIRECTORY`.
// See: https://github.com/stackabletech/operator-rs/blob/f035997fca85a54238c8de895389cc50b4d421e2/crates/stackable-operator/src/logging/mod.rs#L40
// Now it will be `ROLLING_LOGS` (or via `--rolling-logs <DIRECTORY>`).
.with_file_output(telemetry_arguments.rolling_logs.map(|log_directory| {
let rotation_period = telemetry_arguments
.rolling_logs_period
.unwrap_or(RollingPeriod::Never)
.deref()
.clone();

Settings::builder()
.with_environment_variable(ENV_VAR_CONSOLE_LOG)
.with_default_level(LevelFilter::INFO)
.file_log_settings_builder(log_directory, "tracing-rs.log")
.with_rotation_period(rotation_period)
.build()
}))
.with_otlp_log_exporter((
"OTLP_LOG",
LevelFilter::DEBUG,
telemetry_arguments.otlp_logs,
))
.with_otlp_trace_exporter((
"OTLP_TRACE",
LevelFilter::DEBUG,
telemetry_arguments.otlp_traces,
))
.build()
.init()?;

tracing::info!(
built_info.pkg_version = built_info::PKG_VERSION,
built_info.git_version = built_info::GIT_VERSION,
built_info.target = built_info::TARGET,
built_info.built_time_utc = built_info::BUILT_TIME_UTC,
built_info.rustc_version = built_info::RUSTC_VERSION,
"Starting {description}",
description = built_info::PKG_DESCRIPTION
);
let product_config = product_config.load(&[
"deploy/config-spec/properties.yaml",