1use fuchsia_sync::Mutex;
6use moniker::Moniker;
7use {fuchsia_inspect as inspect, fuchsia_inspect_contrib as inspect_contrib};
8
9const MAX_NUMBER_OF_ROUTING_ERRORS: usize = 100;
10
11pub struct RoutingErrors {
13 _node: inspect::Node,
14 errors: Mutex<inspect_contrib::nodes::BoundedListNode>,
15}
16
17impl RoutingErrors {
18 pub fn new(node: inspect::Node) -> Self {
19 let errors = inspect_contrib::nodes::BoundedListNode::new(
20 node.create_child("errors"),
21 MAX_NUMBER_OF_ROUTING_ERRORS,
22 );
23 Self { _node: node, errors: Mutex::new(errors) }
24 }
25
26 pub fn record(
27 &self,
28 moniker: &Moniker,
29 capability_name: &str,
30 error: &str,
31 availability: cm_types::Availability,
32 ) {
33 self.errors.lock().add_entry(|node| {
34 node.record_string("moniker", moniker.to_string());
35 node.record_string("capability_name", capability_name);
36 node.record_string("error", error);
37 node.record_string("availability", availability.to_string());
38 });
39 }
40}