MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / find_from_env

Method find_from_env

crates/memtrack/src/allocators/mod.rs:84–109  ·  view source on GitHub ↗

Discover allocators from binaries listed in the `CODSPEED_MEMTRACK_BINARIES` env var. The variable is a platform path-list. Each path is checked for a statically linked allocator via [`AllocatorLib::from_path_static`]. Invalid or missing paths are silently skipped (with a debug log).

()

Source from the content-addressed store, hash-verified

82 /// a statically linked allocator via [`AllocatorLib::from_path_static`].
83 /// Invalid or missing paths are silently skipped (with a debug log).
84 fn find_from_env() -> Vec<AllocatorLib> {
85 let Some(raw) = std::env::var_os("CODSPEED_MEMTRACK_BINARIES") else {
86 return vec![];
87 };
88
89 std::env::split_paths(&raw)
90 .filter(|p| !p.as_os_str().is_empty())
91 .filter_map(|p| {
92 let path = p.as_path();
93 match Self::from_path_static(path) {
94 Ok(alloc) => {
95 log::debug!(
96 "Found {} allocator in env-specified binary: {}",
97 alloc.kind.name(),
98 path.display()
99 );
100 Some(alloc)
101 }
102 Err(e) => {
103 log::debug!("Skipping env-specified binary {}: {e}", path.display());
104 None
105 }
106 }
107 })
108 .collect()
109 }
110}
111
112/// Check if a file is an ELF binary by reading its magic bytes.

Callers

nothing calls this directly

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected