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
#[must_use]
#[inline]
pub fn trace_enable<T: Into<u32>>(
event: T,
) -> (
crate::trace_local::LocalTraceGuard,
crate::collector::Collector,
) {
let collector = crate::collector::Collector::new();
let now = crate::time::real_time_ns();
let (trace_guard, _) = crate::trace_local::LocalTraceGuard::new(
collector.inner.clone(),
event,
crate::Link::Root,
now,
now,
)
.unwrap();
(trace_guard, collector)
}
#[must_use]
#[inline]
pub fn trace_may_enable<T: Into<u32>>(
enable: bool,
event: T,
) -> (
Option<crate::trace_local::LocalTraceGuard>,
Option<crate::collector::Collector>,
) {
if enable {
let (guard, collector) = trace_enable(event);
(Some(guard), Some(collector))
} else {
(None, None)
}
}
#[must_use]
#[inline]
pub fn new_span<T: Into<u32>>(event: T) -> Option<crate::trace_local::SpanGuard> {
crate::trace_local::SpanGuard::new(event.into())
}
#[must_use]
#[inline]
pub fn trace_crossthread<T: Into<u32>>(event: T) -> crate::trace_crossthread::CrossthreadTrace {
crate::trace_crossthread::CrossthreadTrace::new(event.into())
}