1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! # slokit
//!
//! An SLO and error-budget engine for Rust.
//!
//! `slokit` does two things:
//!
//! 1. **Library core** (always available): compute error budgets, burn rates,
//! and the multi-window multi-burn-rate (MWMBR) alert model from the Google
//! SRE Workbook. This core has no `serde`, YAML, or CLI dependencies, so it
//! embeds cleanly inside services (for example, an Axum handler that reports
//! live budget status).
//!
//! 2. **Generator** (the `spec` feature, on by default via `cli`): parse a
//! [`sloth`](https://sloth.dev)-compatible YAML spec and generate Prometheus
//! recording rules, metadata rules, and MWMBR page/ticket alert rules.
//!
//! ## Library example
//!
//! ```
//! use slokit::{Objective, Slo, BurnRate, Window};
//!
//! let slo = Slo::new(Objective::percent(99.9).unwrap(), Window::days(30));
//!
//! // With a million events, 0.1% may fail: ~1,000 allowed failures.
//! let budget = slo.error_budget(1_000_000.0);
//! assert!((budget.allowed_bad_events() - 1_000.0).abs() < 1e-6);
//!
//! // Observing a 1% error rate is a 10x burn against a 99.9% objective.
//! let burn = BurnRate::from_error_ratio(0.01, &slo);
//! assert!((burn.value() - 10.0).abs() < 1e-9);
//! ```
//!
//! ## Generating Prometheus rules
//!
//! With the default features enabled:
//!
//! ```ignore
//! use slokit::spec::Spec;
//! use slokit::generate::generate_rules;
//!
//! let spec = Spec::from_yaml(yaml_str)?;
//! let ruleset = generate_rules(&spec)?;
//! println!("{}", ruleset.to_yaml()?);
//! ```
pub use ErrorBudget;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Window;