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
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
use crate::io_type::IOType;
use uuid::Uuid;
/// A wrapper containing a trace event with context information.
pub struct EventEnvelope {
/// The index of the thread that generated this event.
pub thread_index: u8,
/// The index of the task that generated this event.
pub task_index: u16,
/// The trace event.
pub event: Events,
}
/// Trace events emitted by the runtime for debugging and performance analysis.
pub enum Events {
TaskScheduled {
activity_id: Uuid,
tenant_id: Uuid,
tag: u32,
io: bool,
},
TaskRunEnd {
activity_id: Uuid,
start_time: u64,
tag: u32,
cpu: u16,
action: u8,
complete: bool,
},
RingEnterEnd {
submissions: u64,
in_flight_io: u64,
start_time: u64,
completions: u64,
tag: u32,
task_count: u32,
want: bool,
iopoll: bool,
},
AsyncWaitStart {
activity_id: Uuid,
tag: u32,
},
AsyncWaitEnd {
activity_id: Uuid,
tag: u32,
},
IoStart {
activity_id: Uuid,
fd: i32,
tag: u32,
io_type: IOType,
},
IoEnd {
activity_id: Uuid,
result: i32,
tag: u32,
},
IoError {
activity_id: Uuid,
tag: u32,
error: i32,
},
#[cfg(feature = "tls")]
TlsError {
activity_id: Uuid,
code: u64,
},
FutureCanceled {
activity_id: Uuid,
},
}
/// A trait for receiving trace events from the runtime.
///
/// Implement this trait to collect and process runtime trace events.
pub trait TraceConfiguration: Send {
/// Called when a trace event is emitted.
fn trace(&self, event: EventEnvelope);
}