Skip to content

feat(typing): add tenant_id property #6985

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 3 commits into from
Jul 16, 2025
Merged

Conversation

leandrodamascena
Copy link
Contributor

Issue number: #6799

Summary

Changes

AWS Lambda RIC added a new field called tenant_id and we need to add this field to the context. This must be a string.

Also, I tested functions that already exists and new one and all of them are sending this context right now.

LambdaContext([aws_request_id=faf26568-ecb9-454b-a8f2-ff426c2fe22e,log_group_name=/aws/lambda/myfuncp13,log_stream_name=2025/06/12/[$LATEST]4c6c2d6baa594a008b5aeeea5017d6f4,function_name=myfuncp13,memory_limit_in_mb=128,function_version=$LATEST,invoked_function_arn=arn:aws:lambda:us-east-1:xxxxxx:function:myfuncp13,client_context=None,identity=CognitoIdentity([cognito_identity_id=None,cognito_identity_pool_id=None]),tenant_id=None])

User experience

Please share what the user experience looks like before and after this change

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner July 15, 2025 11:53
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jul 15, 2025
@boring-cyborg boring-cyborg bot added tests typing Static typing definition related issues (mypy, pyright, etc.) labels Jul 15, 2025
@github-actions github-actions bot added the feature New feature or functionality label Jul 15, 2025
@leandrodamascena leandrodamascena self-assigned this Jul 15, 2025
@leandrodamascena leandrodamascena requested review from dreamorosi and removed request for anafalcao July 15, 2025 11:54
Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Thanks for adding this, still need to test in Node.js.

Before merging, can you please add the key to this table?

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (9f20583) to head (2a3c118).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #6985   +/-   ##
========================================
  Coverage    96.25%   96.25%           
========================================
  Files          274      274           
  Lines        12856    12860    +4     
  Branches       950      950           
========================================
+ Hits         12374    12378    +4     
  Misses         377      377           
  Partials       105      105           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leandrodamascena
Copy link
Contributor Author

Thanks for adding this, still need to test in Node.js.

Before merging, can you please add the key to this table?

This is a good point, and I didn't intentionally change it. In Python, we don't dump the entire context to the log, but just add a few fields: https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/logging/lambda_context.py#L37

To be honest, I'm not sure we should add tenant_id to the default log context. In cases where customers aren't using tenant_id, it will only cost money with an extra key and customers will have nothing to do with this key. I'd rather wait for customer feedback if they want this in the Lambda context in the logger.

I'd like to hear from you.

@dreamorosi
Copy link
Contributor

Ok that makes sense, so this PR only adds it to the LambdaContext class/type but doesn't do any interaction with the Logger, is that correct?

If this is the case, do we want customers to know about it? Or have an easy way to use it with the Logger?

Right now if I'm using this feature in Lambda, as a customer using Logger I understand the only way I have is to do something like logger.append_key("tenant_id", context.tenant_id) (or equivalent), do we want to add a mention to the docs or show how to do something like we do with correlation ids?

@leandrodamascena
Copy link
Contributor Author

Right now if I'm using this feature in Lambda, as a customer using Logger I understand the only way I have is to do something like logger.append_key("tenant_id", context.tenant_id) (or equivalent), do we want to add a mention to the docs or show how to do something like we do with correlation ids?

I think it makes sense. Let me work in this page to add all the fields customers can access when using LambdaContext object.

@dreamorosi
Copy link
Contributor

Cool, I'm looking at notifications so feel free to re-request a review when you want me to check it.

@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Jul 16, 2025
@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 16, 2025
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jul 16, 2025
Copy link

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

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

Thank you for adding more info to the docs - let's go!

@leandrodamascena leandrodamascena merged commit 5276b9c into develop Jul 16, 2025
12 checks passed
@leandrodamascena leandrodamascena deleted the feat/add-tenant-id branch July 16, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests typing Static typing definition related issues (mypy, pyright, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Add tentant_id field to Context object and propagate to logger
2 participants