Skip to content

Commit a3efec7

Browse files
committed
allow metrics-service to compile on macos
1 parent e54f117 commit a3efec7

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

examples/metrics-service/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ aws-config = "1"
1919
aws-sdk-dynamodb = "1"
2020
serde = { version = "1", features = ["derive"] }
2121
serde_json = "1"
22-
dial9-tokio-telemetry = { path = "../../dial9-tokio-telemetry", features = ["cpu-profiling"] }
22+
dial9-tokio-telemetry = { path = "../../dial9-tokio-telemetry" }
2323
reqwest = { version = "0.12", features = ["json"] }
2424
clap = { version = "4", features = ["derive"] }
25+
26+
[target.'cfg(target_os = "linux")'.dependencies]
27+
dial9-tokio-telemetry = { path = "../../dial9-tokio-telemetry", features = ["cpu-profiling"] }

examples/metrics-service/src/main.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use std::time::Duration;
88

99
use aws_config::BehaviorVersion;
1010
use clap::Parser;
11-
use dial9_tokio_telemetry::telemetry::{
12-
CpuProfilingConfig, RotatingWriter, SchedEventConfig, TracedRuntime,
13-
};
11+
use dial9_tokio_telemetry::telemetry::{RotatingWriter, TracedRuntime};
12+
#[cfg(target_os = "linux")]
13+
use dial9_tokio_telemetry::telemetry::{CpuProfilingConfig, SchedEventConfig};
1414
use tokio::runtime::Builder;
1515
use tokio_util::sync::CancellationToken;
1616

@@ -81,14 +81,18 @@ fn main() -> std::io::Result<()> {
8181

8282
let mut builder = Builder::new_multi_thread();
8383
builder.worker_threads(args.worker_threads).enable_all();
84-
let (runtime, guard) = TracedRuntime::builder()
85-
.with_task_tracking(true)
86-
.with_cpu_profiling(CpuProfilingConfig::default())
87-
.with_inline_callframe_symbols(true)
88-
.with_sched_events(SchedEventConfig {
89-
include_kernel: true,
90-
})
91-
.build(builder, Box::new(writer))?;
84+
#[allow(unused_mut)]
85+
let mut traced_builder = TracedRuntime::builder().with_task_tracking(true);
86+
#[cfg(target_os = "linux")]
87+
{
88+
traced_builder = traced_builder
89+
.with_cpu_profiling(CpuProfilingConfig::default())
90+
.with_inline_callframe_symbols(true)
91+
.with_sched_events(SchedEventConfig {
92+
include_kernel: true,
93+
});
94+
}
95+
let (runtime, guard) = traced_builder.build(builder, Box::new(writer))?;
9296
guard.enable();
9397
let handle = guard.handle();
9498

0 commit comments

Comments
 (0)