Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add x-ray trace id header in lambda-http #557

Merged
merged 4 commits into from Oct 28, 2022
Merged

Conversation

twu-AWS
Copy link
Contributor

@twu-AWS twu-AWS commented Oct 28, 2022

Issue #, if available:
Issue #552
Description of changes:
change xray_trace_id from string to option enum, and set the value in a env var through pattern match to make sure overwrite the incorrect xray_trace_id value

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

@bnusunny bnusunny changed the title fix for Github issue #552 add x-ray trace id header in lambda-http Oct 28, 2022
@bnusunny
Copy link
Contributor

Please check the format and clippy related issues.

if let Some(cookies) = ag.cookies {
if let Ok(header_value) = http::header::HeaderValue::from_str(&cookies.join(";")) {
if let Ok(header_value) = HeaderValue::from_str(&cookies.join(";")) { //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this comment, it's not necessary

@@ -119,8 +119,9 @@ fn into_api_gateway_v2_request(ag: ApiGatewayV2httpRequest) -> http::Request<Bod
.extension(RequestContext::ApiGatewayV2(ag.request_context));

let mut headers = ag.headers;
update_xray_trace_id_header(&mut headers); //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment, it's not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

@@ -229,6 +238,7 @@ fn into_alb_request(alb: AlbTargetGroupRequest) -> http::Request<Body> {
// multi-value_headers our cannoncial source of request headers
let mut headers = alb.multi_value_headers;
headers.extend(alb.headers);
update_xray_trace_id_header(&mut headers); //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment, it's not necessary

@@ -291,6 +301,7 @@ fn into_websocket_request(ag: ApiGatewayWebsocketProxyRequest) -> http::Request<
// multi-value_headers our cannoncial source of request headers
let mut headers = ag.multi_value_headers;
headers.extend(ag.headers);
update_xray_trace_id_header(&mut headers); //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment, it's not necessary

lambda-runtime/src/lib.rs Outdated Show resolved Hide resolved
@@ -90,7 +90,7 @@ pub struct Context {
/// The ARN of the Lambda function being invoked.
pub invoked_function_arn: String,
/// The X-Ray trace ID for the current invocation.
pub xray_trace_id: String,
pub xray_trace_id: Option<String>, //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment, it's not necessary

@@ -139,8 +139,7 @@ impl TryFrom<HeaderMap> for Context {
.to_owned(),
xray_trace_id: headers
.get("lambda-runtime-trace-id")
.unwrap_or(&HeaderValue::from_static(""))
.to_str()?
.map(|v| String::from_utf8_lossy(v.as_bytes()).to_string()) //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the comment, it's not necessary

Copy link
Contributor

@calavera calavera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you mark the two checkboxes in the PR description, otherwise we cannot accept this contribution.

if let Some(cookies) = ag.cookies {
if let Ok(header_value) = http::header::HeaderValue::from_str(&cookies.join(";")) {
if let Ok(header_value) = HeaderValue::from_str(&cookies.join(";")) { //Github issue #552
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment

@calavera calavera merged commit 1fc2ccb into awslabs:main Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants