stormchaser_engine/
lib.rs1pub mod artifact;
8pub mod db;
10pub mod git_cache;
12pub mod handler;
14pub mod hcl_eval;
16pub mod hitl;
18pub mod junit;
20pub mod nats;
22pub mod persistence;
24pub mod resource_utils;
26pub mod s3;
28pub mod secrets;
30pub mod step_machine;
32pub mod telemetry;
34pub mod wasm;
36pub mod workflow_machine;
38
39use once_cell::sync::Lazy;
40use opentelemetry::{
41 global,
42 metrics::{Counter, Histogram},
43};
44use std::time::Duration;
45
46pub static RUNS_STARTED: Lazy<Counter<u64>> = Lazy::new(|| {
48 global::meter("stormchaser-engine")
49 .u64_counter("stormchaser.runs_started")
50 .with_description("Total number of runs started")
51 .build()
52});
53
54pub static RUNS_COMPLETED: Lazy<Counter<u64>> = Lazy::new(|| {
56 global::meter("stormchaser-engine")
57 .u64_counter("stormchaser.runs_completed")
58 .with_description("Total number of runs completed successfully")
59 .build()
60});
61
62pub static RUNS_FAILED: Lazy<Counter<u64>> = Lazy::new(|| {
64 global::meter("stormchaser-engine")
65 .u64_counter("stormchaser.runs_failed")
66 .with_description("Total number of runs failed")
67 .build()
68});
69
70pub static STEPS_STARTED: Lazy<Counter<u64>> = Lazy::new(|| {
72 global::meter("stormchaser-engine")
73 .u64_counter("stormchaser.steps_started")
74 .with_description("Total number of steps started")
75 .build()
76});
77
78pub static STEPS_COMPLETED: Lazy<Counter<u64>> = Lazy::new(|| {
80 global::meter("stormchaser-engine")
81 .u64_counter("stormchaser.steps_completed")
82 .with_description("Total number of steps completed successfully")
83 .build()
84});
85
86pub static STEPS_FAILED: Lazy<Counter<u64>> = Lazy::new(|| {
88 global::meter("stormchaser-engine")
89 .u64_counter("stormchaser.steps_failed")
90 .with_description("Total number of steps failed")
91 .build()
92});
93
94pub static STEP_DURATION: Lazy<Histogram<f64>> = Lazy::new(|| {
96 global::meter("stormchaser-engine")
97 .f64_histogram("stormchaser.step_duration_seconds")
98 .with_description("Duration of step execution in seconds")
99 .build()
100});
101
102pub fn parse_duration(s: &str) -> anyhow::Result<Duration> {
104 Ok(humantime::parse_duration(s)?)
105}
106
107#[cfg(test)]
108mod tests {
109 use super::*;
110
111 #[test]
112 fn test_parse_duration() {
113 assert_eq!(parse_duration("10s").unwrap(), Duration::from_secs(10));
114 assert_eq!(parse_duration("5m").unwrap(), Duration::from_secs(300));
115 assert_eq!(parse_duration("1h").unwrap(), Duration::from_secs(3600));
116 assert_eq!(parse_duration("1d").unwrap(), Duration::from_secs(86400));
117 assert_eq!(parse_duration("2h 30m").unwrap(), Duration::from_secs(9000));
118 }
119}