Skip to main content

datadog_agent_commons/platform/
mod.rs

1//! Platform-specific settings.
2
3#[cfg(target_os = "linux")]
4mod linux_impl;
5
6use std::path::{Path, PathBuf};
7
8#[cfg(target_os = "linux")]
9pub use self::linux_impl::*;
10
11#[cfg(target_os = "macos")]
12mod macos_impl;
13
14#[cfg(target_os = "macos")]
15pub use self::macos_impl::*;
16
17/// Prefix for all environment variables used by the Datadog Agent.
18pub const DATADOG_AGENT_ENV_VAR_PREFIX: &str = "DD";
19
20/// Platform-specific settings and information.
21pub struct PlatformSettings;
22
23impl PlatformSettings {
24    /// Returns the path to the default Datadog Agent configuration directory.
25    pub fn get_config_dir_path() -> &'static Path {
26        Path::new(DATADOG_AGENT_CONF_DIR)
27    }
28
29    /// Returns the path to the default Datadog Agent configuration file.
30    pub fn get_config_file_path() -> PathBuf {
31        Self::get_config_dir_path().join("datadog.yaml")
32    }
33
34    /// Returns the path to the default Datadog Agent authentication token.
35    pub fn get_auth_token_path() -> PathBuf {
36        Self::get_config_dir_path().join("auth_token")
37    }
38
39    /// Returns the filename of the IPC certificate file.
40    pub fn get_ipc_cert_filename() -> &'static Path {
41        Path::new("ipc_cert.pem")
42    }
43
44    /// Returns the default log file path for the Agent Data Plane.
45    pub fn get_default_log_file_path() -> PathBuf {
46        Path::new(DATADOG_AGENT_LOG_DIR).join("agent-data-plane.log")
47    }
48
49    /// Returns the default DogStatsD debug log file path.
50    pub fn get_default_dogstatsd_log_file_path() -> PathBuf {
51        Path::new(DATADOG_AGENT_LOG_DIR)
52            .join("dogstatsd_info")
53            .join("dogstatsd-stats.log")
54    }
55
56    /// Returns the default local syslog URI used by the Datadog Agent on this platform.
57    pub const fn get_default_syslog_uri() -> &'static str {
58        DATADOG_AGENT_DEFAULT_SYSLOG_URI
59    }
60
61    /// Returns the prefix for all environment variables used by the Datadog Agent.
62    pub const fn get_env_var_prefix() -> &'static str {
63        DATADOG_AGENT_ENV_VAR_PREFIX
64    }
65}