Skip to content

Commit bba60f5

Browse files
error handling
1 parent 1fe1f35 commit bba60f5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/otel/otel_utils.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,18 @@ fn merge_with_existing_attributes(
245245
attributes: &Map<String, Value>,
246246
attrs_str: &str,
247247
) -> Option<String> {
248-
if let Ok(mut existing_attrs) = serde_json::from_str::<Map<String, Value>>(attrs_str) {
249-
for (key, value) in attributes {
250-
existing_attrs.insert(key.clone(), value.clone());
248+
match serde_json::from_str::<Map<String, Value>>(attrs_str) {
249+
Ok(mut existing_attrs) => {
250+
for (key, value) in attributes {
251+
existing_attrs.insert(key.clone(), value.clone());
252+
}
253+
serde_json::to_string(&existing_attrs).ok()
254+
}
255+
Err(e) => {
256+
tracing::warn!("failed to deserialize existing attributes: {e}");
257+
None
251258
}
252-
return serde_json::to_string(&existing_attrs).ok();
253259
}
254-
None
255260
}
256261

257262
/// Merge attributes with an existing JSON object of attributes

0 commit comments

Comments
 (0)