@@ -18,17 +18,7 @@ The BlackBox system:
1818
1919## Enabling BlackBox
2020
21- ### Via Scheduler Builder (Recommended)
22-
23- ``` rust
24- use horus :: prelude :: * ;
25-
26- // Enable with 16MB buffer
27- let scheduler = Scheduler :: new ()
28- . with_blackbox (16 ); // 16MB flight recorder
29- ```
30-
31- ### Via Deploy Preset
21+ ### Via Deploy Preset (Recommended)
3222
3323The ` deploy() ` preset enables blackbox automatically with 16MB:
3424
@@ -44,13 +34,7 @@ let scheduler = Scheduler::deploy();
4434``` rust
4535use horus :: prelude :: * ;
4636
47- // Using the builder method
48- let config = SchedulerConfig :: standard ()
49- . with_black_box (true , 10 ); // Enabled with 10MB buffer
50-
51- let scheduler = Scheduler :: new (). with_config (config );
52-
53- // Or set fields directly
37+ // Set blackbox fields on SchedulerConfig
5438let mut config = SchedulerConfig :: standard ();
5539config . monitoring. black_box_enabled = true ;
5640config . monitoring. black_box_size_mb = 10 ;
@@ -137,7 +121,7 @@ blackbox.record(BlackBoxEvent::DeadlineMiss {
137121### Get All Events
138122
139123``` rust
140- let events = blackbox . get_events ();
124+ let events = blackbox . events ();
141125println! (" Total events: {}" , events . len ());
142126
143127for record in & events {
@@ -155,7 +139,7 @@ Each `BlackBoxRecord` contains:
155139Filter for error-related events (errors, deadline misses, WCET violations, circuit breaker changes, emergency stops):
156140
157141``` rust
158- let anomalies = blackbox . get_anomalies ();
142+ let anomalies = blackbox . anomalies ();
159143for record in & anomalies {
160144 println! (" [tick {}] {:?}" , record . tick, record . event);
161145}
@@ -178,13 +162,16 @@ The Scheduler provides read and write access to its blackbox:
178162``` rust
179163use horus :: prelude :: * ;
180164
181- let mut scheduler = Scheduler :: new ()
182- . with_blackbox (16 );
165+ let mut config = SchedulerConfig :: standard ();
166+ config . monitoring. black_box_enabled = true ;
167+ config . monitoring. black_box_size_mb = 16 ;
168+
169+ let mut scheduler = Scheduler :: new (). with_config (config );
183170
184171// Read-only access
185172if let Some (bb ) = scheduler . blackbox () {
186- let events = bb . get_events ();
187- let anomalies = bb . get_anomalies ();
173+ let events = bb . events ();
174+ let anomalies = bb . anomalies ();
188175 println! (" Recorded {} events, {} anomalies" , events . len (), anomalies . len ());
189176}
190177
@@ -223,7 +210,7 @@ std::thread::spawn(move || {
223210
224211| Parameter | Default | Description |
225212| -----------| ---------| -------------|
226- | Buffer size | 0 (disabled) | Set via ` BlackBox::new(mb) ` or ` with_blackbox(mb) ` |
213+ | Buffer size | 0 (disabled) | Set via ` BlackBox::new(mb) ` or ` config.monitoring.black_box_size_mb ` |
227214| Records per MB | ~ 5,000 | Estimated at ~ 200 bytes per record |
228215| Max pre-allocated | 100,000 records | Initial capacity cap |
229216| Min buffer | 1,000 records | Minimum regardless of size |
@@ -245,21 +232,20 @@ After a failure, use the blackbox to investigate what happened:
245232``` rust
246233use horus :: prelude :: * ;
247234
248- let mut scheduler = Scheduler :: new ()
249- . with_blackbox (16 );
235+ let mut scheduler = Scheduler :: deploy ();
250236
251237// ... run application ...
252238
253239// After a failure, inspect the blackbox
254240if let Some (bb ) = scheduler . blackbox () {
255- let anomalies = bb . get_anomalies ();
241+ let anomalies = bb . anomalies ();
256242 println! (" === ANOMALIES ({}) ===" , anomalies . len ());
257243 for record in & anomalies {
258244 println! (" [tick {}] {:?}" , record . tick, record . event);
259245 }
260246
261247 // Look at all events around the failure
262- let all_events = bb . get_events ();
248+ let all_events = bb . events ();
263249 println! (" \ n === LAST {} EVENTS ===" , all_events . len ());
264250 for record in all_events . iter (). rev (). take (20 ) {
265251 println! (" [tick {}] {:?}" , record . tick, record . event);
0 commit comments