microclaw_engine/internal/observability/adapters/
agentops.rs1use serde_yaml::{Mapping, Value};
2
3use super::TraceTargetConfig;
4
5fn get_trimmed<'a>(map: &'a Mapping, key: &str) -> Option<&'a str> {
6 map.get(Value::String(key.to_string()))
7 .and_then(Value::as_str)
8 .map(str::trim)
9 .filter(|v| !v.is_empty())
10}
11
12pub fn apply(map: &Mapping, target: &mut TraceTargetConfig) {
13 let Some(api_key) = get_trimmed(map, "agentops_api_key") else {
14 return;
15 };
16 if target.endpoint.is_none() {
17 target.endpoint = get_trimmed(map, "agentops_otlp_endpoint").map(ToOwned::to_owned);
18 }
19 if !target
20 .headers
21 .iter()
22 .any(|(k, _)| k.eq_ignore_ascii_case("authorization"))
23 {
24 target
25 .headers
26 .push(("Authorization".to_string(), format!("Bearer {api_key}")));
27 }
28}