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
//! Synchronous telemetry ports without a runtime or backend dependency.
use cratePrivateReport;
use ;
/// Metadata-only hook for expected Problems and unexpected Faults.
///
/// Implementations run synchronously on the request lifecycle and must be
/// fast, nonblocking, nonpanicking, and internally bounded. Framework adapters
/// may contain unwinding panics, but cannot make blocking or unbounded work safe.
/// Separate private-error reporting port for unexpected faults.
///
/// This port has no blanket no-op implementation. Dropping a private report
/// discards the only record of an unexpected failure, so an application states
/// that intent through its adapter configuration rather than by leaving the
/// port unset.
///
/// Implementations run synchronously on the request lifecycle and must be
/// fast, nonblocking, nonpanicking, and internally bounded. Prefer a nonblocking
/// send into an application-owned bounded channel when reporting elsewhere.
///
/// A runtime-neutral reporter can hand an owned record to a bounded worker
/// without waiting on the request path:
///
/// ```
/// use std::sync::mpsc::SyncSender;
///
/// use recourse::{
/// fault::PrivateReport,
/// observe::{FaultEvent, FaultReporter},
/// };
///
/// #[derive(Debug)]
/// struct BoundedReporter(SyncSender<(String, String)>);
///
/// impl FaultReporter for BoundedReporter {
/// fn report_fault(&self, event: &FaultEvent, report: &PrivateReport) {
/// let record = (
/// event.problem_metadata().code().to_string(),
/// report.to_string(),
/// );
/// let _dropped_or_closed = self.0.try_send(record).is_err();
/// }
/// }
/// ```
/// Metadata-only observation is optional, so `()` observes nothing.