Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d0792f3
fix
lalitb Jul 30, 2025
880d6e5
fix
lalitb Jul 30, 2025
0a60b82
fix
lalitb Jul 30, 2025
78be687
more changes
lalitb Jul 30, 2025
a0797f7
Merge branch 'main' into custom-user-agent
lalitb Aug 1, 2025
99f10d7
fix
lalitb Aug 1, 2025
2806cf3
Merge branch 'custom-user-agent' of github.com:lalitb/opentelemetry-r…
lalitb Aug 1, 2025
606caf6
Merge branch 'main' into custom-user-agent
lalitb Aug 1, 2025
76da83c
fix
lalitb Aug 1, 2025
a381d16
Merge branch 'custom-user-agent' of github.com:lalitb/opentelemetry-r…
lalitb Aug 1, 2025
50d94cd
fix
lalitb Aug 1, 2025
7ecda1b
fix
lalitb Aug 1, 2025
7b2d972
fix
lalitb Aug 1, 2025
d912832
fix
lalitb Aug 1, 2025
504845e
add missing common.rs
lalitb Aug 1, 2025
5881c06
add user-agent support in ingestion_service
lalitb Aug 1, 2025
f57c640
fix warning
lalitb Aug 1, 2025
80e4528
fix
lalitb Aug 1, 2025
d623496
more rearrange
lalitb Aug 1, 2025
9cb1145
fix
lalitb Aug 1, 2025
3c02e09
add todo
lalitb Aug 1, 2025
683820c
fix
lalitb Aug 1, 2025
1675d6c
reformat
lalitb Aug 1, 2025
c7121d1
build errors
lalitb Aug 1, 2025
2ec20c4
fix
lalitb Aug 1, 2025
6ab85ab
Merge branch 'main' into custom-user-agent
lalitb Aug 3, 2025
6fb82cb
Merge branch 'main' into custom-user-agent
lalitb Aug 6, 2025
643e5ab
Merge branch 'main' into custom-user-agent
lalitb Nov 3, 2025
e2d84be
remove non-ascii validation
lalitb Nov 3, 2025
f5d840d
fix nit
lalitb Nov 3, 2025
ca74e81
nit doc
lalitb Nov 3, 2025
a2d68e4
more build fix
lalitb Nov 4, 2025
143548a
doc fix
lalitb Nov 4, 2025
aa6fb5e
fix
lalitb Nov 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions opentelemetry-exporter-geneva/geneva-uploader/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ pub struct GenevaClientConfig {
pub role_instance: String,
/// Maximum number of concurrent uploads. If None, defaults to number of CPU cores.
pub max_concurrent_uploads: Option<usize>,
/// User agent for the application. Will be formatted as "<application> (RustGenevaClient/0.1)".
/// If None, defaults to "RustGenevaClient/0.1".
///
/// Examples:
/// - None: "RustGenevaClient/0.1"
/// - Some("MyApp/2.1.0"): "MyApp/2.1.0 (RustGenevaClient/0.1)"
/// - Some("ProductionService-1.0"): "ProductionService-1.0 (RustGenevaClient/0.1)"
pub user_agent_suffix: Option<&'static str>,
// Add event name/version here if constant, or per-upload if you want them per call.
}

Expand All @@ -47,6 +55,7 @@ impl GenevaClient {
region: cfg.region,
config_major_version: cfg.config_major_version,
auth_method: cfg.auth_method,
user_agent_suffix: cfg.user_agent_suffix,
};
let config_client = Arc::new(
GenevaConfigClient::new(config_client_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ pub(crate) struct GenevaConfigClientConfig {
pub(crate) namespace: String,
pub(crate) region: String,
pub(crate) config_major_version: u32,
pub(crate) auth_method: AuthMethod, // agent_identity and agent_version are hardcoded for now
pub(crate) auth_method: AuthMethod,
/// User agent for the application. Will be formatted as "<application> (RustGenevaClient/0.1)".
/// If None, defaults to "RustGenevaClient/0.1".
///
/// Examples:
/// - None: "RustGenevaClient/0.1"
/// - Some("MyApp/2.1.0"): "MyApp/2.1.0 (RustGenevaClient/0.1)"
/// - Some("ProductionService-1.0"): "ProductionService-1.0 (RustGenevaClient/0.1)"
pub(crate) user_agent_suffix: Option<&'static str>,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -259,9 +267,11 @@ impl GenevaConfigClient {
}
}

let agent_identity = "GenevaUploader";
let agent_identity = "RustGenevaClient";
let agent_version = "0.1";
let static_headers = Self::build_static_headers(agent_identity, agent_version);
let user_agent_suffix = config.user_agent_suffix.as_deref().unwrap_or("");
let static_headers =
Self::build_static_headers(agent_identity, agent_version, user_agent_suffix);

let identity = format!("Tenant=Default/Role=GcsClient/RoleInstance={agent_identity}");

Expand Down Expand Up @@ -302,9 +312,17 @@ impl GenevaConfigClient {
.map(|dt| dt.with_timezone(&Utc))
}

fn build_static_headers(agent_identity: &str, agent_version: &str) -> HeaderMap {
fn build_static_headers(
agent_identity: &str,
agent_version: &str,
user_agent_suffix: &str,
) -> HeaderMap {
let mut headers = HeaderMap::new();
let user_agent = format!("{agent_identity}-{agent_version}");
let user_agent = if user_agent_suffix.is_empty() {
format!("{}/{}", agent_identity, agent_version)
} else {
format!("{} ({}/{})", user_agent_suffix, agent_identity, agent_version)
};
headers.insert(USER_AGENT, HeaderValue::from_str(&user_agent).unwrap());
headers.insert(ACCEPT, HeaderValue::from_static("application/json"));
headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod tests {
region: "region".to_string(),
config_major_version: 1,
auth_method: AuthMethod::ManagedIdentity,
user_agent_suffix: Some("TestApp/1.0"),
};

assert_eq!(config.environment, "env");
Expand Down Expand Up @@ -107,6 +108,7 @@ mod tests {
path: PathBuf::from(temp_p12_file.path().to_string_lossy().to_string()),
password,
},
user_agent_suffix: Some("MockClient/1.0"),
};

let client = GenevaConfigClient::new(config).unwrap();
Expand Down Expand Up @@ -152,6 +154,7 @@ mod tests {
path: PathBuf::from(temp_p12_file.path().to_string_lossy().to_string()),
password,
},
user_agent_suffix: Some("ErrorTestApp/1.0"),
};

let client = GenevaConfigClient::new(config).unwrap();
Expand Down Expand Up @@ -200,6 +203,7 @@ mod tests {
path: PathBuf::from(temp_p12_file.path().to_string_lossy().to_string()),
password,
},
user_agent_suffix: Some("MissingInfoTestApp/1.0"),
};

let client = GenevaConfigClient::new(config).unwrap();
Expand Down Expand Up @@ -231,6 +235,7 @@ mod tests {
path: PathBuf::from("/nonexistent/path.p12".to_string()),
password: "test".to_string(),
},
user_agent_suffix: Some("InvalidCertTestApp/1.0"),
};

let result = GenevaConfigClient::new(config);
Expand Down Expand Up @@ -294,6 +299,7 @@ mod tests {
path: PathBuf::from(cert_path),
password: cert_password,
},
user_agent_suffix: Some("RealServerTestApp/1.0"),
};

println!("Connecting to real Geneva Config service...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ mod tests {
path: cert_path,
password: cert_password,
},
user_agent_suffix: Some("TestUploader".to_string()),
};

// Build client and uploader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ async fn main() {
role_name,
role_instance,
max_concurrent_uploads: None, // Use default
user_agent_suffix: Some("BasicExample".to_string()),
};

let geneva_client = GenevaClient::new(config)
Expand Down
Loading