mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 09:09:17 +00:00
feat(core): add gated LTTng tracing
This commit is contained in:
@@ -37,6 +37,7 @@ tracing-subscriber = { version = "0.3", features = [
|
||||
"local-time",
|
||||
"time",
|
||||
] }
|
||||
lttng-ust = { git = "https://github.com/EasyTier/lttng-ust-rs.git", optional = true }
|
||||
derivative = "2.2.0"
|
||||
derive_more = { version = "2.1.1", features = ["full"] }
|
||||
console-subscriber = { version = "0.4.1", optional = true }
|
||||
@@ -329,6 +330,7 @@ quote = "1"
|
||||
thunk-rs = { git = "https://github.com/easytier/thunk.git", default-features = false, features = [
|
||||
"win7",
|
||||
] }
|
||||
lttng-ust-generate = { git = "https://github.com/EasyTier/lttng-ust-rs.git", optional = true }
|
||||
|
||||
[target.'cfg(windows)'.build-dependencies]
|
||||
reqwest = { version = "0.12.12", features = ["blocking"] }
|
||||
@@ -402,6 +404,7 @@ jemalloc-prof = [
|
||||
"jemalloc-sys/stats",
|
||||
]
|
||||
tracing = ["tokio/tracing", "dep:console-subscriber"]
|
||||
lttng = ["dep:lttng-ust", "dep:lttng-ust-generate"]
|
||||
magic-dns = ["dep:hickory-client", "dep:hickory-server"]
|
||||
faketcp = ["dep:flume"]
|
||||
zstd = ["dep:zstd"]
|
||||
|
||||
@@ -133,6 +133,33 @@ fn check_locale() {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "lttng")]
|
||||
fn generate_lttng_tracepoints(out: &PathBuf) -> Result<(), Box<dyn std::error::Error>> {
|
||||
use lttng_ust_generate::{CIntegerType, CTFType, Generator, LogLevel, Provider};
|
||||
|
||||
let mut provider = Provider::new("easytier");
|
||||
provider
|
||||
.create_class("marker")
|
||||
.add_field("name", CTFType::SequenceText)
|
||||
.add_field("value", CTFType::Integer(CIntegerType::U64))
|
||||
.instantiate_with_level("mark", LogLevel::Info);
|
||||
|
||||
provider
|
||||
.create_class("duration")
|
||||
.add_field("name", CTFType::SequenceText)
|
||||
.add_field("duration_micros", CTFType::Integer(CIntegerType::U64))
|
||||
.instantiate_with_level("duration_micros", LogLevel::Info);
|
||||
|
||||
Generator::default()
|
||||
.generated_lib_name("easytier_lttng_tracepoints")
|
||||
.register_provider(provider)
|
||||
.output_file_name(out.join("lttng_tracepoints.rs"))
|
||||
.generate()
|
||||
.map_err(|_| std::io::Error::other("failed to generate LTTng tracepoints"))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
cfg_aliases! {
|
||||
mobile: {
|
||||
@@ -174,6 +201,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
let out = PathBuf::from(env::var("OUT_DIR")?);
|
||||
#[cfg(feature = "lttng")]
|
||||
generate_lttng_tracepoints(&out)?;
|
||||
|
||||
let descriptor = out.join("descriptors.bin");
|
||||
|
||||
let mut config = prost_build::Config::new();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#[cfg(feature = "lttng")]
|
||||
lttng_ust::import_tracepoints!(
|
||||
concat!(env!("OUT_DIR"), "/lttng_tracepoints.rs"),
|
||||
tracepoints
|
||||
);
|
||||
|
||||
#[cfg(feature = "lttng")]
|
||||
pub fn mark(name: &str, value: u64) {
|
||||
tracepoints::easytier::mark(name, value);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "lttng"))]
|
||||
#[inline(always)]
|
||||
pub fn mark(_name: &str, _value: u64) {}
|
||||
|
||||
#[cfg(feature = "lttng")]
|
||||
pub fn duration_micros(name: &str, duration_micros: u64) {
|
||||
tracepoints::easytier::duration_micros(name, duration_micros);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "lttng"))]
|
||||
#[inline(always)]
|
||||
pub fn duration_micros(_name: &str, _duration_micros: u64) {}
|
||||
@@ -18,6 +18,7 @@ pub mod global_ctx;
|
||||
pub mod idn;
|
||||
pub mod ifcfg;
|
||||
pub mod log;
|
||||
pub mod lttng;
|
||||
pub mod machine_id;
|
||||
pub mod netns;
|
||||
pub mod network;
|
||||
|
||||
Reference in New Issue
Block a user