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

chore(user-agent): support patching botocore session #2614

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions aws_lambda_powertools/shared/user_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,31 @@ def register_feature_to_session(session, feature):
logger.debug(f"session passed in doesn't have a event system:{e}")


# Add feature user-agent to given sdk botocore.session.Session
def register_feature_to_botocore_session(botocore_session, feature):
heitorlessa marked this conversation as resolved.
Show resolved Hide resolved
"""
Register the given feature string to the event system of the provided boto3 session
and append the feature to the User-Agent header of the request

Parameters
----------
botocore_session : botocore.session.Session
The botocore session to which the feature will be registered.
feature : str
The feature string to be appended to the User-Agent header, e.g., "data-masking" in Powertools.

Raises
------
AttributeError
If the provided session does not have an event system.

"""
try:
botocore_session.register(TARGET_SDK_EVENT, _create_feature_function(feature))
except AttributeError as e:
logger.debug(f"botocore session passed in doesn't have a event system:{e}")


# Add feature user-agent to given sdk boto3.client
def register_feature_to_client(client, feature):
"""
Expand Down