diff --git a/.rustfmt.toml b/.rustfmt.toml index a40f0edc..d8e9ca33 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -1,6 +1,6 @@ -edition = "2018" +edition = "2021" # imports_granularity is unstable # # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports # imports_granularity = "Crate" # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#max_width -max_width = 120 \ No newline at end of file +max_width = 120 diff --git a/lambda-runtime/Cargo.toml b/lambda-runtime/Cargo.toml index cbcdc1b5..6453615b 100644 --- a/lambda-runtime/Cargo.toml +++ b/lambda-runtime/Cargo.toml @@ -18,16 +18,26 @@ default = ["simulated"] simulated = [] [dependencies] -tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] } +tokio = { version = "1.0", features = [ + "macros", + "io-util", + "sync", + "rt-multi-thread", +] } # Hyper requires the `server` feature to work on nightly -hyper = { version = "0.14.20", features = ["http1", "client", "stream", "server"] } +hyper = { version = "0.14.20", features = [ + "http1", + "client", + "stream", + "server", +] } futures = "0.3" serde = { version = "1", features = ["derive"] } serde_json = "^1" bytes = "1.0" http = "0.2" async-stream = "0.3" -tracing = { version = "0.1", features = ["log"] } +tracing = { version = "0.1.37", features = ["log"] } tower = { version = "0.4", features = ["util"] } tokio-stream = "0.1.2" lambda_runtime_api_client = { version = "0.7", path = "../lambda-runtime-api-client" } diff --git a/lambda-runtime/src/lib.rs b/lambda-runtime/src/lib.rs index 88e66b4d..9663b375 100644 --- a/lambda-runtime/src/lib.rs +++ b/lambda-runtime/src/lib.rs @@ -124,19 +124,15 @@ where let ctx: Context = ctx.with_config(config); let request_id = &ctx.request_id.clone(); - let xray_trace_id = &ctx.xray_trace_id.clone(); - match xray_trace_id { - Some(trace_id) => env::set_var("_X_AMZN_TRACE_ID", trace_id), - None => env::remove_var("_X_AMZN_TRACE_ID"), - } - let request_span = match xray_trace_id { - Some(trace_id) => tracing::span!( - tracing::Level::INFO, - "Lambda runtime invoke", - requestId = request_id, - xrayTraceId = trace_id - ), - None => tracing::span!(tracing::Level::INFO, "Lambda runtime invoke", requestId = request_id), + let request_span = match &ctx.xray_trace_id { + Some(trace_id) => { + env::set_var("_X_AMZN_TRACE_ID", trace_id); + tracing::info_span!("Lambda runtime invoke", requestId = request_id, xrayTraceId = trace_id) + } + None => { + env::remove_var("_X_AMZN_TRACE_ID"); + tracing::info_span!("Lambda runtime invoke", requestId = request_id) + } }; // Group the handling in one future and instrument it with the span