industry40_metrics/
industry40_metrics.rs

1use avila_async::{Runtime, RuntimeConfig};
2use std::time::Duration;
3
4fn main() {
5    // Create runtime with Industry 4.0 features
6    let config = RuntimeConfig {
7        num_threads: Some(4),
8        enable_autoscaling: false,
9        ..Default::default()
10    };
11
12    let rt = Runtime::with_config(config);
13
14    println!("🏭 Industry 4.0 Metrics Dashboard");
15    println!("================================\n");
16
17    rt.block_on(async move {
18        // Spawn multiple tasks to generate metrics
19        for i in 0..20 {
20            rt.spawn(async move {
21                avila_async::sleep(Duration::from_millis(50 * (i % 5) as u64)).await;
22                // Simulate work
23            });
24        }
25
26        // Monitor metrics in real-time
27        for iteration in 0..5 {
28            avila_async::sleep(Duration::from_millis(200)).await;
29
30            let snapshot = rt.metrics().snapshot();
31            let health = rt.health().get_report();
32
33            println!("📊 Iteration {}", iteration + 1);
34            println!("   {}", snapshot);
35            println!("   Health: {} | Ready: {} | Alive: {}",
36                health.status, health.ready, health.alive);
37            println!();
38        }
39
40        // Wait for all tasks to complete
41        while rt.task_count() > 0 {
42            avila_async::sleep(Duration::from_millis(50)).await;
43        }
44
45        println!("📈 Final Metrics Report");
46        println!("=====================");
47        let final_snapshot = rt.metrics().snapshot();
48        println!("{}", final_snapshot);
49        println!();
50
51        println!("🏥 Health Check Report");
52        println!("====================");
53        let health_report = rt.health().get_report();
54        println!("{}", health_report);
55        println!();
56
57        println!("📤 Prometheus Export");
58        println!("===================");
59        println!("{}", rt.metrics().to_prometheus());
60    });
61}