use std::fmt;
#[derive(Debug, Clone)]
pub struct ConsoleIntegrationConfig {
pub console_compatible: bool,
pub filter_short_tasks: bool,
pub min_duration_ms: u64,
}
impl Default for ConsoleIntegrationConfig {
fn default() -> Self {
Self {
console_compatible: true,
filter_short_tasks: true,
min_duration_ms: 10,
}
}
}
impl fmt::Display for ConsoleIntegrationConfig {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"ConsoleIntegration {{ compatible: {}, filter: {}, min_ms: {} }}",
self.console_compatible, self.filter_short_tasks, self.min_duration_ms
)
}
}
#[must_use]
pub fn is_console_active() -> bool {
std::env::var("RUSTFLAGS")
.map(|flags| flags.contains("tokio_unstable"))
.unwrap_or(false)
}
pub fn print_integration_info() {
println!("╔════════════════════════════════════════════════════════════╗");
println!("║ async-inspect + tokio-console Integration ║");
println!("╚════════════════════════════════════════════════════════════╝\n");
if is_console_active() {
println!("✅ tokio-console appears to be active");
println!(" Both tools will work together seamlessly!\n");
} else {
println!("ℹ️ tokio-console not detected");
println!(" To enable: RUSTFLAGS=\"--cfg tokio_unstable\" cargo run\n");
}
println!("📊 Tool Comparison:");
println!("┌─────────────────────┬──────────────┬──────────────┐");
println!("│ Feature │ tokio-console│ async-inspect│");
println!("├─────────────────────┼──────────────┼──────────────┤");
println!("│ Real-time monitoring│ ✅ │ ✅ │");
println!("│ Historical export │ ❌ │ ✅ │");
println!("│ Graph analysis │ ❌ │ ✅ │");
println!("│ Deadlock detection │ ❌ │ ✅ │");
println!("│ Production ready │ ❌ │ ✅ │");
println!("│ Zero overhead │ ❌ │ ✅ (opt) │");
println!("└─────────────────────┴──────────────┴──────────────┘\n");
println!("💡 Recommendations:");
println!(" • Development: Use tokio-console for live debugging");
println!(" • Production: Use async-inspect with sampling");
println!(" • CI/CD: Compare async-inspect exports");
println!(" • Post-mortem: Analyze exported JSON/CSV traces\n");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_config() {
let config = ConsoleIntegrationConfig::default();
assert!(config.console_compatible);
}
}