Skip to content

Conversation

@bnusunny
Copy link
Collaborator

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
Collaborator 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
Collaborator 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.

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 aws: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