Skip to content

Commit f34807f

Browse files
lfranckeTechassi
authored andcommitted
Various updates (#45)
* Various updates - Dependency updates - Log open files limit - Reduce logging at info slightly - Add rust-toolchain.toml - Fix pre-commit warnings * Various updates - Dep updates - Rust toolchain update - PR template update * rustfmt * Update dependencies * Update operator-rs * Update dependencies * better telemetry integration * rustfmt * rustfmt * use our version of cargo-udeps * pre-commit * pre-commit * add markdownlint config * add markdownlint & yamllint config * md lint * address review comment
1 parent a97d754 commit f34807f

6 files changed

Lines changed: 28 additions & 20 deletions

File tree

crates/containerdebug/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ All notable changes to this project will be documented in this file.
77
### Changed
88

99
- Increased the default `--loop` interval from every minute to every 30 minutes ([#23]).
10+
- Collect and output the open files limit ([#45])
1011

1112
[#23]: https://github.com/stackabletech/containerdebug/pull/23
13+
[#45]: https://github.com/stackabletech/containerdebug/pull/45
1214

1315
## [0.1.1] - 2024-12-16
1416

crates/containerdebug/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "containerdebug"
33
version = "0.1.1"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
clap = { version = "4.5", features = ["derive"] }
@@ -11,9 +11,9 @@ local-ip-address = "0.6"
1111
serde = { version = "1.0", features = ["derive"] }
1212
serde_json = "1.0"
1313
snafu = "0.8"
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.86.0" }
15-
sysinfo = { version = "0.33", features = ["serde"] }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs", tag = "stackable-operator-0.93.1", features = ["telemetry"] }
15+
sysinfo = { version = "0.35", features = ["serde"] }
1616
tracing = "0.1"
1717

1818
[build-dependencies]
19-
built = { version = "0.7", features = ["chrono", "git2"] }
19+
built = { version = "0.8", features = ["chrono", "git2"] }

crates/containerdebug/src/main.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
mod error;
22
mod system_information;
33

4-
use clap::{crate_description, crate_version, Parser};
5-
use stackable_operator::logging::TracingTarget;
4+
use clap::{Parser, crate_description, crate_version};
5+
use stackable_operator::telemetry::Tracing;
66
use std::path::PathBuf;
77

88
use crate::system_information::SystemInformation;
9+
use stackable_operator::telemetry::tracing::TelemetryOptions;
910
use std::time::Instant;
1011

1112
const APP_NAME: &str = "containerdebug";
@@ -27,9 +28,8 @@ struct Opts {
2728
#[clap(long, short = 'o')]
2829
output: Option<PathBuf>,
2930

30-
/// Tracing log collector system
31-
#[arg(long, env, default_value_t, value_enum)]
32-
pub tracing_target: TracingTarget,
31+
#[clap(flatten)]
32+
pub telemetry_arguments: TelemetryOptions,
3333
}
3434

3535
mod built_info {
@@ -38,11 +38,10 @@ mod built_info {
3838

3939
fn main() {
4040
let opts = Opts::parse();
41-
stackable_operator::logging::initialize_logging(
42-
"CONTAINERDEBUG_LOG",
43-
APP_NAME,
44-
opts.tracing_target,
45-
);
41+
42+
let _trace_guard = Tracing::pre_configured(APP_NAME, opts.telemetry_arguments)
43+
.init()
44+
.unwrap();
4645

4746
// Wrap *all* output in a span, to separate it from main app output.
4847
let _span = tracing::error_span!("containerdebug").entered();

crates/containerdebug/src/system_information/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl SystemInformation {
4242
/// Collects static information that doesn't need to be refreshed.
4343
#[tracing::instrument(name = "SystemInformation::init")]
4444
pub fn init() -> CollectContext {
45-
tracing::info!("initializing");
45+
tracing::debug!("initializing");
4646
let mut ctx = CollectContext {
4747
// Each module is responsible for updating the information that it cares about.
4848
system: sysinfo::System::new(),
@@ -53,14 +53,14 @@ impl SystemInformation {
5353
"failed to initialize user module, ignoring but this will likely cause collection errors..."
5454
);
5555
}
56-
tracing::info!("init finished");
56+
tracing::debug!("init finished");
5757
ctx
5858
}
5959

6060
/// Collects and reports
6161
#[tracing::instrument(name = "SystemInformation::collect", skip(ctx))]
6262
pub fn collect(ctx: &mut CollectContext) -> Self {
63-
tracing::info!("Starting data collection");
63+
tracing::debug!("Starting data collection");
6464

6565
let info = Self {
6666
resources: Some(resources::Resources::collect(&mut ctx.system)),
@@ -74,7 +74,7 @@ impl SystemInformation {
7474
// ..Default::default()
7575
};
7676

77-
tracing::info!("Data collection finished");
77+
tracing::debug!("Data collection finished");
7878
info
7979
}
8080
}

crates/containerdebug/src/system_information/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hickory_resolver::{system_conf::read_system_conf, Resolver};
1+
use hickory_resolver::{Resolver, system_conf::read_system_conf};
22
use local_ip_address::list_afinet_netifas;
33
use serde::Serialize;
44
use std::{

crates/containerdebug/src/system_information/resources.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub struct Resources {
66
pub cpu_count: usize,
77
pub physical_core_count: Option<usize>,
88

9+
pub open_files_limit: Option<usize>,
10+
911
pub total_memory: u64,
1012
pub free_memory: u64,
1113
pub available_memory: u64,
@@ -33,13 +35,16 @@ impl Resources {
3335
);
3436

3537
let cpu_count = sys.cpus().len();
36-
let physical_core_count = sys.physical_core_count();
38+
let physical_core_count = System::physical_core_count();
3739
tracing::info!(
3840
cpus.physical = cpu_count,
3941
cpus.cores.physical = physical_core_count,
4042
"cpus"
4143
);
4244

45+
let open_files_limit = System::open_files_limit();
46+
tracing::info!(open_files.limit = open_files_limit, "open files limit");
47+
4348
let total_memory = sys.total_memory();
4449
let free_memory = sys.free_memory();
4550
let available_memory = sys.available_memory();
@@ -85,6 +90,8 @@ impl Resources {
8590
cpu_count,
8691
physical_core_count,
8792

93+
open_files_limit,
94+
8895
total_memory,
8996
free_memory,
9097
available_memory,

0 commit comments

Comments
 (0)