Skip to content

Commit 483dccc

Browse files
committed
format
1 parent fd50b96 commit 483dccc

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

bottlecap/src/logs/lambda/processor.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl LambdaProcessor {
9696
obj.get("requestId")
9797
.or_else(|| obj.get("AWSRequestId"))
9898
.and_then(|v| v.as_str())
99-
.map(|s| s.to_string())
99+
.map(ToString::to_string)
100100
} else {
101101
None
102102
};
@@ -1563,16 +1563,25 @@ mod tests {
15631563

15641564
// Test with "requestId" field
15651565
let mut obj = serde_json::Map::new();
1566-
obj.insert("requestId".to_string(), Value::String("test-request-123".to_string()));
1567-
obj.insert("message".to_string(), Value::String("Hello World".to_string()));
1566+
obj.insert(
1567+
"requestId".to_string(),
1568+
Value::String("test-request-123".to_string()),
1569+
);
1570+
obj.insert(
1571+
"message".to_string(),
1572+
Value::String("Hello World".to_string()),
1573+
);
15681574

15691575
let event = TelemetryEvent {
15701576
time: Utc.with_ymd_and_hms(2023, 1, 7, 3, 23, 47).unwrap(),
15711577
record: TelemetryRecord::Function(Value::Object(obj)),
15721578
};
15731579

15741580
let result = processor.get_message(event).await.unwrap();
1575-
assert_eq!(result.lambda.request_id, Some("test-request-123".to_string()));
1581+
assert_eq!(
1582+
result.lambda.request_id,
1583+
Some("test-request-123".to_string())
1584+
);
15761585
}
15771586

15781587
#[tokio::test]
@@ -1605,8 +1614,14 @@ mod tests {
16051614

16061615
// Test that requestId is NOT extracted in regular Lambda mode
16071616
let mut obj = serde_json::Map::new();
1608-
obj.insert("requestId".to_string(), Value::String("test-request-789".to_string()));
1609-
obj.insert("message".to_string(), Value::String("Hello World".to_string()));
1617+
obj.insert(
1618+
"requestId".to_string(),
1619+
Value::String("test-request-789".to_string()),
1620+
);
1621+
obj.insert(
1622+
"message".to_string(),
1623+
Value::String("Hello World".to_string()),
1624+
);
16101625

16111626
let event = TelemetryEvent {
16121627
time: Utc.with_ymd_and_hms(2023, 1, 7, 3, 23, 47).unwrap(),

0 commit comments

Comments
 (0)