Skip to content

Commit d5187fd

Browse files
committed
clenaup examples
1 parent daa4176 commit d5187fd

16 files changed

Lines changed: 72 additions & 29 deletions

dial9-tokio-telemetry/Cargo.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ metrique-writer = "0.1"
4040
metrique = { version = "0.1.20", features = ["local-format"] }
4141

4242
[features]
43+
analysis = []
4344
cpu-profiling = ["dep:dial9-perf-self-profile"]
4445
task-dump = ["tokio/taskdump"]
4546
worker-s3 = ["dep:aws-sdk-s3-transfer-manager", "dep:aws-sdk-s3", "dep:aws-config", "dep:time"]
4647

4748
[dev-dependencies]
49+
dial9-tokio-telemetry = { path = ".", features = ["analysis"] }
4850
assert2 = { workspace = true }
4951
criterion = "0.5"
5052
clap = { version = "4", features = ["derive"] }
@@ -62,7 +64,7 @@ async-trait = "0.1.89"
6264
uuid = { version = "1", features = ["v4"] }
6365

6466
[target.'cfg(target_os = "linux")'.dev-dependencies]
65-
dial9-tokio-telemetry = { path = ".", features = ["cpu-profiling", "worker-s3"] }
67+
dial9-tokio-telemetry = { path = ".", features = ["cpu-profiling", "worker-s3", "analysis"] }
6668
nix = { version = "0.29", features = ["process"] }
6769

6870
[[bench]]
@@ -96,15 +98,27 @@ required-features = ["cpu-profiling"]
9698

9799
[[example]]
98100
name = "cpu_profile_workload"
99-
required-features = ["cpu-profiling"]
101+
required-features = ["cpu-profiling", "analysis"]
100102

101103
[[example]]
102104
name = "s3_stress_test"
103105
required-features = ["worker-s3"]
104106

107+
[[example]]
108+
name = "analyze_trace"
109+
required-features = ["analysis"]
110+
111+
[[example]]
112+
name = "trace_to_jsonl"
113+
required-features = ["analysis"]
114+
115+
[[example]]
116+
name = "trace_to_fat_jsonl"
117+
required-features = ["analysis"]
118+
105119
[[example]]
106120
name = "kernel_sched_events"
107-
required-features = ["cpu-profiling"]
121+
required-features = ["cpu-profiling", "analysis"]
108122

109123
[[bench]]
110124
name = "writer_encode"

dial9-tokio-telemetry/examples/analyze_trace.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use dial9_tokio_telemetry::telemetry::{
2-
TaskId, TelemetryEvent, TraceReader, UNKNOWN_TASK_ID, analyze_trace,
3-
compute_wake_to_poll_delays, detect_idle_workers, print_analysis,
1+
use dial9_tokio_telemetry::analysis_unstable::{
2+
TraceReader, analyze_trace, compute_wake_to_poll_delays, detect_idle_workers, print_analysis,
43
};
4+
use dial9_tokio_telemetry::telemetry::{TaskId, TelemetryEvent, UNKNOWN_TASK_ID};
55
use std::collections::HashMap;
66
use std::env;
77

dial9-tokio-telemetry/examples/cpu_profile_workload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn main() {
6060

6161
// Read back and report
6262
eprintln!("\n=== Reading trace from {trace_path} ===");
63-
let reader = dial9_tokio_telemetry::telemetry::TraceReader::new(trace_path).unwrap();
63+
let reader = dial9_tokio_telemetry::analysis_unstable::TraceReader::new(trace_path).unwrap();
6464
let events = &reader.runtime_events;
6565
let mut cpu_samples = 0;
6666
let mut polls = 0;

dial9-tokio-telemetry/examples/kernel_sched_events.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@
4242
//! ...
4343
//! start_thread
4444
45+
use dial9_tokio_telemetry::analysis_unstable::TraceReader;
4546
use dial9_tokio_telemetry::telemetry::{
46-
CpuSampleSource, RotatingWriter, SchedEventConfig, TelemetryEvent, TraceReader, TracedRuntime,
47+
CpuSampleSource, RotatingWriter, SchedEventConfig, TelemetryEvent, TracedRuntime,
4748
};
4849
use std::time::Duration;
4950

dial9-tokio-telemetry/examples/trace_to_fat_jsonl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
//! Usage:
44
//! cargo run --example trace_to_fat_jsonl -- <input.bin> [output.jsonl]
55
6-
use dial9_tokio_telemetry::telemetry::{TelemetryEvent, TraceReader};
6+
use dial9_tokio_telemetry::analysis_unstable::TraceReader;
7+
use dial9_tokio_telemetry::telemetry::TelemetryEvent;
78
use serde::Serialize;
89
use std::io::{BufWriter, Write};
910

dial9-tokio-telemetry/examples/trace_to_jsonl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! If output is omitted, writes to stdout.
77
8-
use dial9_tokio_telemetry::telemetry::TraceReader;
8+
use dial9_tokio_telemetry::analysis_unstable::TraceReader;
99
use std::io::{BufWriter, Write};
1010

1111
fn main() -> std::io::Result<()> {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//! Trace analysis utilities (**unstable**).
2+
//!
3+
//! This module is feature-gated behind `analysis` and re-exports every public
4+
//! type and function from the internal `telemetry::analysis` implementation.
5+
//!
6+
//! The API surface here is still evolving — hence the `_unstable` suffix.
7+
//! Expect breaking changes between minor versions.
8+
//!
9+
//! # Quick start
10+
//!
11+
//! ```rust,ignore
12+
//! use dial9_tokio_telemetry::analysis_unstable::{TraceReader, analyze_trace, print_analysis};
13+
//!
14+
//! let reader = TraceReader::new("trace.0.bin")?;
15+
//! let analysis = analyze_trace(&reader);
16+
//! print_analysis(&analysis);
17+
//! ```
18+
19+
pub use crate::telemetry::analysis::{
20+
ActivePeriod, LongPoll, SampledPoll, SchedDelay, SpawnLocationStats, TraceAnalysis,
21+
TraceReader, WakeDelay, WorkerStats, analyze_trace, compute_active_periods,
22+
compute_wake_to_poll_delays, detect_idle_workers, detect_long_polls, detect_sampled_polls,
23+
detect_sched_delays, detect_wake_delays, print_analysis,
24+
};

dial9-tokio-telemetry/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![doc = include_str!("../README.md")]
22

3+
#[cfg(feature = "analysis")]
4+
pub mod analysis_unstable;
35
pub mod background_task;
46
pub(crate) mod metrics;
57
pub mod telemetry;

dial9-tokio-telemetry/src/telemetry/mod.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! All public types are re-exported here — use `dial9_tokio_telemetry::telemetry::*`
44
//! rather than reaching into sub-modules.
55
6+
#[cfg(feature = "analysis")]
67
pub(crate) mod analysis;
78
pub(crate) mod buffer;
89
pub(crate) mod collector;
@@ -14,12 +15,6 @@ pub(crate) mod recorder;
1415
pub(crate) mod task_metadata;
1516
pub(crate) mod writer;
1617

17-
pub use analysis::{
18-
ActivePeriod, LongPoll, SampledPoll, SchedDelay, SpawnLocationStats, TraceAnalysis,
19-
TraceReader, WakeDelay, WorkerStats, analyze_trace, compute_active_periods,
20-
compute_wake_to_poll_delays, detect_idle_workers, detect_long_polls, detect_sampled_polls,
21-
detect_sched_delays, detect_wake_delays, print_analysis,
22-
};
2318
#[cfg(feature = "cpu-profiling")]
2419
pub use cpu_profile::CpuProfilingConfig;
2520
#[cfg(feature = "cpu-profiling")]

dial9-tokio-telemetry/src/telemetry/recorder/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ mod tests {
811811
}
812812

813813
#[test]
814+
#[cfg(feature = "analysis")]
814815
fn test_spawn_locations_resolve_after_rotation() {
815816
use crate::telemetry::analysis::TraceReader;
816817
use crate::telemetry::format::WorkerId;
@@ -902,7 +903,7 @@ mod tests {
902903
);
903904
}
904905

905-
#[cfg(feature = "cpu-profiling")]
906+
#[cfg(all(feature = "cpu-profiling", feature = "analysis"))]
906907
mod rotation_proptest {
907908
use super::*;
908909
use crate::telemetry::analysis::TraceReader;

0 commit comments

Comments
 (0)