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 stdlib;
31pub mod step_machine;
33pub mod telemetry;
35pub mod wasm;
37pub mod workflow_machine;
39
40use once_cell::sync::Lazy;
41use opentelemetry::{
42 global,
43 metrics::{Counter, Histogram},
44};
45use std::time::Duration;
46
47pub static RUNS_STARTED: Lazy<Counter<u64>> = Lazy::new(|| {
49 global::meter("stormchaser-engine")
50 .u64_counter("stormchaser.v1.runs_started")
51 .with_description("Total number of runs started")
52 .build()
53});
54
55pub static RUNS_COMPLETED: Lazy<Counter<u64>> = Lazy::new(|| {
57 global::meter("stormchaser-engine")
58 .u64_counter("stormchaser.v1.runs_completed")
59 .with_description("Total number of runs completed successfully")
60 .build()
61});
62
63pub static RUNS_FAILED: Lazy<Counter<u64>> = Lazy::new(|| {
65 global::meter("stormchaser-engine")
66 .u64_counter("stormchaser.v1.runs_failed")
67 .with_description("Total number of runs failed")
68 .build()
69});
70
71pub static STEPS_STARTED: Lazy<Counter<u64>> = Lazy::new(|| {
73 global::meter("stormchaser-engine")
74 .u64_counter("stormchaser.v1.steps_started")
75 .with_description("Total number of steps started")
76 .build()
77});
78
79pub static STEPS_COMPLETED: Lazy<Counter<u64>> = Lazy::new(|| {
81 global::meter("stormchaser-engine")
82 .u64_counter("stormchaser.v1.steps_completed")
83 .with_description("Total number of steps completed successfully")
84 .build()
85});
86
87pub static STEPS_FAILED: Lazy<Counter<u64>> = Lazy::new(|| {
89 global::meter("stormchaser-engine")
90 .u64_counter("stormchaser.v1.steps_failed")
91 .with_description("Total number of steps failed")
92 .build()
93});
94
95pub static STEP_DURATION: Lazy<Histogram<f64>> = Lazy::new(|| {
97 global::meter("stormchaser-engine")
98 .f64_histogram("stormchaser.v1.step_duration_seconds")
99 .with_description("Duration of step execution in seconds")
100 .build()
101});
102
103pub fn parse_duration(s: &str) -> anyhow::Result<Duration> {
105 Ok(humantime::parse_duration(s)?)
106}
107
108#[cfg(test)]
109mod tests {
110 use super::*;
111
112 #[test]
113 fn test_parse_duration() {
114 assert_eq!(parse_duration("10s").unwrap(), Duration::from_secs(10));
115 assert_eq!(parse_duration("5m").unwrap(), Duration::from_secs(300));
116 assert_eq!(parse_duration("1h").unwrap(), Duration::from_secs(3600));
117 assert_eq!(parse_duration("1d").unwrap(), Duration::from_secs(86400));
118 assert_eq!(parse_duration("2h 30m").unwrap(), Duration::from_secs(9000));
119 }
120}