pub struct Wrapper<T>(pub T);Expand description
Generic wrapper to facilitate the addition of new methods to the wrapped type.
Tuple Fields§
§0: TImplementations§
Source§impl<K> Wrapper<BTreeMap<K, Histogram<u64>>>
impl<K> Wrapper<BTreeMap<K, Histogram<u64>>>
Sourcepub fn aggregate<G>(&self, f: impl Fn(&K) -> G) -> TimingsView<G>where
G: Ord,
pub fn aggregate<G>(&self, f: impl Fn(&K) -> G) -> TimingsView<G>where
G: Ord,
Combines histogram values according to sets of keys that yield the same value when f
is applied.
Sourcepub fn add(&mut self, other: TimingsView<K>)where
K: Ord,
pub fn add(&mut self, other: TimingsView<K>)where
K: Ord,
Combines the histograms of self with those of another TimingsView.
Sourcepub fn summary_stats(&self) -> Wrapper<BTreeMap<K, SummaryStats>>
pub fn summary_stats(&self) -> Wrapper<BTreeMap<K, SummaryStats>>
Produces a map whose values are the SummaryStats of self’s histogram values.
Source§impl Wrapper<BTreeMap<SpanGroup, Histogram<u64>>>
impl Wrapper<BTreeMap<SpanGroup, Histogram<u64>>>
Sourcepub fn aggregator_is_consistent<G>(&self, f: impl Fn(&SpanGroup) -> G) -> boolwhere
G: Ord,
pub fn aggregator_is_consistent<G>(&self, f: impl Fn(&SpanGroup) -> G) -> boolwhere
G: Ord,
Checks whether an aggregation function f used in Self::aggregate is consistent according to the following
definition:
- the values resulting from applying
fto span groups are called aggregate keys - the sets of span groups corresponding to each aggregate key are called aggregates.
- an aggregation function is consistent if and only if, for each aggregate, all the span groups in the aggregate have the same callsite.
Source§impl<K, V> Wrapper<BTreeMap<K, V>>
impl<K, V> Wrapper<BTreeMap<K, V>>
Sourcepub fn map_values<V1, BV>(
&self,
f: impl FnMut(&BV) -> V1,
) -> Wrapper<BTreeMap<K, V1>>
pub fn map_values<V1, BV>( &self, f: impl FnMut(&BV) -> V1, ) -> Wrapper<BTreeMap<K, V1>>
Returns a new Wrapper<BTreeMap> with the same keys as self and values corresponding to the
invocation of function f on the original values.
Examples found in repository?
examples/doc_sync.rs (line 32)
26fn main() {
27 let latencies = LatencyTrace::activated_default()
28 .unwrap()
29 .measure_latencies(f);
30
31 println!("\nLatency stats below are in microseconds");
32 for (span_group, stats) in latencies.map_values(summary_stats) {
33 println!(" * {:?}, {:?}", span_group, stats);
34 }
35
36 // A shorter way to print the summary stats, with uglier formatting.
37 println!("\nDebug print of `latencies.map_values(summary_stats)`:");
38 println!("{:?}", latencies.map_values(summary_stats));
39}More examples
examples/doc_async.rs (line 33)
27fn main() {
28 let latencies = LatencyTrace::activated_default()
29 .unwrap()
30 .measure_latencies_tokio(f);
31
32 println!("\nLatency stats below are in microseconds");
33 for (span_group, stats) in latencies.map_values(summary_stats) {
34 println!(" * {:?}, {:?}", span_group, stats);
35 }
36
37 // A shorter way to print the summary stats, with uglier formatting.
38 println!("\nDebug print of `latencies.map_values(summary_stats)`:");
39 println!("{:?}", latencies.map_values(summary_stats));
40}examples/doc_sync_probed.rs (line 39)
26fn main() {
27 let probed = LatencyTrace::activated_default()
28 .unwrap()
29 .measure_latencies_probed(f)
30 .unwrap();
31
32 // Let the function run for some time before probing latencies.
33 thread::sleep(Duration::from_micros(16000));
34
35 let latencies1 = probed.probe_latencies();
36 let latencies2 = probed.wait_and_report();
37
38 println!("\nlatencies1 in microseconds");
39 for (span_group, stats) in latencies1.map_values(summary_stats) {
40 println!(" * {:?}, {:?}", span_group, stats);
41 }
42
43 println!("\nlatencies2 in microseconds");
44 for (span_group, stats) in latencies2.map_values(summary_stats) {
45 println!(" * {:?}, {:?}", span_group, stats);
46 }
47}examples/doc_async_probed.rs (line 40)
27fn main() {
28 let probed = LatencyTrace::activated_default()
29 .unwrap()
30 .measure_latencies_probed_tokio(f)
31 .unwrap();
32
33 // Let the function run for some time before probing latencies.
34 thread::sleep(Duration::from_micros(48000));
35
36 let latencies1 = probed.probe_latencies();
37 let latencies2 = probed.wait_and_report();
38
39 println!("\nlatencies1 in microseconds");
40 for (span_group, stats) in latencies1.map_values(summary_stats) {
41 println!(" * {:?}, {:?}", span_group, stats);
42 }
43
44 println!("\nlatencies2 in microseconds");
45 for (span_group, stats) in latencies2.map_values(summary_stats) {
46 println!(" * {:?}, {:?}", span_group, stats);
47 }
48}examples/doc_sync_layered.rs (line 55)
32fn main() {
33 // LatencyTrace instance from which latency statistics will be extracted later.
34 let lt = LatencyTrace::default();
35
36 // Clone of the above that will be used as a `tracing_subscriber::layer::Layer` that can be
37 // composed with other tracing layers. Add a filter so that only spans with level `INFO` or
38 // higher priority (lower level) are aggregated.
39 let ltl = lt.clone().with_filter(LevelFilter::INFO);
40
41 // `tracing_subscriber::fmt::Layer` that can be composed with the above `LatencyTrace` layer.
42 // Spans with level `TRACE` or higher priority (lower level) are displayed.
43 let tfmt = tracing_subscriber::fmt::layer()
44 .with_span_events(FmtSpan::FULL)
45 .with_filter(LevelFilter::TRACE);
46
47 // Instantiate a layered subscriber and set it as the global default.
48 let layered = Registry::default().with(ltl).with(tfmt);
49 layered.init();
50
51 // Measure latencies.
52 let latencies = lt.measure_latencies(f);
53
54 println!("\nLatency stats below are in microseconds");
55 for (span_group, stats) in latencies.map_values(summary_stats) {
56 println!(" * {:?}, {:?}", span_group, stats);
57 }
58
59 // A shorter way to print the summary stats, with uglier formatting.
60 println!("\nDebug print of `latencies.map_values(summary_stats)`:");
61 println!("{:?}", latencies.map_values(summary_stats));
62}Trait Implementations§
Source§impl<'a, T> IntoIterator for &'a Wrapper<T>where
&'a T: IntoIterator,
impl<'a, T> IntoIterator for &'a Wrapper<T>where
&'a T: IntoIterator,
Source§impl<'a, T> IntoIterator for &'a mut Wrapper<T>where
&'a mut T: IntoIterator,
impl<'a, T> IntoIterator for &'a mut Wrapper<T>where
&'a mut T: IntoIterator,
Source§impl<T> IntoIterator for Wrapper<T>where
T: IntoIterator,
impl<T> IntoIterator for Wrapper<T>where
T: IntoIterator,
Source§impl<T: Ord> Ord for Wrapper<T>
impl<T: Ord> Ord for Wrapper<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for Wrapper<T>
impl<T: PartialOrd> PartialOrd for Wrapper<T>
impl<T: Eq> Eq for Wrapper<T>
impl<T> StructuralPartialEq for Wrapper<T>
Auto Trait Implementations§
impl<T> Freeze for Wrapper<T>where
T: Freeze,
impl<T> RefUnwindSafe for Wrapper<T>where
T: RefUnwindSafe,
impl<T> Send for Wrapper<T>where
T: Send,
impl<T> Sync for Wrapper<T>where
T: Sync,
impl<T> Unpin for Wrapper<T>where
T: Unpin,
impl<T> UnwindSafe for Wrapper<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more