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
//! Watching effects for metrics.
//!
//! An [`EffectObserver`] (`RuntimeBuilder::observer`) is told about every
//! effect the runtime records and every transition it stores, after the
//! write succeeds. That covers calls, recovery, compensation, approval and
//! operator decisions alike. That is enough for every metric that matters:
//!
//! - counts by transition or by status reached (committed, failed, unknown,
//! retries, compensations);
//! - attempt duration ([`Observation::in_previous_status`] when leaving
//! `Executing`);
//! - time spent unknown (the same, when leaving `Unknown`);
//! - end-to-end duration ([`Observation::since_created`] when settling);
//! - levels such as "awaiting approval", as up/down counts. These are deltas
//! since the observer started; for exact current numbers, query
//! [`Runtime::pending`](crate::Runtime::pending).
//!
//! The core crate depends on no metrics library; `agent-effects-otel`
//! implements an observer with OpenTelemetry. An observer that panics is
//! caught and logged: a metrics bug must never break an effect whose
//! transition is already stored.
use Duration;
use crate;
use crateEffectRecord;
/// One stored transition.
/// Receives effect lifecycle events, for metrics. Both methods default to
/// doing nothing.
///
/// Calls are synchronous and run on the runtime's tasks: keep them cheap
/// (increment a counter, record a histogram), and hand anything slow to
/// another task.