Add shared OTLP telemetry and propagate command traces across agents
This commit is contained in:
29 files changed
+1227
-213
No files matched your search
@@ -113,6 +113,9 @@ pub fn write_init_config(args: &InitConfigArgs) -> Result<Option<PathBuf>> {
|
||||
ui_dist_dir,
|
||||
bootstrap_enroll_tokens,
|
||||
telemetry: WritableTelemetry {
|
||||
authorization_env: base_telemetry
|
||||
.authorization_env
|
||||
.or_else(|| defaults.telemetry.authorization_env.clone()),
|
||||
otlp_endpoint: args
|
||||
.telemetry_otlp_endpoint
|
||||
.clone()
|
||||
@@ -223,6 +226,7 @@ bootstrap_enroll_tokens = ["old-token"]
|
||||
|
||||
[telemetry]
|
||||
otlp_endpoint = "http://otel.example"
|
||||
authorization_env = "WAKEY_OTLP_AUTHORIZATION"
|
||||
service_name = "old-service"
|
||||
json_logs = true
|
||||
"#,
|
||||
@@ -261,6 +265,10 @@ json_logs = true
|
||||
Some("/tmp/wakey-base/old.sqlite3")
|
||||
);
|
||||
assert_eq!(parsed["telemetry"]["json_logs"].as_bool(), Some(true));
|
||||
assert_eq!(
|
||||
parsed["telemetry"]["authorization_env"].as_str(),
|
||||
Some("WAKEY_OTLP_AUTHORIZATION")
|
||||
);
|
||||
assert_eq!(
|
||||
parsed["telemetry"]["service_name"].as_str(),
|
||||
Some("old-service")
|
||||
|
||||
@@ -231,6 +231,7 @@ fn resolve_admin_public_url(
|
||||
fn resolve_telemetry(file: Option<FileTelemetryConfig>) -> TelemetryConfig {
|
||||
let mut out = TelemetryConfig::default();
|
||||
if let Some(file) = file {
|
||||
out.authorization_env = file.authorization_env;
|
||||
if let Some(endpoint) = file.otlp_endpoint {
|
||||
let trimmed = endpoint.trim().to_string();
|
||||
if !trimmed.is_empty() {
|
||||
|
||||
@@ -23,6 +23,7 @@ pub struct DaemonConfig {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TelemetryConfig {
|
||||
pub otlp_endpoint: Option<String>,
|
||||
pub authorization_env: Option<String>,
|
||||
pub service_name: String,
|
||||
pub json_logs: bool,
|
||||
}
|
||||
@@ -32,6 +33,7 @@ impl Default for TelemetryConfig {
|
||||
let defaults = &DEFAULT_CONFIG.telemetry;
|
||||
Self {
|
||||
otlp_endpoint: defaults.otlp_endpoint.clone(),
|
||||
authorization_env: defaults.authorization_env.clone(),
|
||||
service_name: defaults.service_name.clone(),
|
||||
json_logs: defaults.json_logs,
|
||||
}
|
||||
@@ -57,6 +59,7 @@ pub(crate) struct FileConfig {
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
pub(crate) struct FileTelemetryConfig {
|
||||
pub(crate) otlp_endpoint: Option<String>,
|
||||
pub(crate) authorization_env: Option<String>,
|
||||
pub(crate) service_name: Option<String>,
|
||||
pub(crate) json_logs: Option<bool>,
|
||||
}
|
||||
@@ -81,6 +84,8 @@ pub(crate) struct WritableConfig {
|
||||
pub(crate) struct WritableTelemetry {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub(crate) otlp_endpoint: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub(crate) authorization_env: Option<String>,
|
||||
pub(crate) service_name: String,
|
||||
pub(crate) json_logs: bool,
|
||||
}
|
||||
@@ -98,6 +103,7 @@ pub(crate) static DEFAULT_CONFIG: LazyLock<WritableConfig> = LazyLock::new(|| Wr
|
||||
bootstrap_enroll_tokens: Vec::new(),
|
||||
telemetry: WritableTelemetry {
|
||||
otlp_endpoint: None,
|
||||
authorization_env: None,
|
||||
service_name: "wakey-control-plane".to_string(),
|
||||
json_logs: false,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user