Skip to content

Commit 324c5ce

Browse files
authored
set _X_AMZN_TRACE_ID environment variable for x-ray (#341)
1 parent b3d0699 commit 324c5ce

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lambda-runtime/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ where
158158
trace!("{}", std::str::from_utf8(&body)?); // this may be very verbose
159159
let body = serde_json::from_slice(&body)?;
160160

161+
let xray_trace_id = &ctx.xray_trace_id.clone();
162+
env::set_var("_X_AMZN_TRACE_ID", xray_trace_id);
163+
161164
let request_id = &ctx.request_id.clone();
162165
let task = panic::catch_unwind(panic::AssertUnwindSafe(|| handler.call(body, ctx)));
163166

lambda-runtime/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl TryFrom<HeaderMap> for Context {
139139
.to_owned(),
140140
xray_trace_id: headers
141141
.get("lambda-runtime-trace-id")
142-
.unwrap_or(&HeaderValue::from_static("No header lambda-runtime-trace-id found."))
142+
.unwrap_or(&HeaderValue::from_static(""))
143143
.to_str()?
144144
.to_owned(),
145145
..Default::default()

0 commit comments

Comments
 (0)