#tracing #perf #tracing-subscriber

tracing-timing

在跟踪之上的事件间时间度量

25次发布

0.6.0 2022年3月11日
0.5.0 2021年5月15日
0.4.4 2021年5月13日
0.4.3 2020年2月6日
0.2.12 2019年7月16日

#162性能分析

Download history 491/week @ 2024-04-20 476/week @ 2024-04-27 437/week @ 2024-05-04 665/week @ 2024-05-11 460/week @ 2024-05-18 395/week @ 2024-05-25 845/week @ 2024-06-01 843/week @ 2024-06-08 813/week @ 2024-06-15 319/week @ 2024-06-22 280/week @ 2024-06-29 284/week @ 2024-07-06 499/week @ 2024-07-13 481/week @ 2024-07-20 589/week @ 2024-07-27 345/week @ 2024-08-03

1,940 每月下载量
2 crates 中使用

MIT 许可证

61KB
914 代码行

Crates.io Documentation Codecov Dependency status

tracing 之上的事件间时间度量。

这个crate提供了一个 tracing::Subscriber,它可以记录事件间时间信息的统计数据。更具体地说,给定如下代码

use tracing::*;
use tracing_timing::{Builder, Histogram};
let subscriber = Builder::default().build(|| Histogram::new_with_max(1_000_000, 2).unwrap());
let dispatcher = Dispatch::new(subscriber);
dispatcher::with_default(&dispatcher, || {
    trace_span!("request").in_scope(|| {
        // do a little bit of work
        trace!("fast");
        // do a lot of work
        trace!("slow");
    })
});

你可以生成如下内容(参见 examples/pretty.rs

fast:
mean: 173.2µs, p50: 172µs, p90: 262µs, p99: 327µs, p999: 450µs, max: 778µs
  25µs | *                                        |  2.2th %-ile
  50µs | *                                        |  2.2th %-ile
  75µs | *                                        |  4.7th %-ile
 100µs | ***                                      | 11.5th %-ile
 125µs | *****                                    | 24.0th %-ile
 150µs | *******                                  | 41.1th %-ile
 175µs | ********                                 | 59.2th %-ile
 200µs | *******                                  | 75.4th %-ile
 225µs | **                                       | 80.1th %-ile
 250µs | ***                                      | 87.3th %-ile
 275µs | ***                                      | 94.4th %-ile
 300µs | **                                       | 97.8th %-ile

slow:
mean: 623.3µs, p50: 630µs, p90: 696µs, p99: 770µs, p999: 851µs, max: 950µs
 500µs | *                                        |  1.6th %-ile
 525µs | **                                       |  4.8th %-ile
 550µs | ***                                      | 10.9th %-ile
 575µs | *****                                    | 22.2th %-ile
 600µs | *******                                  | 37.9th %-ile
 625µs | ********                                 | 55.9th %-ile
 650µs | *******                                  | 72.9th %-ile
 675µs | ******                                   | 85.6th %-ile
 700µs | ****                                     | 93.5th %-ile
 725µs | **                                       | 97.1th %-ile

TimingSubscriber 被用作 tracing::Dispatch 时,使用 quanta 测量事件间的跨度时间,并使用 高动态范围直方图hdrhistogram 的多线程记录功能记录下来。记录的时间信息使用 SpanGroupEventGroup 特性进行分组,允许你跨跨度组合记录的统计信息。

依赖

~2.4–4.5MB
~74K SLoC