1#![allow(clippy::mutex_atomic)]
5#![allow(clippy::nonminimal_bool)]
6#![cfg_attr(not(test), deny(clippy::panic))]
7#![cfg_attr(not(test), deny(clippy::unwrap_used))]
8#![cfg_attr(not(test), deny(clippy::expect_used))]
9#![cfg_attr(not(test), deny(clippy::todo))]
10#![cfg_attr(not(test), deny(clippy::unimplemented))]
11
12use libdd_common::entity_id;
13use tracing::debug;
14
15pub mod config;
16pub mod data;
17pub mod info;
18pub mod metrics;
19pub mod worker;
20
21pub fn build_host() -> data::Host {
22 debug!("Building telemetry host information");
23 let hostname = info::os::real_hostname().unwrap_or_else(|_| String::from("unknown_hostname"));
24 let container_id = entity_id::get_container_id().map(|f| f.to_string());
25 let os_version = info::os::os_version().ok();
26
27 debug!(
28 host.hostname = %hostname,
29 host.container_id = ?container_id,
30 host.os = info::os::os_name(),
31 host.os_version = ?os_version,
32 "Built telemetry host information"
33 );
34
35 data::Host {
36 hostname,
37 container_id,
38 os: Some(String::from(info::os::os_name())),
39 os_version,
40 kernel_name: info::os::os_type(),
41 kernel_release: info::os::os_release(),
42 #[cfg(unix)]
43 kernel_version: unsafe { info::os::uname() },
44 #[cfg(windows)]
45 kernel_version: winver::WindowsVersion::detect()
46 .map(|wv| format!("{}.{}.{}", wv.major, wv.minor, wv.build)),
47 #[cfg(not(any(windows, unix)))]
48 kernel_version: None,
49 }
50}