Skip to content
Merged
Show file tree
Hide file tree
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
28 changes: 12 additions & 16 deletions crates/countersyncd/src/actor/otel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ const MAX_EXPORT_RETRIES: u64 = 30;
/// Configuration for the OtelActor
#[derive(Debug, Clone)]
pub struct OtelActorConfig {
/// Whether to print statistics to console
pub print_to_console: bool,
/// OpenTelemetry collector endpoint
pub collector_endpoint: String,
/// Max counters to accumulate before forcing an export
Expand All @@ -56,7 +54,6 @@ pub struct OtelActorConfig {
impl Default for OtelActorConfig {
fn default() -> Self {
Self {
print_to_console: true,
collector_endpoint: "http://localhost:4317".to_string(),
max_counters_per_export: 10_000,
flush_timeout: Duration::from_secs(1),
Expand Down Expand Up @@ -139,8 +136,7 @@ impl OtelActor {
};

info!(
"OtelActor initialized - console: {}, endpoint: {}",
config.print_to_console,
"OtelActor initialized - endpoint: {}",
config.collector_endpoint
);

Expand Down Expand Up @@ -221,7 +217,7 @@ impl OtelActor {
let otel_metrics = OtelMetrics::from_sai_stats(&stats);
let counters_in_message = stats.stats.len();

if self.config.print_to_console {
if log::log_enabled!(log::Level::Debug) {
self.print_otel_metrics(&otel_metrics).await;
}

Expand All @@ -245,7 +241,7 @@ impl OtelActor {
async fn print_otel_metrics(&mut self, otel_metrics: &OtelMetrics) {
self.console_reports += 1;

info!(
debug!(
"[OTel Report #{}] Service: {}, Scope: {} v{}, Total Gauges: {}, Messages Received: {}, Exports: {} (Failures: {})",
self.console_reports,
otel_metrics.service_name,
Expand All @@ -258,24 +254,24 @@ impl OtelActor {
);

if !otel_metrics.is_empty() {
info!("Gauge Metrics:");
debug!("Gauge Metrics:");
for (index, gauge) in otel_metrics.gauges.iter().enumerate() {
let data_point = &gauge.data_points[0];

info!("[{:3}] Gauge: {}", index + 1, gauge.name);
info!("Value: {}", data_point.value);
info!("Unit: {}", gauge.unit);
info!("Time: {}ns", data_point.time_unix_nano);
info!("Description: {}", gauge.description);
debug!("[{:3}] Gauge: {}", index + 1, gauge.name);
debug!("Value: {}", data_point.value);
debug!("Unit: {}", gauge.unit);
debug!("Time: {}ns", data_point.time_unix_nano);
debug!("Description: {}", gauge.description);

if !data_point.attributes.is_empty() {
info!("Attributes:");
debug!("Attributes:");
for attr in &data_point.attributes {
info!(" - {}={}", attr.key, attr.value);
debug!(" - {}={}", attr.key, attr.value);
}
}

info!("Raw Gauge: {:#?}", gauge);
debug!("Raw Gauge: {:#?}", gauge);
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions crates/countersyncd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,6 @@ struct Args {
)]
otel_endpoint: String,

/// Enable OpenTelemetry console output
#[arg(
long,
default_value = "true",
help = "Print OpenTelemetry metrics to console"
)]
otel_console: bool,

/// Channel capacity for otel communication
#[arg(
long,
Expand Down Expand Up @@ -234,7 +226,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
info!("OpenTelemetry export enabled: {}", args.enable_otel);
if args.enable_otel {
info!("OpenTelemetry endpoint: {}", args.otel_endpoint);
info!("OpenTelemetry console output: {}", args.otel_console);
info!(
"OpenTelemetry batching: max_counters_per_export={}, flush_timeout_ms={}",
args.otel_max_counters_per_export, args.otel_flush_timeout_ms
Expand Down Expand Up @@ -331,7 +322,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure OpenTelemetry export with settings from command line arguments
let otel_actor = if args.enable_otel {
let otel_config = OtelActorConfig {
print_to_console: args.otel_console,
collector_endpoint: args.otel_endpoint.clone(),
max_counters_per_export: args.otel_max_counters_per_export,
flush_timeout: std::time::Duration::from_millis(args.otel_flush_timeout_ms),
Expand Down
Loading