Skip to content

allow customized User_Agent for lambda runtime api client #454

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

Merged
merged 2 commits into from
Mar 23, 2022

Conversation

bnusunny
Copy link
Contributor

Issue #, if available:

#452

Description of changes:

allow customized User_Agent for lambda runtime api client

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.

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.

I think this would be better as a runtime environment variable, so people could differentiate requests from the same compiled function in different environments.

So, instead of making it a const with option_env!, I would use std::env::var in the Client's initialization and add it to the request builder when it's not empty.

@bnusunny
Copy link
Contributor Author

We want to track the usage of AWS Lambda Adapter. Users of Lambda Adapter are not supposed to change the User-Agent.
I think customize User-Agent at compiling time is the right solution.

@bnusunny
Copy link
Contributor Author

Thanks for the suggestion. It is done. :)

@nmoutschen
Copy link
Contributor

We want to track the usage of AWS Lambda Adapter. Users of Lambda Adapter are not supposed to change the User-Agent. I think customize User-Agent at compiling time is the right solution.

Agree with this. The use-case for changing the User-Agent is pretty niche, and not something end-users need to do.

@@ -14,7 +14,8 @@ use tokio::io::{AsyncRead, AsyncWrite};
use tower_service::Service;

const USER_AGENT_HEADER: &str = "User-Agent";
const USER_AGENT: &str = concat!("aws-lambda-rust/", env!("CARGO_PKG_VERSION"));
const DEFAULT_USER_AGENT: &str = concat!("aws-lambda-rust/", env!("CARGO_PKG_VERSION"));
const CUSTOM_USER_AGENT: Option<&str> = option_env!("LAMBDA_RUNTIME_USER_AGENT");
Copy link
Contributor

Choose a reason for hiding this comment

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

@bnusunny , Harold, sorry for nit-picking, but it would be nice to have the explanation in the comments for the future us.

// Use of custom value was requested by https://github.com/aws-samples/aws-lambda-adapter for internal AWS needs. It is not something an end user would want to change and the value is not propagated to CloudWatch. See #452

@calavera calavera merged commit eac2e14 into awslabs:main Mar 23, 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.

4 participants